[82] | 1 | #include "elementSoleno.h" |
---|
| 2 | #include "mixedTools.h" |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | elementSoleno::elementSoleno() : abstractElement() |
---|
| 6 | { |
---|
[359] | 7 | cout << " passage constructeur elementSoleno " << endl; |
---|
| 8 | setDefaultValues(); |
---|
| 9 | setDefaults(); |
---|
| 10 | elementName_ = nomdElements("soleno"); |
---|
| 11 | nbParam_ = elementName_.getElementNbParameters(); |
---|
| 12 | parametersString_ = new string[nbParam_+1]; |
---|
| 13 | registerAcceptableSoftware(nomDeLogiciel::transport, TBoolOk); |
---|
| 14 | registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolOk); |
---|
[82] | 15 | } |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | void elementSoleno::setDefaultValues() |
---|
| 19 | { |
---|
[288] | 20 | defaultLabel_ = "solnd"; |
---|
[83] | 21 | B0Def_ = 0.0; |
---|
[229] | 22 | varyB0Def_ = false; |
---|
[82] | 23 | } |
---|
| 24 | |
---|
| 25 | void elementSoleno::setDefaults() |
---|
| 26 | { |
---|
[271] | 27 | label_ = defaultLabel_; |
---|
[82] | 28 | B0_ = B0Def_; |
---|
[229] | 29 | varyB0_ = varyB0Def_; |
---|
[82] | 30 | } |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | string* elementSoleno::getParametersString() const |
---|
| 34 | { |
---|
[83] | 35 | cout << " passage elementSoleno::getParametersString() B0_= " << B0_ << endl; |
---|
[225] | 36 | int compteur = -1; |
---|
| 37 | parametersString_[++compteur] = mixedTools::intToString(nbParam_); |
---|
| 38 | parametersString_[++compteur] = label_; |
---|
| 39 | parametersString_[++compteur] = mixedTools::doubleToString(lenghtElem_); |
---|
| 40 | parametersString_[++compteur] = mixedTools::doubleToString(aperture_); |
---|
| 41 | parametersString_[++compteur] = mixedTools::doubleToString(B0_); |
---|
[229] | 42 | parametersString_[++compteur] = mixedTools::intToString(varyB0_); |
---|
[225] | 43 | if ( compteur != nbParam_ ) { |
---|
| 44 | cerr << " elementSoleno::getParametersString() : ERROR nr pf parameters dosnt match " << endl; |
---|
| 45 | return NULL; |
---|
| 46 | } |
---|
[82] | 47 | return parametersString_; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | void elementSoleno::setParametersString(string* param) |
---|
| 52 | { |
---|
| 53 | if ( param == NULL ) |
---|
| 54 | { |
---|
| 55 | cerr << " elementSoleno::setParametersString parameters empty parameter set"; |
---|
| 56 | return; |
---|
| 57 | } |
---|
[225] | 58 | int compteur = -1; |
---|
| 59 | int nbparam = atoi(param[++compteur].c_str()); |
---|
[82] | 60 | if ( nbparam != nbParam_ ) |
---|
| 61 | { |
---|
| 62 | cerr << " elementSoleno::setParametersString parameters do not match for a SOLENOID"; |
---|
| 63 | return; |
---|
| 64 | } |
---|
[225] | 65 | label_ = param[++compteur]; |
---|
| 66 | lenghtElem_ = atof(param[++compteur].c_str()); |
---|
| 67 | aperture_ = atof(param[++compteur].c_str()); |
---|
| 68 | B0_ = atof(param[++compteur].c_str()); |
---|
[229] | 69 | varyB0_ = atoi(param[++compteur].c_str()); |
---|
[82] | 70 | } |
---|
| 71 | |
---|
| 72 | string elementSoleno::parmelaOutputFlow() const |
---|
| 73 | { |
---|
| 74 | ostringstream sortie; |
---|
[189] | 75 | // on passe l'induction magnetique en Gauss |
---|
[387] | 76 | sortie << "SOLENOID /l=" << lenghtElem_ << " /aper=" << aperture_ << " /iout=1 /h=" << 1000.*B0_ << endl; |
---|
[82] | 77 | return sortie.str(); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | string elementSoleno::transportOutputFlow() const |
---|
| 81 | { |
---|
| 82 | ostringstream sortie; |
---|
[138] | 83 | // on passe la longueur en metres |
---|
[229] | 84 | sortie << label_ << ":" << " SOLENOID, L=" << 0.01*lenghtElem_ << ", B=" << B0_ << ";" << endl; |
---|
| 85 | if ( varyB0_ ) { |
---|
[387] | 86 | sortie << " VARY, " << label_+"[B]" << ";" << endl; |
---|
[229] | 87 | } |
---|
[82] | 88 | return sortie.str(); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | string elementSoleno::FileOutputFlow() const |
---|
| 92 | { |
---|
| 93 | ostringstream sortie; |
---|
[181] | 94 | // sortie << elementName_.getElementType() << endl; |
---|
| 95 | sortie << elementName_.getElementLabel() << endl; |
---|
[118] | 96 | sortie << label_ << endl; |
---|
[229] | 97 | sortie << lenghtElem_ << " " << aperture_<< " " << B0_ << " " << varyB0_ << endl; |
---|
[82] | 98 | return sortie.str(); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | void elementSoleno::FileInput(ifstream& ifs) |
---|
| 102 | { |
---|
[118] | 103 | ifs >> label_; |
---|
[229] | 104 | ifs >> lenghtElem_ >> aperture_ >> B0_ >> varyB0_ ; |
---|
[82] | 105 | } |
---|
[287] | 106 | |
---|
| 107 | |
---|
| 108 | string elementSoleno::print() { |
---|
| 109 | string txt = ""; |
---|
| 110 | |
---|
| 111 | txt += label_; |
---|
| 112 | txt += "\nlength (cm) : "; |
---|
| 113 | txt += mixedTools::doubleToString(lenghtElem_); |
---|
| 114 | txt += "\naperture (cm) : "; |
---|
| 115 | txt += mixedTools::doubleToString(aperture_); |
---|
| 116 | txt += "\nfield (kG) : "; |
---|
| 117 | txt += mixedTools::doubleToString(B0_); |
---|
| 118 | txt += "\n : may vary ? "; |
---|
| 119 | txt += mixedTools::boolToString(varyB0_); |
---|
| 120 | |
---|
| 121 | return txt; |
---|
| 122 | } |
---|