Changeset 484 in PSPA
- Timestamp:
- Jan 22, 2014, 3:43:41 PM (10 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources/controler
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/include/softwareMadx.h
r482 r484 8 8 class softwareMadx : public abstractSoftware 9 9 { 10 string BEAMcommand(particleBeam*) const; 11 string RFGunData(const vector<statements>&) const; 10 string emittances(const beam2Moments&) const; 11 string beamData(particleBeam*) const; 12 string beamData(const vector<statements>&) const; 13 string RFgunData(const vector<statements>&) const; 12 14 string inputFormat(const vector<statements>&) const; 13 15 -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareMadx.cc
r482 r484 5 5 #include "mathematicalConstants.h" 6 6 #include "PhysicalConstants.h" 7 8 #include <boost/filesystem.hpp> 7 9 8 10 softwareMadx::softwareMadx() : abstractSoftware() … … 43 45 abstractElement* elPtr; 44 46 elPtr = getSectionToExecute()->getElements().front(); 45 46 // le 1er elt n'est pas RFGun 47 if(elPtr->getNomdElement().getElementType() != nomdElements::RFgun) { 48 47 nomdElements::typedElement eType = elPtr->getNomdElement().getElementType(); 48 49 if(eType == nomdElements::RFgun) { 50 // le 1er elt est RFgun 51 firstIndex = 1; 52 dataManager_->consoleMessage(" softwareMadx::createInputFile : set from RF cavity the quantities to be supplied to the madx BEAM command"); 53 sbeam = RFgunData(elPtr->parametersToSoftware()); 54 } else if(eType == nomdElements::beam) { 55 // le 1er elt est beam 56 firstIndex = 1; 57 dataManager_->consoleMessage(" softwareMadx::createInputFile : set from beam the quantities to be supplied to the madx BEAM command"); 58 sbeam = beamData(elPtr->parametersToSoftware()); 59 } else { 60 // on suppose qu'il y a déjà un faisceau 49 61 if(beamBefore == NULL) { 50 62 // il n'y a pas de faisceau : erreur … … 67 79 return false; 68 80 } 69 70 sbeam = BEAMcommand(beamBefore); 81 sbeam = beamData(beamBefore); 71 82 } 72 73 // le 1er elt est RFGun74 } else {75 firstIndex = 1;76 dataManager_->consoleMessage(" softwareMadx::createInputFile : set from RF cavity the quantities to be supplied to the madx BEAM command");77 sbeam = RFGunData(elPtr->parametersToSoftware());78 83 } 79 84 /////////////////////////////////////////// … … 121 126 } 122 127 123 string softwareMadx::BEAMcommand(particleBeam* beam) const 124 { 125 // le 20 décembre : les commandes BEAM de madx sont : 128 string softwareMadx::beamData(const vector<statements>& v) const 129 { 130 // x (cm) = v.at(1).second.at(0) 131 // xp (mrad) = v.at(1).second.at(1) 132 // y (cm) = v.at(1).second.at(2) 133 // yp (mrad) = v.at(1).second.at(3) 134 // dl (cm) = v.at(2).second.at(0) 135 // del (mrad) = v.at(2).second.at(1) 136 // p0 (GeV/c) = v.at(3).second.at(0) 137 138 ostringstream os; 139 os << "beam, PARTICLE = ELECTRON"; 140 141 double PC = atof(v.at(3).second.at(0).c_str()); 142 os << ", ENERGY = " << PC; // momentum of the central trajectory [GeV/c] 143 144 double x = atof(v.at(1).second.at(0).c_str()); 145 double xp = atof(v.at(1).second.at(1).c_str()); 146 double y = atof(v.at(1).second.at(2).c_str()); 147 double yp = atof(v.at(1).second.at(3).c_str()); 148 double dl = atof(v.at(2).second.at(0).c_str()); 149 double del= atof(v.at(2).second.at(1).c_str()); 150 beam2Moments mts(x,xp,y,yp,dl,del); 151 os << emittances(mts) << ";"; 152 return os.str(); 153 } 154 155 string softwareMadx::beamData(particleBeam* beam) const 156 { 157 // les commandes BEAM de madx sont : 126 158 // PARTICLE (defaut POSITRON) 127 159 // ENERGY (defaut 1 GeV) ou bien PC GeV/c … … 132 164 os << "beam, PARTICLE = ELECTRON"; 133 165 134 double pc= beam->getP0Transport();135 os << ", ENERGY = " << pc; // en GeV166 double PC = beam->getP0Transport(); 167 os << ", ENERGY = " << PC; // en GeV/c 136 168 137 169 const beam2Moments& mts = beam->getTransportMoments(); 170 os << emittances(mts) << ";"; 171 return os.str(); 172 } 173 174 string softwareMadx::emittances(const beam2Moments& mts) const 175 { 138 176 const vector< vector<double> > rij= mts.getMoments(); 177 ostringstream os; 139 178 140 179 // emittance (x,x') … … 153 192 os << ", EY = " << EY*1.E-05; 154 193 155 os << ";";156 194 return os.str(); 157 195 } 158 196 159 string softwareMadx::RF GunData(const vector<statements>& v) const197 string softwareMadx::RFgunData(const vector<statements>& v) const 160 198 { 161 199 //NPART = v.at(1).second.at(0); … … 228 266 229 267 dataManager_->consoleMessage(" softwareMadx::execute"); 268 ostringstream sortie; 230 269 bool status= true; 231 232 ostringstream sortie;233 sortie << " run madx " << endl;234 235 270 string mjob = workingDir + "madx64"; 236 mjob += string(" < "); 237 mjob += workingDir + inputFileName_; 238 cout << " job madx = " << mjob << endl; 239 240 string resultOfRun; 241 bool success = launchJob(mjob,resultOfRun); 242 // xx sortie << resultOfRun << endl; 243 if ( !success ) { 244 //sortie << " launching of madx failed " << endl; 271 272 if(!boost::filesystem::exists(mjob.c_str())) { 273 sortie << "Error:: " << mjob << " does not exist\n"; 245 274 status = false; 246 275 } else { 247 sortie << " madx finished normally" << endl; 248 string nameOut = workingDir + "madx.output"; 249 ofstream outfile; 250 outfile.open(nameOut.c_str(),ios::out); 251 if (!outfile) { 252 sortie << " error in opening madx output stream " << nameOut << endl; 276 mjob += string(" < "); 277 mjob += workingDir + inputFileName_; 278 sortie << " run " << mjob << endl; 279 string resultOfRun; 280 bool success = launchJob(mjob,resultOfRun); 281 // xx sortie << resultOfRun << endl; 282 if ( !success ) { 283 //sortie << " launching of madx failed " << endl; 253 284 status = false; 254 285 } else { 255 // on copie la sortie dans un fichier 'madx.out' 256 outfile << resultOfRun << endl; 257 outfile.close(); 286 sortie << " madx finished normally" << endl; 287 string nameOut = workingDir + "madx.output"; 288 ofstream outfile; 289 outfile.open(nameOut.c_str(),ios::out); 290 if (!outfile) { 291 sortie << " error in opening madx output stream " << nameOut << endl; 292 status = false; 293 } else { 294 // on copie la sortie dans un fichier 'madx.out' 295 outfile << resultOfRun << endl; 296 outfile.close(); 297 } 258 298 } 259 299 } … … 263 303 } 264 304 265 // bool softwareMadx::execute(string workingDir)266 // {267 // cout << "***********************************" << endl;268 // cout << " softwareMadx::execute(...) " << endl << endl;269 270 // dataManager_->consoleMessage(" softwareMadx::execute");271 // return false;272 // }273 274 305 bool softwareMadx::buildBeamAfterElements(string workingDir) 275 306 {
Note: See TracChangeset
for help on using the changeset viewer.