Skip to content
Snippets Groups Projects
Commit f83ac216 authored by zhang's avatar zhang
Browse files

08/04/2011

Add the interface to read .fe and .fe files, and also to read parameters for orbit corrections.
parent 2550c435
Branches
Tags
No related merge requests found
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
Read_Lattice() Read_Lattice()
Comments: Comments:
Jianfeng Zhang 03/2011 soleil Written by Jianfeng Zhang 03/2011 soleil
****************************************************************************/ ****************************************************************************/
...@@ -32,13 +32,28 @@ ...@@ -32,13 +32,28 @@
char twiss_file[max_str]; char twiss_file[max_str];
// cod file // cod file
char cod_file[max_str]; char cod_file[max_str];
// girder file
char girder_file[max_str];
//chamber file //chamber file
char chamber_file[max_str];
// multipole files // multipole files
char multipole_file[max_str]; char multipole_file[max_str];
// multipole file for soleil lattice // multipole file for soleil lattice
char fic_hcorr[max_str],fic_vcorr[max_str], fic_skew[max_str]; char fic_hcorr[max_str],fic_vcorr[max_str], fic_skew[max_str];
//errors
//char fe_file[max_str]; //the same as multipole_file[max_str]????
/* COD correction */
int nwh = 56, nwv = 56; //number of singular values for SVD correction
//correction
char hcorr_file[max_str], vcorr_file[max_str]; //files with the status of hcorr/vcorr status,
//to choose which correctors are used for orbit correction
//default name of special elements in lattice
char hcorr_name[max_str] = "", vcorr_name[max_str] = "";
char skew_quad_name[max_str] = "", bpm_name[max_str] = "";
char gs_name[max_str] = "", ge_name[max_str] = "";
#define OLD_LATTICE #define OLD_LATTICE
...@@ -114,8 +129,6 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom ...@@ -114,8 +129,6 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom
CommNo++; CommNo++;
/*read file names................. */ /*read file names................. */
/* set file directory*/ /* set file directory*/
if (strcmp("in_dir", name) == 0) if (strcmp("in_dir", name) == 0)
...@@ -138,44 +151,74 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom ...@@ -138,44 +151,74 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom
*/ */
#endif #endif
} }
} }
/* other file names.....*/ /* other file names.....*/
/* chamber file */
else if (strcmp("chamber_file", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(chamber_file,"%s%s", in_dir, str); /* add file directory of the chamber file*/
}
else if (strcmp("multipole_file", name) == 0){ else if (strcmp("multipole_file", name) == 0){
sscanf(line, "%*s %s", str); sscanf(line, "%*s %s", str);
sprintf(multipole_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/ sprintf(multipole_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/
} }
/* read in bool flags */ /* read in bool flags */
//print twiss parameters flag else if (strcmp("QuadFringeOnFlag", name) == 0){
else if (strcmp("PrintTwissFlag", name) == 0){
sscanf(line, "%*s %s", twiss_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//print close orbit(COD) flag else if (strcmp("RFvoltageFlag", name) == 0){
else if (strcmp("PrintCODFlag", name) == 0){ sscanf(line, "%*s %lf", &(UserCommandFlag[CommNo].RFvolt));
sscanf(line, "%*s %s", cod_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//read chamber file flat //read chamber file flat
else if (strcmp("ReadChamberFlag", name) == 0){ else if (strcmp("ReadChamberFlag", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(UserCommandFlag[CommNo].chamber_file,"%s%s", in_dir, str);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//read field error, GENERIC command
else if (strcmp("QuadFringeOnFlag", name) == 0){ else if (strcmp("ReadfefileFlag", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(UserCommandFlag[CommNo].fe_file,"%s%s", in_dir, str);
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}
//read misalignment error, then do orbit correction
else if (strcmp("ReadaefileFlag", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(UserCommandFlag[CommNo].ae_file,"%s%s", in_dir, str);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
else if (strcmp("RFvoltageFlag", name) == 0){ //read multipole errors; specific for SOLEIL lattice
sscanf(line, "%*s %lf", &(UserCommandFlag[CommNo].RFvolt)); else if (strcmp("ReadMultipoleFlag", name) == 0){
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}else if (strcmp("fic_hcorr", name) == 0){// read of h-correctors for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_hcorr,"%s%s", in_dir, str);
}else if (strcmp("fic_vcorr", name) == 0){// read of v-correctors for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_vcorr,"%s%s", in_dir, str);
}else if (strcmp("fic_skew", name) == 0){// read of skew quads for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_skew,"%s%s", in_dir, str);
}
//print twiss parameters flag
else if (strcmp("PrintTwissFlag", name) == 0){
sscanf(line, "%*s %s", twiss_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}
//print close orbit(COD) flag
else if (strcmp("PrintCODFlag", name) == 0){
sscanf(line, "%*s %s", cod_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//print close orbit(COD) flag
else if (strcmp("PrintGirderFlag", name) == 0){
sscanf(line, "%*s %s", girder_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}
else if (strcmp("TuneTracFlag", name) == 0){ else if (strcmp("TuneTracFlag", name) == 0){
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
...@@ -276,23 +319,7 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom ...@@ -276,23 +319,7 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom
); );
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
else if (strcmp("ReadMultipoleFlag", name) == 0){
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}
else if (strcmp("fic_hcorr", name) == 0){// read of h-correctors for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_hcorr,"%s%s", in_dir, str);
}
else if (strcmp("fic_vcorr", name) == 0){// read of v-correctors for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_vcorr,"%s%s", in_dir, str);
}
else if (strcmp("fic_skew", name) == 0){// read of skew quads for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_skew,"%s%s", in_dir, str);
}
// generic one, fit for 1 family of quadrupoles // generic one, fit for 1 family of quadrupoles
else if (strcmp("FitTuneFlag", name) == 0){ else if (strcmp("FitTuneFlag", name) == 0){
sscanf(line, "%*s %s %s %lf %lf",UserCommandFlag[CommNo].qf,UserCommandFlag[CommNo].qd, sscanf(line, "%*s %s %s %lf %lf",UserCommandFlag[CommNo].qf,UserCommandFlag[CommNo].qd,
...@@ -370,6 +397,50 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom ...@@ -370,6 +397,50 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//correctors for COD correction
else if (strcmp("hcorr_file", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(hcorr_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/
}
else if (strcmp("vcorr_file", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(vcorr_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/
}
else if (strcmp("bpm_name", name) == 0){
sscanf(line, "%*s %s", bpm_name); /* the name of bpm */
}
else if (strcmp("h_corr", name) == 0){
sscanf(line, "%*s %s", hcorr_name); /* the name of H corrector used for COD correction*/
}
else if (strcmp("v_corr", name) == 0){
sscanf(line, "%*s %s", vcorr_name); /* the name of V corrector used for COD correction*/
}
else if (strcmp("qt", name) == 0){
sscanf(line, "%*s %s", skew_quad_name); /* name of skew quadrupoles */
}
else if (strcmp("gs", name) == 0){
sscanf(line, "%*s %s", gs_name); /* name of start of the girder */
}
else if (strcmp("ge", name) == 0){
sscanf(line, "%*s %s", ge_name); /* name of end of the girder */
}
//set parameters for COD correction
else if (strcmp("n_orbit", name) == 0){
sscanf(line, "%*s %d", &n_orbit);
}
else if (strcmp("n_scale", name) == 0){
sscanf(line, "%*s %d", &n_scale);
}
else if (strcmp("n_stat", name) == 0){
sscanf(line, "%*s %d", &n_stat);
}
else if (strcmp("nwh", name) == 0){
sscanf(line, "%*s %d", &nwh);
}
else if (strcmp("nwv", name) == 0){
sscanf(line, "%*s %d", &nwv);
}
else{ else{
printf("bad line in file %s, line %ld \n", full_param_file_name, LineNum); printf("bad line in file %s, line %ld \n", full_param_file_name, LineNum);
exit_(1); exit_(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment