Commit 1f80c8de authored by TOUZE Francois's avatar TOUZE Francois
Browse files

fix matching statements

parent f7cfae77
This diff is collapsed.
......@@ -610,9 +610,7 @@ bool dataManager::parseJSONFile( string fileName )
cout << "dataManager::parseJSONFile => nameOfCase " << nameOfCase_ << " with " << s << endl;
nameOfCase_= s;
}
if ( !machineCourante_ ) machineCourante_= new machine( this );
auto jt= j.find( "simulations" );
json exp;
......
......@@ -404,37 +404,32 @@ void softwareMadx::output2(string& s1,string& s2)
string softwareMadx::matchStatement(const std::vector<smap>& v,string seqname)
{
if(debug > 0) cout << "softwareMadx::matchStatement()\n";
ostringstream os;
// initialize insertion matching
if( !v[ 5 ].empty() ) { // transfert matrix
os << "match, rmatrix, sequence = " + seqname;
os << "match, rmatrix, sequence= " + seqname;
} else {
os << "match, sequence = " + seqname;
os << "match, sequence= " + seqname;
}
// initial values for the optic functions
ostringstream osx;
string tx;
if( !v[ 1 ].empty() ) { // option 2
tx= v[ 1 ].find("beta_x")->second.at(0);
if( tx.find("none") == string::npos )
osx << ", betx = " << tx;
tx= v[ 1 ].find("beta_y")->second.at(0);
if( tx.find("none") == string::npos )
osx << ", bety = " << tx;
tx= v[ 1 ].find("alpha_x")->second.at(0);
if( tx.find("none") == string::npos )
osx << ", alfx = " << tx;
tx= v[ 1 ].find("alpha_y")->second.at(0);
if( tx.find("none") == string::npos )
osx << ", alfy = " << tx;
tx= v[ 1 ].find("dx")->second.at(0);
if( tx.find("none") == string::npos )
osx << ", dx = " << tx;
tx= v[ 1 ].find("dpx")->second.at(0);
if( tx.find("none") == string::npos )
osx << ", dpx = " << tx;
smap::const_iterator kt= v[1].find("beta_x");
if (kt != v[1].end()) osx << ", betx= " << kt->second.at(0);
kt= v[1].find("alpha_x");
if (kt != v[1].end()) osx << ", alfx= " << kt->second.at(0);
kt= v[1].find("dx");
if (kt != v[1].end()) osx << ", dx= " << kt->second.at(0);
kt= v[1].find("beta_y");
if (kt != v[1].end()) osx << ", bety= " << kt->second.at(0);
kt= v[1].find("alpha_y");
if (kt != v[1].end()) osx << ", alfy= " << kt->second.at(0);
kt= v[1].find("dpx");
if (kt != v[1].end()) osx << ", dpx= " << kt->second.at(0);
} else { // option 1
if(debug > 0) {
......@@ -462,10 +457,11 @@ string softwareMadx::matchStatement(const std::vector<smap>& v,string seqname)
smap::const_iterator it;
it= v[ 2 ].find( mixedTools::intToString(k) );
if( it == v[ 2 ].end() ) continue;
os << "constraint, sequence = " + seqname;
os << "constraint, sequence= " + seqname;
string range= it->second.at(0);
if( range.find("End") != string::npos ) {
os << ", range = #e";
os << ", range= #e";
} else if( range.find("FromTo") != string::npos ) {
unsigned int fIndex;
fIndex= getComputingBlock()->getRankOfFirstElement();
......@@ -473,11 +469,11 @@ string softwareMadx::matchStatement(const std::vector<smap>& v,string seqname)
lIndex= getComputingBlock()->getRankOfLastElement();
string s1= mixedTools::intToString( fIndex );
string s2= mixedTools::intToString( lIndex );
os << ", range = " << "#"+s1+"/"+"#"+s2;
os << ", range= " << "#"+s1+"/"+"#"+s2;
} else {
os << ", range = " << range;
os << ", range= " << range;
}
string key= nameOpticalFunction(it->second.at(1));
string key= nameOpticalFunction( it->second.at(1) );
if( !key.empty() ) {
tx = it->second.at(2);
if( tx.find("none") == string::npos )
......@@ -492,7 +488,8 @@ string softwareMadx::matchStatement(const std::vector<smap>& v,string seqname)
smap::const_iterator it;
it= v[ 3 ].find( mixedTools::intToString(k) );
if( it == v[ 3 ].end() ) continue;
os << "global, sequence = " + seqname;
os << "global, sequence= " + seqname;
string key= it->second.at(1);
if( !key.empty() ) {
tx = it->second.at(2);
......@@ -508,6 +505,7 @@ string softwareMadx::matchStatement(const std::vector<smap>& v,string seqname)
smap::const_iterator it;
it= v[ 5 ].find( mixedTools::intToString(k) );
if( it == v[ 5 ].end() ) continue;
os << "constraint, sequence= " + seqname;
os << ", range= " << it->second.at(0);
string str= it->second.at(1);
......@@ -539,8 +537,8 @@ string softwareMadx::matchStatement(const std::vector<smap>& v,string seqname)
// method
os << v[ 6 ].find("method")->second.at(0);
os << ", calls = " << v[ 6 ].find("evaluations")->second.at(0);
os << ", tolerance = " << v[ 6 ].find("tolerance")->second.at(0);
os << ", calls= " << v[ 6 ].find("evaluations")->second.at(0);
os << ", tolerance= " << v[ 6 ].find("tolerance")->second.at(0);
os << ";" << endl;
// end of matching
......@@ -557,7 +555,7 @@ string softwareMadx::matchStatement(const std::vector<smap>& v,string seqname)
// creates a Twiss table
os << "\n";
os << "select, flag=twiss, column= name,s,betx,alfx,dx,bety,alfy;\n";
os << "select, flag= twiss, column= name,s,betx,alfx,dx,bety,alfy;\n";
// creates the TWISS table => xxx-twiss.txt
os << "twiss, save, file= " + getFileName("twiss",true);
......@@ -988,9 +986,9 @@ void softwareMadx::FinalValues()
string* parm= ptr->getParametersString();
string eType= ptr->getGenericName();
if( eType == "quad" ) parm[ 3 ]= vFinal;
if( eType == "sext" ) parm[ 3 ]= vFinal;
if( eType == "mpole") parm[ 3 ]= vFinal;
if( eType == "qpole" ) parm[ 3 ]= vFinal;
if( eType == "spole" ) parm[ 3 ]= vFinal;
if( eType == "mpole") parm[ 3 ]= vFinal;
if( eType == "soleno" ) {
double brho= 3.3356*eGev; // BEAM RIGIDITY in T*M
double ksfit= atof(vFinal.c_str()); // SOLENOID STRENGTH
......@@ -998,7 +996,7 @@ void softwareMadx::FinalValues()
parm[ 4 ]= mixedTools::doubleToString( bfit ); // bfield
}
ptr->setParametersString(parm);
ptr->setParametersString( parm );
}
}
} while ( buf.find( enddo ) == string::npos );
......
......@@ -329,7 +329,8 @@ string elementBeam::print()
void elementBeam::toJSON(json& j)
{
j["id"] = "beam-" + mixedTools::alea();
idElement_= "beam-" + mixedTools::alea();
j["id"] = idElement_;
j["displayName"] = getLabel();
j["category"] = "element";
j["type"]= genericName_;
......
......@@ -293,7 +293,8 @@ void elementBend::AMLRepToPSPA(string key,UAPNode* knode)
void elementBend::toJSON(json& j)
{
j["id"] = "bend-" + mixedTools::alea();
idElement_= "bend-" + mixedTools::alea();
j["id"] = idElement_;
j["displayName"] = getLabel();
j["category"] = "element";
j["type"]= genericName_;
......
......@@ -206,9 +206,8 @@ void elementCathode::AMLRepToPSPA(string key,UAPNode* node)
void elementCathode::toJSON(json& j)
{
//cout << "elementCathode::toJSON()\n";
j["id"] = "cathode-" + mixedTools::alea();
idElement_= "cathode-" + mixedTools::alea();
j["id"] = idElement_;
j["type"]= genericName_;
j["displayName"] = getLabel();
......
......@@ -141,7 +141,8 @@ void elementDrift::AMLRepToPSPA(string key,UAPNode* knode)
void elementDrift::toJSON(json& j)
{
j["id"] = "drift-" + mixedTools::alea();
idElement_= "drift-" + mixedTools::alea();
j["id"] = idElement_;
j["displayName"] = getLabel();
j["category"] = "element";
j["type"]= genericName_;
......
......@@ -131,7 +131,8 @@ void elementKicker::AMLRepToPSPA(string key,UAPNode* node)
void elementKicker::toJSON(json& j)
{
j["id"] = "kicker-" + mixedTools::alea();
idElement_= "kicker-" + mixedTools::alea();
j["id"] = idElement_;
j["displayName"] = getLabel();
j["category"] = "element";
j["type"]= genericName_;
......
......@@ -238,9 +238,8 @@ void elementLinac::AMLRepToPSPA(string key,UAPNode* node)
void elementLinac::toJSON(json& j)
{
//cout << "elementLinac::toJSON()\n";
j["id"] = "linac-" + mixedTools::alea();
idElement_= "linac-" + mixedTools::alea();
j["id"] = idElement_;
j["type"]= "linaccav";
j["displayName"] = getLabel();
......
......@@ -100,7 +100,8 @@ void elementMarker::AMLRepToPSPA(string key,UAPNode* knode)
void elementMarker::toJSON(json& j)
{
j["id"] = "Marker-" + mixedTools::alea();
idElement_= "marker-" + mixedTools::alea();
j["id"] = idElement_;
j["displayName"] = getLabel();
j["category"] = "element";
j["type"]= genericName_;
......
......@@ -146,7 +146,8 @@ void elementMpole::AMLRepToPSPA(string key,UAPNode* nde)
void elementMpole::toJSON(json& j)
{
j["id"] = "mpole-" + mixedTools::alea();
idElement_= "mpole-" + mixedTools::alea();
j["id"] = idElement_;
j["displayName"] = getLabel();
j["category"] = "element";
j["type"]= genericName_;
......
......@@ -144,7 +144,8 @@ void elementOpole::AMLRepToPSPA(string key,UAPNode* knode)
void elementOpole::toJSON(json& j)
{
j["id"] = "opole-" + mixedTools::alea();
idElement_= "opole-" + mixedTools::alea();
j["id"] = idElement_;
j["type"]= "oct";
j["displayName"] = getLabel();
......
......@@ -140,7 +140,8 @@ void elementQpole::AMLRepToPSPA(string key,UAPNode* knode)
void elementQpole::toJSON(json& j)
{
j["id"] = "quad-" + mixedTools::alea();
idElement_= "quad-" + mixedTools::alea();
j["id"] = idElement_;
j["type"]= "quad";
j["displayName"] = getLabel();
......
......@@ -188,9 +188,8 @@ void elementRfCavity::AMLRepToPSPA(string key,UAPNode* nde)
void elementRfCavity::toJSON(json& j)
{
// cout << "elementRfCavity::toJSON()\n";
j["id"] = "rfcavity-" + mixedTools::alea();
idElement_= "rfcavity-" + mixedTools::alea();
j["id"] = idElement_;
j["type"]= "rfcav";
j["displayName"] = getLabel();
......
......@@ -142,7 +142,8 @@ void elementSolenoid::AMLRepToPSPA(string key,UAPNode *knode)
void elementSolenoid::toJSON(json& j)
{
j["id"] = "solenoid-" + mixedTools::alea();
idElement_= "solenoid-" + mixedTools::alea();
j["id"] = idElement_;
j["displayName"] = getLabel();
j["category"] = "element";
j["type"]= genericName_;
......
......@@ -144,7 +144,8 @@ void elementSpole::AMLRepToPSPA(string key,UAPNode* knode)
void elementSpole::toJSON(json& j)
{
j["id"] = "sext-" + mixedTools::alea();
idElement_= "sext-" + mixedTools::alea();
j["id"] = idElement_;
j["type"]= "sext";
j["displayName"] = getLabel();
......
......@@ -206,7 +206,9 @@ int main (int argc, char* argv[])
string answer;
cout << "print json? (yes/no)" << endl;
cin >> answer;
if( answer == "yes" ) cout << j.dump(4) << endl;
if( answer == "yes" ) {
cout << j.dump(4) << endl;
}
cout << "run? (yes/no)" << endl;
cin >> answer;
......
......@@ -73,7 +73,7 @@
<tr v-for="(simpleConstraint, index) in actionParameters.simpleConstraints" v-bind:key="index">
<td class="td-number">{{ index + 1 }}</td>
<td><input v-model="simpleConstraint.range" type="number" /></td>
<td><input v-model="simpleConstraint.range" type="string" /></td>
<td>
<select v-model="simpleConstraint.constraintVariable">
<option v-for="element in simpleConstraintVariablesSelect" v-bind:key="element.value" v-bind:value="element.value">
......
......@@ -4,4 +4,4 @@ export const TRACK = 'track';
export const TUNES = 'tunes';
export const MATCHING = 'matching';
export const LIST_ACTIONS = [EMITT, TWISS, TRACK, TUNES, MATCHING];
\ No newline at end of file
export const LIST_ACTIONS = [EMITT, TWISS, TRACK, TUNES, MATCHING];
......@@ -5,6 +5,9 @@ import { startSimulationUrl, getSimulationResultUrl } from '@/utils/constants/si
import { SimulationResult } from '@/utils/models/simulation-result.js';
export const startAllSimulations = (state) => {
console.log('=> startAllSimulations')
var d = new Date();
var dformat = [d.getMonth()+1,
d.getDate(),
......
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