Commit a93f3eb3 authored by TOUZE Francois's avatar TOUZE Francois
Browse files

modified SBEND implementation in ELEGANT

parent c170d2ba
...@@ -145,20 +145,28 @@ void softwareElegant::fromParameters(const vector<psvs>& v) ...@@ -145,20 +145,28 @@ void softwareElegant::fromParameters(const vector<psvs>& v)
string key= v.at(1).second.at(1); string key= v.at(1).second.at(1);
string WEN= "1000"; string WEN= "1000";
if( key.find("none") == std::string::npos ) { if (key.find("none") == std::string::npos) {
double energy = 1000.*atof( key.c_str() ); // MeV
WEN = mixedTools::doubleToString(energy); double EMev= atof(key.c_str()); // MeV
WEN= mixedTools::doubleToString(EMev);
bunch_[ "energy" ].push_back( WEN ); bunch_[ "energy" ].push_back( WEN );
} else { } else {
bunch_[ "energy" ].push_back( "none" ); bunch_[ "energy" ].push_back( "none" );
} }
key= v.at(1).second.at(2); key= v.at(1).second.at(2);
if( key.find("none") == std::string::npos ) { if (key.find("none") == std::string::npos ) {
double pc = 1000.*atof( key.c_str() ); // MeV
double pc= atof( key.c_str() ); // MeV
bunch_[ "pc" ].push_back( mixedTools::doubleToString(pc) ); bunch_[ "pc" ].push_back( mixedTools::doubleToString(pc) );
} else { } else {
bunch_[ "pc" ].push_back( WEN ); bunch_[ "pc" ].push_back( WEN );
} }
bunch_[ "emit_x" ].push_back( v.at(1).second.at(3) ); // m.rad bunch_[ "emit_x" ].push_back( v.at(1).second.at(3) ); // m.rad
...@@ -194,27 +202,31 @@ void softwareElegant::beamData(particleBeam *beam) ...@@ -194,27 +202,31 @@ void softwareElegant::beamData(particleBeam *beam)
if(debug > 0) cout << "softwareElegant::beamData( 2 )\n"; if(debug > 0) cout << "softwareElegant::beamData( 2 )\n";
bunch_[ "energy" ].push_back( "none" ); bunch_[ "energy" ].push_back( "none" );
double pc = 1000*beam->getP0Transport(); // en MeV double pc= 1000*beam->getP0Transport(); // en MeV
bunch_[ "pc" ].push_back( mixedTools::doubleToString( pc ) ); bunch_[ "pc" ].push_back( mixedTools::doubleToString( pc ) );
double epsx= beam->emit_x(); double epsx= beam->emit_x();
bunch_[ "emit_x" ].push_back( mixedTools::doubleToString( epsx ) ); bunch_[ "emit_x" ].push_back( mixedTools::doubleToString( epsx ) );
double epsy= beam->emit_y(); double epsy= beam->emit_y();
bunch_[ "emit_y" ].push_back( mixedTools::doubleToString( epsy ) ); bunch_[ "emit_y" ].push_back( mixedTools::doubleToString( epsy ) );
bunch_[ "emit_z" ].push_back( "none" ); bunch_[ "emit_z" ].push_back( "none" );
bunch_[ "sig_s" ].push_back( "none" ); bunch_[ "sig_s" ].push_back( "none" );
bunch_[ "sig_e" ].push_back( "none" ); bunch_[ "sig_e" ].push_back( "none" );
const beam2Moments& mts= beam->getTransportMoments(); const beam2Moments& mts= beam->getTransportMoments();
const vector< vector<double> >& rij= mts.getMoments(); const vector< vector<double> >& rij= mts.getMoments();
double betax= rij.at(0).at(0)*rij.at(0).at(0)/epsx; double betax= rij.at(0).at(0)*rij.at(0).at(0)/epsx;
double r10= rij.at(1).at(0); double r10= rij.at(1).at(0);
double alfax= -r10/sqrt( 1.0-r10*r10 ); double alfax= -r10/sqrt( 1.0-r10*r10 );
bunch_[ "beta_x" ].push_back( mixedTools::doubleToString( betax ) ); bunch_[ "beta_x" ].push_back( mixedTools::doubleToString( betax ) );
bunch_[ "alfa_x" ].push_back( mixedTools::doubleToString( alfax ) ); bunch_[ "alfa_x" ].push_back( mixedTools::doubleToString( alfax ) );
double betay= rij.at(2).at(2)*rij.at(2).at(2)/epsy; double betay= rij.at(2).at(2)*rij.at(2).at(2)/epsy;
double r32= rij.at(3).at(2); double r32= rij.at(3).at(2);
double alfay= -r32/sqrt( 1.0-r32*r32 ); double alfay= -r32/sqrt( 1.0-r32*r32 );
bunch_[ "beta_y" ].push_back( mixedTools::doubleToString( betay ) ); bunch_[ "beta_y" ].push_back( mixedTools::doubleToString( betay ) );
bunch_[ "alfa_y" ].push_back( mixedTools::doubleToString( alfay ) ); bunch_[ "alfa_y" ].push_back( mixedTools::doubleToString( alfay ) );
} }
...@@ -545,61 +557,103 @@ string softwareElegant::elementsData(const vector<psvs>& v) ...@@ -545,61 +557,103 @@ string softwareElegant::elementsData(const vector<psvs>& v)
vary_[ label ].push_back( keyword ); vary_[ label ].push_back( keyword );
ostringstream os; ostringstream os;
if(keyword == "marker") { if (keyword == "marker") {
os << label << ": marker\n"; os << label << ": MARK\n";
} else if(keyword == "drift") { } else if (keyword == "drift") {
double length= atof(v.at(1).second.at(0).c_str()); double length= atof(v.at(1).second.at(0).c_str());
os << label << ":" << " drift, l=" << length << endl; os << label << ":" << " DRIF, L= " << length << endl;
} else if (keyword == "mpole") {
double knL= atof(v.at(1).second.at(1).c_str());
os << label << ":" << " MULT, KNL= " << knL;
int order= atoi(v.at(1).second.at(0).c_str());
os << ", ORDER= " << order << "\n";
} else if(keyword == "qpole") { } else if (keyword == "qpole") {
double ln= atof(v.at(1).second.at(0).c_str()); double ln= atof(v.at(1).second.at(0).c_str());
os << label << ":" << " QUAD, L= " << ln;
double k1= atof(v.at(1).second.at(1).c_str()); double k1= atof(v.at(1).second.at(1).c_str());
os << label << ":" << " quadrupole, l=" << ln << ", k1= " << k1 << "\n"; os << ", K1= " << k1 << "\n";
} else if(keyword == "spole") { } else if (keyword == "spole") {
double ln= atof(v.at(1).second.at(0).c_str()); double ln= atof(v.at(1).second.at(0).c_str());
os << label << ":" << " SEXT, L=" << ln;
double k2= atof(v.at(1).second.at(1).c_str()); double k2= atof(v.at(1).second.at(1).c_str());
os << label << ":" << " sextupole, l=" << ln << ", k2= " << k2 << endl; os << ", K2= " << k2 << "\n";
} else if(keyword == "mpole") { } else if (keyword == "bend") {
int order= atoi(v.at(1).second.at(0).c_str()); double len= atof(v.at(1).second.at(0).c_str()); // m
double knL= atof(v.at(1).second.at(1).c_str()); os << label << ":" << " SBEN, L=" << len;
os << label << ":" << " mult, knl=" << knL << ", order= " << order << "\n"; double alfa= atof(v.at(1).second.at(1).c_str()); // rad
os << ", ANGLE= " << alfa;
string str;
str= v.at(1).second.at(3); // e1
if (str.find("none") == std::string::npos) {
os << ", E1= " << atof(str.c_str());
}
str= v.at(1).second.at(4); // e2
if (str.find("none") == std::string::npos) {
os << ", E2= " << atof(str.c_str());
}
// The edge-field integral at entrance and exit of the bend
str= v.at(1).second.at(5); // f_int1 = f_int2
double f_int1= 0.0;
if (str.find("none") == std::string::npos) {
f_int1= atof(str.c_str());
}
// The half-gap between poles
str= v.at(1).second.at(7); // h_gap1
double h_gap1= 0.0;
if (str.find("none") == std::string::npos) {
if (str.find("HGAP") == std::string::npos) {
h_gap1= atof(str.c_str());
} else {
// Prabably fringing field value comes from BETA software => HGAP is mandatory. FINT and HGAP are reseted to the default values
cout << "softwareElegant::elementsData WARNING: HGAP mandatory => The quantities are reseted to the default values\n";
f_int1= 0.5;
}
}
os << ", FINT= " << f_int1;
os << ", HGAP= " << h_gap1;
os <<";\n";
// ????} else if (keyword == "solenoid") {
} else if(keyword == "bend") { } else if (keyword == "rf_cavity") {
double ln= atof(v.at(1).second.at(0).c_str()); // m double ln= atof(v.at(1).second.at(0).c_str()); // m
double angleRad = atof(v.at(2).second.at(0).c_str()); // rad os << label << ":" << " RFCA, L= " << ln;
double beta1Rad = atof(v.at(4).second.at(0).c_str()); // rad
double beta2Rad = atof(v.at(4).second.at(1).c_str()); // rad
double fint = atof(v.at(5).second.at(0).c_str()); // -
double hgap = atof(v.at(5).second.at(1).c_str()); // m
os << label << ":" << " sbend, l=" << ln << ", angle= " << angleRad << ", e1=" << beta1Rad << ", e2=" << beta2Rad << ", fint= " << fint << ", hgap= " << hgap << endl;
} else if(keyword == "rf_cavity") {
double ln= atof(v.at(1).second.at(0).c_str()); // m
double volt= atof(v.at(1).second.at(1).c_str()); // MV double volt= atof(v.at(1).second.at(1).c_str()); // MV
volt *= 1.e+06; // V volt *= 1.e+06; // V
os << ", VOLT= " << volt;
double phase= atof(v.at(1).second.at(2).c_str()); // degrees double phase= atof(v.at(1).second.at(2).c_str()); // degrees
os << ", PHASE= " << phase;
string s= v.at(1).second.at(3); // frequency (MHz) string s= v.at(1).second.at(3); // frequency (MHz)
double freq= 500.e+06; // RF frequency double freq= 500.e+06; // RF frequency
if( s.find("none") == std::string::npos ) { if (s.find("none") == std::string::npos ) {
freq= atof( s.c_str() )*1.e+06; // Hz freq= atof( s.c_str() )*1.e+06; // Hz
} else { } else {
int h= atoi(v.at(1).second.at(4).c_str()); int h= atoi(v.at(1).second.at(4).c_str());
//freq= h*f0 // RF frequency is an integer multiple h of the revolution frequency f0 //freq= h*f0 // RF frequency is an integer multiple h of the revolution frequency f0
} }
os << ", FREQ= " << freq << ";\n";
os << label << ":" << " rfca, l=" << ln << ", volt=" << volt << ", phase=" << phase << ", freq=" << freq << ";\n";
// ??? } else if (keyword == "kicker") {
} else { } else {
......
...@@ -173,7 +173,6 @@ void elementBend::InputRep(UAPNode *root) ...@@ -173,7 +173,6 @@ void elementBend::InputRep(UAPNode *root)
void elementBend::FileAMLInput(UAPNode *up) void elementBend::FileAMLInput(UAPNode *up)
{ {
if(debug > 0) cout << "elementBend::FileAMLInput()\n"; if(debug > 0) cout << "elementBend::FileAMLInput()\n";
cout << "elementBend::FileAMLInput()\n";
if (!checkAMLelementGenericName(up)) return; if (!checkAMLelementGenericName(up)) return;
if( !vtr_.empty() ) vtr_.clear(); if( !vtr_.empty() ) vtr_.clear();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment