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)
string key= v.at(1).second.at(1);
string WEN= "1000";
if( key.find("none") == std::string::npos ) {
double energy = 1000.*atof( key.c_str() ); // MeV
WEN = mixedTools::doubleToString(energy);
if (key.find("none") == std::string::npos) {
double EMev= atof(key.c_str()); // MeV
WEN= mixedTools::doubleToString(EMev);
bunch_[ "energy" ].push_back( WEN );
} else {
bunch_[ "energy" ].push_back( "none" );
}
key= v.at(1).second.at(2);
if( key.find("none") == std::string::npos ) {
double pc = 1000.*atof( key.c_str() ); // MeV
if (key.find("none") == std::string::npos ) {
double pc= atof( key.c_str() ); // MeV
bunch_[ "pc" ].push_back( mixedTools::doubleToString(pc) );
} else {
bunch_[ "pc" ].push_back( WEN );
}
bunch_[ "emit_x" ].push_back( v.at(1).second.at(3) ); // m.rad
......@@ -194,8 +202,9 @@ void softwareElegant::beamData(particleBeam *beam)
if(debug > 0) cout << "softwareElegant::beamData( 2 )\n";
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 ) );
double epsx= beam->emit_x();
bunch_[ "emit_x" ].push_back( mixedTools::doubleToString( epsx ) );
double epsy= beam->emit_y();
......@@ -210,11 +219,14 @@ void softwareElegant::beamData(particleBeam *beam)
double betax= rij.at(0).at(0)*rij.at(0).at(0)/epsx;
double r10= rij.at(1).at(0);
double alfax= -r10/sqrt( 1.0-r10*r10 );
bunch_[ "beta_x" ].push_back( mixedTools::doubleToString( betax ) );
bunch_[ "alfa_x" ].push_back( mixedTools::doubleToString( alfax ) );
double betay= rij.at(2).at(2)*rij.at(2).at(2)/epsy;
double r32= rij.at(3).at(2);
double alfay= -r32/sqrt( 1.0-r32*r32 );
bunch_[ "beta_y" ].push_back( mixedTools::doubleToString( betay ) );
bunch_[ "alfa_y" ].push_back( mixedTools::doubleToString( alfay ) );
}
......@@ -545,61 +557,103 @@ string softwareElegant::elementsData(const vector<psvs>& v)
vary_[ label ].push_back( keyword );
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());
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());
os << label << ":" << " QUAD, L= " << ln;
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());
os << label << ":" << " SEXT, L=" << ln;
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 knL= atof(v.at(1).second.at(1).c_str());
os << label << ":" << " mult, knl=" << knL << ", order= " << order << "\n";
double len= atof(v.at(1).second.at(0).c_str()); // m
os << label << ":" << " SBEN, L=" << len;
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());
}
} else if(keyword == "bend") {
str= v.at(1).second.at(4); // e2
if (str.find("none") == std::string::npos) {
os << ", E2= " << atof(str.c_str());
}
double ln= atof(v.at(1).second.at(0).c_str()); // m
double angleRad = atof(v.at(2).second.at(0).c_str()); // rad
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;
// 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());
}
} else if(keyword == "rf_cavity") {
// 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 == "rf_cavity") {
double ln= atof(v.at(1).second.at(0).c_str()); // m
os << label << ":" << " RFCA, L= " << ln;
double volt= atof(v.at(1).second.at(1).c_str()); // MV
volt *= 1.e+06; // V
os << ", VOLT= " << volt;
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)
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
} else {
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
}
os << ", FREQ= " << freq << ";\n";
os << label << ":" << " rfca, l=" << ln << ", volt=" << volt << ", phase=" << phase << ", freq=" << freq << ";\n";
// ??? } else if (keyword == "kicker") {
} else {
......
......@@ -173,7 +173,6 @@ void elementBend::InputRep(UAPNode *root)
void elementBend::FileAMLInput(UAPNode *up)
{
if(debug > 0) cout << "elementBend::FileAMLInput()\n";
cout << "elementBend::FileAMLInput()\n";
if (!checkAMLelementGenericName(up)) return;
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