diff --git a/tracy/tools/soltracy.cc b/tracy/tools/soltracy.cc index 8d8bff4b442922dd921d6edb6ff4c475bf0ca626..4ec0e6ab4559089a64072e265a3c66c1a0e31bf5 100644 --- a/tracy/tools/soltracy.cc +++ b/tracy/tools/soltracy.cc @@ -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]; /************************************************************************ @@ -138,12 +139,9 @@ int main(int argc, char *argv[]) { // Chamber factory else if(strcmp(CommandStr,"ReadChamberFlag") == 0) { ReadCh(UserCommandFlag[i].chamber_file); /* read vacuum chamber from a file "Apertures.dat" , soleil version*/ - PrintCh(); // print chamber into chamber.out + 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); - // print flat lattice - // sprintf(mfile_name, "flat_file.%03d.dat",k); - // prtmfile(mfile_name); + // 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"; @@ -519,11 +523,12 @@ int main(int argc, char *argv[]) { MomentumAcceptance(UserCommandFlag[i]._MomentumAccFlag_istart, UserCommandFlag[i]._MomentumAccFlag_istop, UserCommandFlag[i]._MomentumAccFlag_deltaminp, - UserCommandFlag[i]._MomentumAccFlag_deltamaxp, + UserCommandFlag[i]._MomentumAccFlag_deltamaxp, UserCommandFlag[i]._MomentumAccFlag_nstepp, - UserCommandFlag[i]._MomentumAccFlag_deltaminn, + 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;