Changeset 424 in PSPA for Interface_Web/trunk/pspaWT/sources/controler/src/elementBend.cc
- Timestamp:
- Sep 30, 2013, 5:03:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/src/elementBend.cc
r418 r424 11 11 nbParam_ = elementName_.getElementNbParameters(); 12 12 parametersString_ = new string[nbParam_+1]; 13 // registerAcceptableSoftware(nomDeLogiciel::transport, TBoolOk); 14 // registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolOk); 15 } 16 17 void elementBend::setDefaultValues() 18 { 19 defaultSpecificName_ = "bend"; 20 angleDegDef_ = 0.0; 21 radiusDef_ = 1.0; 22 beta1Def_ = 0.0; 23 beta2Def_ = 0.0; 24 momentumDef_ = 0.0; 13 // registerAcceptableSoftware(nomDeLogiciel::transport, TBoolOk); 14 // registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolOk); 15 } 16 17 void elementBend::setDefaultValues() 18 { 19 defaultSpecificName_ = "bend"; 20 angleDegDef_ = 0.0; 21 radiusDef_ = 1.0; 22 beta1Def_ = 0.0; 23 beta2Def_ = 0.0; 24 momentumDef_ = 0.0; 25 } 26 27 void elementBend::setDefaults() 28 { 29 specificName_ = defaultSpecificName_; 30 angleDeg_ = angleDegDef_; 31 radius_ = radiusDef_; 32 beta1_ = beta1Def_; 33 beta2_ = beta2Def_; 34 momentum_ = momentumDef_; 35 } 36 37 string* elementBend::getParametersString() const 38 { 39 int compteur = -1; 40 parametersString_[++compteur] = mixedTools::intToString(nbParam_); 41 parametersString_[++compteur] = specificName_; 42 parametersString_[++compteur] = mixedTools::doubleToString( angleDeg_); 43 parametersString_[++compteur] = mixedTools::doubleToString(radius_); 44 parametersString_[++compteur] = mixedTools::doubleToString(momentum_); 45 parametersString_[++compteur] = mixedTools::doubleToString(aperture_); 46 parametersString_[++compteur] = mixedTools::doubleToString(beta1_); 47 parametersString_[++compteur] = mixedTools::doubleToString(beta2_); 48 if ( compteur != nbParam_ ) { 49 cerr << " elementBend::getParametersString() : ERROR nr pf parameters dosnt match " << endl; 50 return NULL; 25 51 } 26 27 void elementBend::setDefaults() 28 { 29 specificName_ = defaultSpecificName_; 30 angleDeg_ = angleDegDef_; 31 radius_ = radiusDef_; 32 beta1_ = beta1Def_; 33 beta2_ = beta2Def_; 34 momentum_ = momentumDef_; 52 return parametersString_; 53 } 54 55 double elementBend::getLenghtOfElement() const 56 { 57 return 1.0e2 * radius_ * angleDeg_ * DEG_TO_RADIANS; 58 } 59 60 61 void elementBend::setParametersString(string* param) 62 { 63 if ( param == NULL ) { 64 cerr << " elementBend::setParametersString parameters empty parameter set"; 65 return; 35 66 } 36 37 string* elementBend::getParametersString() const 38 { 39 int compteur = -1; 40 parametersString_[++compteur] = mixedTools::intToString(nbParam_); 41 parametersString_[++compteur] = specificName_; 42 parametersString_[++compteur] = mixedTools::doubleToString( angleDeg_); 43 parametersString_[++compteur] = mixedTools::doubleToString(radius_); 44 parametersString_[++compteur] = mixedTools::doubleToString(momentum_); 45 parametersString_[++compteur] = mixedTools::doubleToString(aperture_); 46 parametersString_[++compteur] = mixedTools::doubleToString(beta1_); 47 parametersString_[++compteur] = mixedTools::doubleToString(beta2_); 48 if ( compteur != nbParam_ ) { 49 cerr << " elementBend::getParametersString() : ERROR nr pf parameters dosnt match " << endl; 50 return NULL; 51 } 52 return parametersString_; 53 } 54 55 double elementBend::getLenghtOfElement() const 56 { 57 return 1.0e2 * radius_ * angleDeg_ * DEG_TO_RADIANS; 58 } 59 60 61 void elementBend::setParametersString(string* param) 62 { 63 if ( param == NULL ) 64 { 65 cerr << " elementBend::setParametersString parameters empty parameter set"; 66 return; 67 } 68 69 int compteur = -1; 70 int nbparam = atoi(param[++compteur].c_str()); 71 if ( nbparam != nbParam_ ) 72 { 73 cerr << " elementBend::setParametersString parameters do not match for a BEND" << endl; 74 return; 75 } 76 specificName_ = param[++compteur]; 77 angleDeg_ = atof(param[++compteur].c_str()); 78 radius_ = atof(param[++compteur].c_str()); 79 momentum_ = atof(param[++compteur].c_str()); 80 aperture_ = atof(param[++compteur].c_str()); 81 beta1_ = atof(param[++compteur].c_str()); 82 beta2_ = atof(param[++compteur].c_str()); 83 // calcul de la longueur : rayon en m ; longueur en cm 84 lenghtElem_ = getLenghtOfElement(); 85 cout << " elementBend::setParametersString calcule longueur = " << lenghtElem_ << endl; 86 } 67 68 int compteur = -1; 69 int nbparam = atoi(param[++compteur].c_str()); 70 if ( nbparam != nbParam_ ) { 71 cerr << " elementBend::setParametersString parameters do not match for a BEND" << endl; 72 return; 73 } 74 specificName_ = param[++compteur]; 75 angleDeg_ = atof(param[++compteur].c_str()); 76 radius_ = atof(param[++compteur].c_str()); 77 momentum_ = atof(param[++compteur].c_str()); 78 aperture_ = atof(param[++compteur].c_str()); 79 beta1_ = atof(param[++compteur].c_str()); 80 beta2_ = atof(param[++compteur].c_str()); 81 // calcul de la longueur : rayon en m ; longueur en cm 82 lenghtElem_ = getLenghtOfElement(); 83 cout << " elementBend::setParametersString calcule longueur = " << lenghtElem_ << endl; 84 } 87 85 88 86 // string elementBend::parmelaOutputFlow() const … … 109 107 110 108 string elementBend::FileOutputFlow() const 111 { 112 ostringstream sortie; 113 // sortie << elementName_.getElementType() << endl; 114 sortie << elementName_.getGenericLabel() << endl; 115 sortie << specificName_ << endl; 116 sortie << angleDeg_ << " " << radius_ << " " << aperture_ << endl; 117 sortie << beta1_ << " " << beta2_ << " " << momentum_ << endl; 118 return sortie.str(); 119 } 120 121 vector< pair<string, vector<string> > > elementBend::parametersToSoftware () const{ 109 { 110 ostringstream sortie; 111 // sortie << elementName_.getElementType() << endl; 112 sortie << elementName_.getGenericLabel() << endl; 113 sortie << specificName_ << endl; 114 sortie << angleDeg_ << " " << radius_ << " " << aperture_ << endl; 115 sortie << beta1_ << " " << beta2_ << " " << momentum_ << endl; 116 return sortie.str(); 117 } 118 119 vector< pair<string, vector<string> > > elementBend::parametersToSoftware () const 120 { 122 121 vector< pair<string, vector<string> > > sortie; 123 122 sortie.push_back( pair<string, vector<string> >("labelsGenericSpecific", vector<string>() ) ); … … 148 147 } 149 148 150 151 string elementBend::print() { 152 string txt = ""; 153 154 txt += specificName_; 155 txt += "\nangle (deg.) : "; 156 txt += mixedTools::doubleToString(angleDeg_); 157 txt += "\nradius (m) : "; 158 txt += mixedTools::doubleToString(radius_); 159 txt += "\nmomentum (MeV/c) : "; 160 txt += mixedTools::doubleToString(momentum_); 161 txt += "\nlength (cm) : "; 162 txt += mixedTools::doubleToString(lenghtElem_); 163 txt += "\naperture (cm) : "; 164 txt += mixedTools::doubleToString(aperture_); 165 txt += "\npole face rotations (deg.) entrance : "; 166 txt += mixedTools::doubleToString(beta1_); 167 txt += "\nexit : "; 168 txt += mixedTools::doubleToString(beta2_); 169 170 return txt; 171 } 149 string elementBend::print() 150 { 151 string txt = ""; 152 txt += specificName_; 153 txt += "\nangle (deg.) : "; 154 txt += mixedTools::doubleToString(angleDeg_); 155 txt += "\nradius (m) : "; 156 txt += mixedTools::doubleToString(radius_); 157 txt += "\nmomentum (MeV/c) : "; 158 txt += mixedTools::doubleToString(momentum_); 159 txt += "\nlength (cm) : "; 160 txt += mixedTools::doubleToString(lenghtElem_); 161 txt += "\naperture (cm) : "; 162 txt += mixedTools::doubleToString(aperture_); 163 txt += "\npole face rotations (deg.) entrance : "; 164 txt += mixedTools::doubleToString(beta1_); 165 txt += "\nexit : "; 166 txt += mixedTools::doubleToString(beta2_); 167 return txt; 168 } 169 170 void elementBend::InputRep(UAPNode* root) 171 { 172 UAPNode* ele = root->addChild("element"); 173 ele->addAttribute("name",specificName_); 174 175 string txt = ""; 176 txt = mixedTools::doubleToString(lenghtElem_); 177 ele->addChild("length")->addAttribute("design",txt); 178 179 // pour Parmela /aper : radius of aperture at exit (gap) 180 UAPNode* node = ele->addChild("aperture"); 181 node->addAttribute("at","EXIT"); 182 node->addAttribute("shape","CIRCLE"); 183 txt = mixedTools::doubleToString(aperture_); 184 node->addChild("xy_limit")->addAttribute("design",txt); 185 186 // ??? encore pour Parmela /wt : ref energy 187 txt = mixedTools::doubleToString(momentum_); 188 ele->addChild("momentum")->addAttribute("design",txt); 189 190 node = ele->addChild("bend"); 191 192 // bending field g= 1/r = angle/length : on en déduit angle= g*length 193 double g = 1.0/radius_; 194 txt = mixedTools::doubleToString(g); 195 node->addChild("g")->addAttribute("design",txt); 196 197 txt = mixedTools::doubleToString(beta1_); 198 node->addChild("e1")->addAttribute("design",txt); 199 txt = mixedTools::doubleToString(beta2_); 200 node->addChild("e2")->addAttribute("design",txt); 201 }
Note: See TracChangeset
for help on using the changeset viewer.