Skip to content
Snippets Groups Projects
Commit eb72a3ac authored by nadolski's avatar nadolski
Browse files

LNLS: add number of turns for Mometum acceptance computation

add flag to select the number of sigma to keep in a Gaussian distribution

Momentum aperture: no stop if orbit is unstable
parent c48a3979
No related branches found
No related tags found
No related merge requests found
......@@ -25,16 +25,16 @@ int main(int argc, char *argv[]) {
const long seed = 1121; //the default random seed number
iniranf(seed); //initialize the seed
setrancut(2.0); //default value of the normal cut for the normal distribution
// turn on globval.Cavity_on and globval.radiation to get proper synchr radiation damping
// turn on globval.Cavity_on and globval.radiation to get proper synchro radiation damping
// IDs accounted too if: wiggler model and symplectic integrator (method = 1)
globval.H_exact = false;
/* parameters to read the user input script .prm */
long i=0L; //initilize the for loop to read command string
long i=0L; //initialize the for loop to read command string
char CommandStr[max_str];
double nux = 0, nuy = 0, ksix = 0, ksiy = 0;
bool chroma;
double nux = 0.0, nuy = 0.0, ksix = 0.0, ksiy = 0.0;
bool chroma=true;
double dP = 0.0;
long lastpos = -1L;
char str1[S_SIZE];
......@@ -43,7 +43,8 @@ int main(int argc, char *argv[]) {
long CommandNo = -1L; //the number of commands, since this value is also
// the index of array UserCommandFlag[], so this
// value is always less than 1 in the really case.
UserCommand UserCommandFlag[500];
const int NCOMMAND = 500;
UserCommand UserCommandFlag[NCOMMAND];
/************************************************************************
......@@ -141,9 +142,6 @@ int main(int argc, char *argv[]) {
PrintCh(); // print chamber into chamber.out
}
// read the misalignment errors to the elements, then do COD correction
// using SVD method.
// Based on the function error_and_correction() in nsls-ii_lib_templ.h
......@@ -151,8 +149,8 @@ int main(int argc, char *argv[]) {
// else if(strcmp(ReadaefileFlag, "") != 0){
else if (strcmp(CommandStr,"ReadaefileFlag") == 0) {
// ***** Apply corrections and output flatfile for n_stat sets of random #'s
bool cod;
int k;
bool cod = true;
int k, icod=0;
FILE *hOrbitFile, *vOrbitFile ;
int hcorrIdx[nCOR], vcorrIdx[nCOR]; //list of corr for orbit correction
......@@ -226,17 +224,23 @@ int main(int argc, char *argv[]) {
printf("iter # %3d Orbit correction succeeded\n", k);
}
else
chk_cod(cod, "iter # %3d error_and_correction");
if(!cod){
icod = icod + 1;
fprintf(stdout, "!!! iter # %3d error_and_correction\n",k);
}
//chk_cod(cod, "iter # %3d error_and_correction");
}
// Ring_GetTwiss(chroma, dp);
Ring_GetTwiss(true, 0.0);
// for debugging
//print flat lattice
//sprintf(mfile_name, "flat_file.%03d.dat",k);
//prtmfile(mfile_name);
}
fprintf(stdout, "Number of unstable orbits %d/%d", icod, n_stat);
prt_cod("corr_after.out", globval.bpm, true);
// close file giving orbit at BPM location
......@@ -246,8 +250,8 @@ int main(int argc, char *argv[]) {
}
// set the field error into the lattice
// The coresponding field error is replaced by the new value.
// This feature is generatic, works for all lattice
// The corresponding field error is replaced by the new value.
// This feature is generic, works for all lattices
else if (strcmp(CommandStr,"ReadfefileFlag") == 0) {
fprintf(stdout,"\n Read field error from fe_file: \n");
LoadFieldErrs(UserCommandFlag[i].fe_file, true, 1.0, true, 1);
......@@ -255,7 +259,7 @@ int main(int argc, char *argv[]) {
Ring_GetTwiss(true, 0.0);
prtmfile("flat_file_fefile.dat");
}
// read multipole error from a file; specfic for soleil lattice
// read multipole errors from a file; specific for soleil lattice
else if(strcmp(CommandStr,"ReadMultipoleFlag") == 0) {
fprintf(stdout,"\n Read Multipoles file for lattice with thick sextupoles, specific for SOLEIL lattice: \n");
ReadFieldErr(multipole_file);
......@@ -265,7 +269,7 @@ int main(int argc, char *argv[]) {
printglob();
}
//print the twiss paramters in a file defined by the name
//print the twiss paramaters in a file defined by the name
else if(strcmp(CommandStr,"PrintTwissFlag") == 0) {
cout << "\n";
cout << "print the twiss parameters to file: "<< twiss_file << "\n";
......@@ -523,7 +527,8 @@ int main(int argc, char *argv[]) {
UserCommandFlag[i]._MomentumAccFlag_nstepp,
UserCommandFlag[i]._MomentumAccFlag_deltaminn,
UserCommandFlag[i]._MomentumAccFlag_deltamaxn,
UserCommandFlag[i]._MomentumAccFlag_nstepn);
UserCommandFlag[i]._MomentumAccFlag_nstepn,
UserCommandFlag[i]._MomentumAccFlag_nturn);
/* restore the initial values*/
globval.Cavity_on = cavityflag;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment