Changeset 482 in PSPA


Ignore:
Timestamp:
Jan 21, 2014, 1:52:16 PM (10 years ago)
Author:
touze
Message:

maj dans le fichier d'appel de madx

Location:
Interface_Web/trunk/pspaWT/sources/controler
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/include/beam2Moments.h

    r386 r482  
    1919
    2020 public :
    21 
     21 
    2222  beam2Moments();
    23 
    24 ~beam2Moments();
     23 
     24  ~beam2Moments();
    2525
    2626
    27 beam2Moments( beam2Moments& tm);
     27  beam2Moments( beam2Moments& tm);
    2828
    29 beam2Moments(const beam2Moments& tm);
     29  beam2Moments(const beam2Moments& tm);
    3030
    31  beam2Moments(double x, double xp, double y, double yp, double dl, double del);
     31  beam2Moments(double x, double xp, double y, double yp, double dl, double del);
    3232
    33 // const vector< vector<double> >& getMoments() const;
    34  vector< vector<double> >& getMatrix();
    35  void raz();
     33  // const vector< vector<double> >& getMoments() const;
     34  vector< vector<double> >& getMatrix();
     35  const vector< vector<double> >& getMoments() const;
    3636
    37  // void readFromTransportOutput(ifstream& inp);
    38  bool readFromTransportOutput(stringstream& inp);
    39  string writeToTransportInput(double P0) const;
     37  void raz();
    4038
    41  void impression() const;
     39  // void readFromTransportOutput(ifstream& inp);
     40  bool readFromTransportOutput(stringstream& inp);
     41  string writeToTransportInput(double P0) const;
     42
     43  void impression() const;
    4244
    4345  // operators
  • Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h

    r480 r482  
    3939  inline std::vector< abstractElement* > getElements() {return elements_;};
    4040 
     41  inline sector* getSector() const {return sector_;};
     42
    4143  /**
    4244   Get the last element of this section
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareMadx.h

    r472 r482  
    88class softwareMadx : public abstractSoftware
    99{
     10  string BEAMcommand(particleBeam*) const;
     11  string RFGunData(const vector<statements>&) const;
    1012  string inputFormat(const vector<statements>&) const;
    1113
     
    1315 
    1416  softwareMadx();
    15   softwareMadx(string,sectionToExecute*, dataManager*);
     17  softwareMadx(string,sectionToExecute*,dataManager*);
    1618  virtual ~softwareMadx() {;}
    1719
    18   virtual bool createInputFile(particleBeam*, string);
     20  virtual bool createInputFile(particleBeam*,string);
    1921  virtual bool execute(string);
    2022  virtual bool buildBeamAfterElements(string);
  • Interface_Web/trunk/pspaWT/sources/controler/src/beam2Moments.cc

    r386 r482  
    4949}
    5050
     51const vector< vector<double> >& beam2Moments::getMoments() const
     52{
     53  return rij_secondOrderMoments_;
     54}
    5155
    5256void beam2Moments::impression() const {
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r481 r482  
    7878  string workingDir = pspa_->getWorkingDir();
    7979 
    80 
    8180  // Main loop !
    82   for(unsigned k = 0; k < jobList_.size(); k++) {
    83     sector* sector = jobList_[k];
    84    
    85     // for the moment, we put everything in one line without loops
    86     for (unsigned int l=0; l <sector->getSectionsToExecute().size(); l++) {
    87       sectionToExecute* section = sector->getSectionsToExecute()[l];
    88       abstractSoftware* softw = section->getSoftware();
     81  cout << " dataManager::executeAll #jobList_= " << jobList_.size() << endl;
     82  for(unsigned k = 0; k < jobList_.size(); k++)
     83    {
     84      sector* sector = jobList_[k];
     85      cout << " dataManager::executeAll sector name= " << sector->getName() << endl;
     86      cout << " dataManager::executeAll #sectionsToExecute= " << sector->getSectionsToExecute().size() << endl;
    8987     
    90 #if BAVARD > 0
    91     cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
    92 #endif
    93      
     88      // for the moment, we put everything in one line without loops
     89      for(unsigned int l = 0; l < sector->getSectionsToExecute().size(); l++)
     90        {
     91          sectionToExecute* section = sector->getSectionsToExecute()[l];
     92          abstractSoftware* softw = section->getSoftware();
     93         
    9494      //cout << "k= " << k << ", de " << jobList_[k]->getFirstElement()->getLabel() << " à " << jobList_[k]->getLastElement()->getLabel() << " avec " << softw->getName() << endl;
    9595     
     
    9999      break;
    100100    }
    101       // END OF FIXME
    102       success = softw->createInputFile(sector->getParticleBeam(),workingDir);
     101   
     102    success = softw->createInputFile(sector->getParticleBeam(),workingDir);
    103103    if ( success ) {
    104104      success = softw->execute(workingDir);
     
    110110    if ( success  && (diagnosticBeam_.size() > 0)) {
    111111      sector->setParticleBeam(&diagnosticBeam_.at(indexElementToIndexDiag_.back()));
    112       cout << " execute termine avec succes " << endl;
     112      cout << " dataManager::executeAll termine avec succes " << endl;
    113113    } else {
    114114      sector->setParticleBeam(NULL);
    115       cout << " execute termine en ECHEC " << endl;
     115      cout << " dataManager::executeAll termine en ECHEC " << endl;
    116116    }
    117117    if ( !success ) break;
    118118   
    119119#if BAVARD > 0
    120       cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
    121       cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
    122       std::vector< abstractElement* > elements = section->getElements();
    123       for (unsigned j = 0; j < elements.size(); j++) {
    124         cout << "[" << j << "] " << elements[j]->getNomdElement().getExpandedName() << endl;
    125       }
     120          cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
     121          cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
     122          std::vector< abstractElement* > elements = section->getElements();
     123          for (unsigned j = 0; j < elements.size(); j++) {
     124            cout << "[" << j << "] " << elements[j]->getNomdElement().getExpandedName() << endl;
     125          }
    126126#endif
    127     } //l
    128   } //k
     127        } //l
     128    } //k
     129 
    129130  // if ( currentBeam_deprecated_ ) {
    130131  // string aml_file = workingDir + "/" + "faisceau_final" + ".aml";
     
    133134  //   currentBeam_deprecated_->readFromAMLFile(aml_file);
    134135  // }
    135   cout << " dataManager::executeAll() " << endl;
    136 
     136 
    137137  return success;
    138138}
  • Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc

    r455 r482  
    357357  vector<double> part(6, 0.0);
    358358
    359     vector< vector<double> >& matrice = rij_.getMatrix();
     359  vector< vector<double> >& matrice = rij_.getMatrix();
    360360
    361361    TRIDVECTOR positionDeployee;
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareMadx.cc

    r472 r482  
    33#include "dataManager.h"
    44
     5#include "mathematicalConstants.h"
     6#include "PhysicalConstants.h"
     7
    58softwareMadx::softwareMadx() : abstractSoftware()
    69{
     
    1215  nameOfSoftware_ = nomDeLogiciel("madx");
    1316
     17 registerElement(nomdElements::RFgun,TBoolOk);
    1418  registerElement(nomdElements::drift,TBoolOk);
    1519  registerElement(nomdElements::mpole,TBoolOk);
    1620}
    1721
    18 bool softwareMadx::createInputFile(particleBeam* beamBefore, string workingDir)
     22bool softwareMadx::createInputFile(particleBeam* beamBefore,string workingDir)
    1923{
    2024  cout << "***********************************" << endl;
    2125  cout << " softwareMadx::createInputFile(...) " << endl << endl;
    22 
    2326  dataManager_->consoleMessage(" softwareMadx::createInputFile");
    2427
     
    3235  }
    3336
    34   cout << " softwareMadx::createInputFile(...) lecture des elts " << endl;
    35  
     37  sector* sector= getSectionToExecute()->getSector();
     38  cout << " softwareMadx::createInputFile sector " << sector->getName() << endl;
     39  ///////////////////////////////////////////
     40 
     41  unsigned firstIndex= 0;
     42  string sbeam;
     43  abstractElement* elPtr;
     44  elPtr = getSectionToExecute()->getElements().front();
     45
     46  // le 1er elt n'est pas RFGun
     47  if(elPtr->getNomdElement().getElementType() != nomdElements::RFgun) {
     48   
     49    if(beamBefore == NULL) {
     50      // il n'y a pas de faisceau : erreur
     51      dataManager_->consoleMessage(" softwareMadx::createInputFile : no input beam, input file not created");
     52      return false;
     53    } else {
     54      // il y a un faisceau : on le met au format madx
     55      dataManager_->consoleMessage(" softwareMadx::createInputFile : extract from input beam the quantities to be supplied to the madx BEAM command");
     56     
     57      if (beamBefore->particleRepresentationOk()) {
     58        // le faisceau est représenté à la "parmela"
     59        cout << "passsage de la représentation macroparticules à la representation moments" << endl;
     60        beamBefore->buildMomentRepresentation();
     61      } else if(beamBefore->momentRepresentationOk()) {
     62        // le faisceau est représenté à la "transport"
     63        cout << "le faisceau est représenté par moments" << endl;
     64      } else {
     65        // représentation ni "macroparticules" ni "moments"
     66        dataManager_->consoleMessage(" softwareMadx::createInputFile : that's unclear: the beam is represented neither by macroparticles neither by moments");
     67        return false;
     68      }
     69
     70      sbeam = BEAMcommand(beamBefore);
     71    }
     72   
     73    // le 1er elt est RFGun
     74  } 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  }
     79  ///////////////////////////////////////////
     80
    3681  // element label //////////////////////////
    37 
    3882  outfile << endl; // saut de ligne
    3983
    40   abstractElement* elPtr;
    41   std::vector <abstractElement*> elements = getSectionToExecute()->getElements();
    42   for(unsigned k = 0; k < elements.size(); k++)
     84  ostringstream os;
     85  os << "L: line=(";
     86  unsigned nElts= getSectionToExecute()->getElements().size();
     87  for(unsigned k = firstIndex; k < nElts; k++)
    4388    {
    44       elPtr = elements[k];
    45       //cout << " debug:: element [" << k << "] " << elPtr->getNomdElement().getExpandedName() << endl;
     89      elPtr = getSectionToExecute()->getElements()[k];
     90      cout << " debug:: element [" << k << "] " << elPtr->getNomdElement().getExpandedName() << endl;
    4691      vector<statements> v= elPtr->parametersToSoftware();
    4792      outfile << inputFormat(v);
    48     }
    49 
    50   // sublines ///////////////////////////////
    51 
     93
     94      if(k < nElts-1)
     95        os << elPtr->getLabel() << ",";
     96      else
     97        os << elPtr->getLabel() << ");" << endl;
     98    }
     99
     100  // lines/sublines ///////////////////////////////
    52101  outfile << endl; // saut de ligne
    53 
    54   //_______________________________________________________
    55   // FIXME Francois !!!!!
    56   //_______________________________________________________
    57  /*
    58   vector<statements> u = sectParamPtr_->getSectors();
    59   for(unsigned int i = 0; i < u.size(); i++) {
    60     ostringstream os;
    61     os << u.at(i).first << ": line=(";
    62     unsigned ai = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(0));
    63     unsigned bi = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(1));
    64 
    65     std::vector <abstractElement*> elements = getSectionToExecute()->getElements();
    66     for(unsigned k = 0; k < elements.size(); k++) {
    67       elPtr = elements[k];
    68      
    69       if(k >= ai && k <= bi) {
    70         if(k == bi)
    71           os << elPtr->getLabel() <<");";
    72         else
    73           os << elPtr->getLabel() <<",";
    74       }
    75     }// k
    76 
    77     outfile << os.str() << endl;
    78   }// i
    79 
     102 
    80103  // relection and repetition ///////////////
    81 
     104  os << "all: " << "line=(" << sector->getRepetitionNumber() << "*L);";
     105  ///////////////////////////////////////////
     106 
     107  outfile << os.str() << endl;
    82108  outfile << endl; // saut de ligne
    83 
    84   string *str= NULL;
    85   if(u.size() > 0) {
    86     str = new string[u.size()];
    87     for(unsigned int i = 0; i < u.size(); i++) str[i]= "false";
    88   }
    89 
    90   ostringstream os;
    91   os << "all: " << "line=(";
    92   for(unsigned k = 0; k < elements.size(); k++) {
    93     elPtr = elements[k];
    94     bool isMember = false;
    95 
    96     for(unsigned int i = 0; i < u.size(); i++) {
    97       unsigned ai = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(0));
    98       unsigned bi = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(1));
    99       if(k >= ai && k <= bi) {
    100         isMember = true;
    101 
    102         if(str[i] == "false") {
    103           //int reflection = atoi(u.at(i).second.at(2).c_str());
    104           int reflection = ( (u.at(i).second.at(2) == "Unchecked") ? 0:1 );
    105           int repeat = atoi(u.at(i).second.at(3).c_str());
    106           if(reflection > 0)
    107             os << "-" << repeat << "*" << u.at(i).first;
    108           else
    109             os << repeat << "*" << u.at(i).first;
    110 
    111           if(i < u.size()-1) os << ", ";
    112         }
    113 
    114         str[i] = "true";
    115         break;
    116       }
    117     }// i
    118    
    119     if(isMember && k == (elements.size()-1)) os << ");";
    120    
    121     if(!isMember) {
    122       if(k == (elements.size()-1)) os << elPtr->getLabel() << ");";
    123       else os << elPtr->getLabel() << ",";
    124     }
    125   }// k
    126 
    127   outfile << os.str() << endl;
    128   ///////////////////////////////////////////
    129      
    130   outfile << endl; // saut de ligne
    131 
    132   outfile << "beam;" << endl; // beam data p46
     109  ///////////////////////////////////////////
     110
     111  outfile << sbeam << endl; // beam commnd p46
    133112  outfile << "use, period = all;" << endl << endl; // action commands p45
    134113 
     
    137116  outfile << "stop;" << endl;
    138117
    139   */
    140   //_______________________________________________________
    141   // FIXME Francois !!!!!
    142   //_______________________________________________________
    143 
    144118  outfile.close();
    145119  dataManager_->consoleMessage("input file done for madx");
    146120  return true;
     121}
     122
     123string softwareMadx::BEAMcommand(particleBeam* beam) const
     124{
     125  // le 20 décembre : les commandes BEAM de madx sont :
     126  // PARTICLE (defaut POSITRON)
     127  // ENERGY (defaut 1 GeV) ou bien PC GeV/c
     128  // EX et EY (defaut 1 m.rad)
     129  // ET (defaut 1 m)
     130
     131  ostringstream os;
     132  os << "beam, PARTICLE = ELECTRON";
     133
     134  double pc = beam->getP0Transport();
     135  os << ", ENERGY = " << pc; // en GeV
     136
     137  const beam2Moments& mts = beam->getTransportMoments();
     138  const vector< vector<double> > rij= mts.getMoments();
     139
     140  // emittance (x,x')
     141  double r10= rij.at(1).at(0); // r10 et s10 = s01= r10*r00*r11
     142  double rac= 0.0;
     143  if(r10*r10 < 1.0) rac= sqrt(1.0-r10*r10);
     144  double EX = rij.at(0).at(0)*rij.at(1).at(1)*rac; // r00*r11*sqrt(1-s01*s10)
     145  // r00 en cm (= 1E-02 m) et r11 en mrad (= 1E-03 rad)
     146  os << ", EX = " << EX*1.E-05;
     147
     148  // emittance (y,y')
     149  double r32= rij.at(3).at(2); // r32 et s32 = s23= r32*r22*r33
     150  rac= 0.0;
     151  if(r32*r32 < 1.0) rac= sqrt(1.0-r32*r32);
     152  double EY = rij.at(2).at(2)*rij.at(3).at(3)*rac; // r22*r33*sqrt(1-s23*s32)
     153  os << ", EY = " << EY*1.E-05;
     154
     155  os << ";";
     156  return os.str();
     157}
     158
     159string softwareMadx::RFGunData(const vector<statements>& v) const
     160{
     161  //NPART = v.at(1).second.at(0);
     162  //SIGT (m) = v.at(2).second.at(0) (ps)
     163  //?? = sigma_r = v.at(2).second.at(1); en cm
     164  //EX (m.rad) = v.at(3).second.at(0) (pi.mm.mrad)
     165  //EY (m.rad) = v.at(3).second.at(1) (pi.mm.mrad)
     166  //ENERGY (GeV) = v.at(4).second.at(0) (MeV)
     167  //SIGE (GeV) = v.at(4).second.at(1) (MeV)
     168  //CHARGE = v.at(6).second.at(0);
     169
     170  ostringstream os;
     171  os << "beam, PARTICLE = ELECTRON";
     172
     173  // masse au repos (en GeV) E0 = 1.E-03*EREST_MeV
     174  // energie cinetique (en GeV) T = 1.E-03*E_cin
     175  // l'energie totale  (en Gev) W = E0+T
     176  double W = 1.E-03*(EREST_MeV + atof(v.at(4).second.at(0).c_str()));
     177  os << ", ENERGY = " << W; // total energy in [Gev]
     178
     179  // pi*EX = 1E-06*emit_x en pi.m.rad
     180  double EX = 1.E-06*atof(v.at(3).second.at(0).c_str())/PI;
     181  os << ", EX = " << EX; // horizontal emittance in [rad.m]
     182  double EY = 1.E-06*atof(v.at(3).second.at(1).c_str())/PI;
     183  os << ", EY = " << EY; // vertical emittance in [rad.m]
     184
     185  // SIGT = c*sigma_t*1E-12
     186  double SIGT = 1.E-04*CLIGHT_E8*atof(v.at(2).second.at(0).c_str());
     187  os << ", SIGT = " << SIGT; // bunch length in [m]
     188
     189  // SIGE = sigma_Ecin/(p0*c) ou p0 impulsion de la paricule de réf.
     190  // os << ", SIGE = " << atof(v.at(4).second.at(1).c_str());
     191
     192  os << ";";
     193  return os.str();
    147194}
    148195
     
    216263}
    217264
     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
    218274bool softwareMadx::buildBeamAfterElements(string workingDir)
    219275{
     
    221277  cout << " softwareMadx::buildBeamAfterElements(...) " << endl << endl;
    222278
    223   dataManager_->consoleMessage(" softwareMadx::buildBeamAfterElements");
     279  dataManager_->consoleMessage(" softwareMadx::buildBeamAfterElements: not programmed :O((");
    224280  return false;
    225281}
Note: See TracChangeset for help on using the changeset viewer.