[3] | 1 | #define PLANES 2 |
---|
| 2 | #define BPM_MAX 120 |
---|
| 3 | |
---|
| 4 | typedef struct globvalrec { |
---|
| 5 | double dPcommon, // dp for numerical differentiation |
---|
| 6 | dPparticle; // energy deviation |
---|
| 7 | double delta_RF; // RF acceptance |
---|
| 8 | Vector2 TotalTune; // transverse tunes |
---|
| 9 | double Omega, |
---|
| 10 | U0, // energy lost per turn in keV |
---|
| 11 | Alphac; // alphap |
---|
| 12 | Vector2 Chrom; // chromaticities |
---|
| 13 | double Energy; // ring energy |
---|
| 14 | long Cell_nLoc, // number of elements in a cell |
---|
| 15 | Elem_nFam, // number of families |
---|
| 16 | CODimax; /* maximum number of cod search before |
---|
| 17 | failing */ |
---|
| 18 | double CODeps; // precision for closed orbit finder |
---|
| 19 | Vector CODvect; // closed orbit; beam position at the first element of lattice |
---|
| 20 | |
---|
| 21 | // family index for special elements |
---|
| 22 | long int bpm; // family index of bpm |
---|
| 23 | long int hcorr; // family index of horizontal corrector which are used for orbit correction |
---|
| 24 | long int vcorr; // family index of vertical corrector which are used for orbit correction |
---|
| 25 | long int qt; // family index of skew quadrupole |
---|
| 26 | int gs; // family number of start girder |
---|
| 27 | int ge; // family number of end girder |
---|
| 28 | long int cav; // family index of RF cavity |
---|
| 29 | |
---|
| 30 | // matrix |
---|
| 31 | Matrix OneTurnMat, // oneturn matrix |
---|
| 32 | Ascr, |
---|
| 33 | Ascrinv, |
---|
| 34 | Vr, // real part of the eigenvectors |
---|
| 35 | Vi; // imaginal par of the eigenvectors |
---|
| 36 | |
---|
| 37 | bool MatMeth, // matrix method |
---|
| 38 | Cavity_on, // if true, cavity turned on |
---|
| 39 | radiation, // if true, radiation turned on |
---|
| 40 | emittance, |
---|
| 41 | quad_fringe, /* dipole- and quadrupole hard-edge |
---|
| 42 | fringe fields. */ |
---|
| 43 | H_exact, // "small ring" Hamiltonian. |
---|
| 44 | pathlength, // absolute path length |
---|
| 45 | stable, |
---|
| 46 | Aperture_on, |
---|
| 47 | EPU, |
---|
| 48 | wake_on; |
---|
| 49 | |
---|
| 50 | double dE, // energy loss |
---|
| 51 | alpha_rad[DOF], // damping coeffs. |
---|
| 52 | D_rad[DOF], // diffusion coeffs (Floquet space) |
---|
| 53 | J[DOF], // partition numbers |
---|
| 54 | tau[DOF]; // damping times |
---|
| 55 | bool IBS; // intrabeam scattering |
---|
| 56 | double Qb, // bunch charge |
---|
| 57 | D_IBS[DOF]; // diffusion matrix (Floquet space) |
---|
| 58 | Vector wr, wi; // real and imaginary part of eigenvalues |
---|
| 59 | Vector3 eps, // 3 motion invariants, emittance? |
---|
| 60 | epsp; /* transverse and longitudinal projected |
---|
| 61 | emittances */ |
---|
| 62 | int RingType; // 1 if a ring (0 if transfer line) |
---|
| 63 | |
---|
| 64 | long bpm_list[BPM_MAX]; /* list of position for bpms into the lattice */ |
---|
| 65 | long hcorr_list[BPM_MAX]; /* list of position for horizontal correctors */ |
---|
| 66 | long vcorr_list[BPM_MAX]; /* list of position for vertical correctors */ |
---|
| 67 | long qt_list[BPM_MAX]; /* list of position for vertical correctors into the lattice */ |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | } globvalrec; |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | struct DriftType { |
---|
| 74 | Matrix D55; // Linear matrix |
---|
| 75 | }; |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | struct MpoleType { |
---|
| 79 | int Pmethod; // Integration Method |
---|
| 80 | int PN; // Number of integration steps |
---|
| 81 | long dipEdge_effect1; // dipole edge effect at the entrance |
---|
| 82 | long dipEdge_effect2; // dipole edge effect at the exit |
---|
| 83 | long quadFF1; /* Entrance quadrupole Fringe field flag */ |
---|
| 84 | long quadFF2; /* Exit quadrupole Fringe field flag */ |
---|
| 85 | double quadFFscaling; /* quadrupole Fringe field scaling factor flag */ |
---|
| 86 | long sextFF1; /* Entrance sextupole Fringe field flag */ |
---|
| 87 | long sextFF2; /* Exit sextupole Fringe field flag */ |
---|
| 88 | |
---|
| 89 | bool Status; /* specific for correctors used for orbit correction. If true, use the corrector |
---|
| 90 | to correct orbit, if false, not use. */ |
---|
| 91 | |
---|
| 92 | // Displacement Errors |
---|
| 93 | Vector2 PdSsys; // systematic displacement error[m] |
---|
| 94 | Vector2 PdSrms; // rms value of the displacement error[m] |
---|
| 95 | Vector2 PdSrnd; // (normal)random scale factor to displacement error PdSrms |
---|
| 96 | // Roll angle |
---|
| 97 | double PdTpar; // design rotation angle, if not equal zero, then skew multipole[deg] |
---|
| 98 | double PdTsys; // systematic [deg] |
---|
| 99 | double PdTrms; // rms rotation error of the element[deg] |
---|
| 100 | double PdTrnd; // (normal)random scale factor to rotation error PdTrms |
---|
| 101 | // Multipole strengths |
---|
| 102 | mpolArray PBpar; // design field gradient; bn, and an |
---|
| 103 | mpolArray PBsys; // systematic multipole errors gradient, bn and an |
---|
| 104 | mpolArray PBrms; // rms multipole field errors gradient, bn and an |
---|
| 105 | mpolArray PBrnd; // random scale factor of rms error PBrms gradient, bn and an |
---|
| 106 | mpolArray PB; // total field strength(design,sys,rms) gradient, bn and an |
---|
| 107 | int Porder; // The highest order in PB |
---|
| 108 | int n_design; // multipole order (design, All = 0, Dip = 1, Quad = 2, Sext = 3, Oct = 4, Dec = 5, Dodec = 6) |
---|
| 109 | pthicktype Pthick; // thick element |
---|
| 110 | // Bending Angles |
---|
| 111 | double PTx1; // horizontal entrance angle [deg] |
---|
| 112 | double PTx2; // horizontal exit angle [deg] |
---|
[11] | 113 | double PH1; // bending curvature of the entrance pole face of dipole, see P116 SAC-75. |
---|
| 114 | double PH2; // bending curvature of the exit pole face of dipole, see P116 SAC-75. |
---|
[3] | 115 | double Pgap; // total magnet gap [m] |
---|
| 116 | double Pirho; // angle([radian], but in lattice definition, angle is with unit degree)/length of the dipole, 1/rho [1/m] |
---|
| 117 | double Pc0, Pc1, Ps1; // corrections for roll error of bend |
---|
| 118 | Matrix AU55, // Upstream 5x5 matrix |
---|
| 119 | AD55; // Downstream 5x5 matrix |
---|
| 120 | }; |
---|
| 121 | |
---|
| 122 | const int n_harm_max = 10; |
---|
| 123 | |
---|
| 124 | struct WigglerType { |
---|
| 125 | int Pmethod; // Integration Method |
---|
| 126 | int PN; // number of integration steps |
---|
| 127 | // Displacement Error |
---|
| 128 | Vector2 PdSsys; // systematic [m] |
---|
| 129 | Vector2 PdSrms; // rms [m] |
---|
| 130 | Vector2 PdSrnd; // random number |
---|
| 131 | // Roll angle |
---|
| 132 | double PdTpar; // design [deg] |
---|
| 133 | double PdTsys; // systematic [deg] |
---|
| 134 | double PdTrms; // rms [deg] |
---|
| 135 | double PdTrnd; // random number |
---|
| 136 | double lambda; // lambda |
---|
| 137 | int n_harm; // no of harmonics |
---|
| 138 | int harm[n_harm_max]; // harmonic number |
---|
| 139 | double BoBrhoV[n_harm_max]; // B/Brho vertical |
---|
| 140 | double BoBrhoH[n_harm_max]; // B/Brho horizontal |
---|
| 141 | double kxV[n_harm_max]; // vertical kx |
---|
| 142 | double kxH[n_harm_max]; // horizontal kx |
---|
| 143 | double phi[n_harm_max]; // phi |
---|
| 144 | mpolArray PBW; |
---|
| 145 | Matrix W55; // Transport matrix |
---|
| 146 | int Porder; // The highest order in PB |
---|
| 147 | }; |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | const int i_max_FM = 100, j_max_FM = 100, k_max_FM = 1000; |
---|
| 151 | |
---|
| 152 | struct FieldMapType { |
---|
| 153 | int n_step; // number of integration steps |
---|
| 154 | int n[3]; // no of steps |
---|
| 155 | double scl; |
---|
| 156 | double xyz[3][i_max_FM][j_max_FM][k_max_FM]; // [x, y, z] |
---|
| 157 | double B[3][i_max_FM][j_max_FM][k_max_FM]; // [B_x, B_y, B_z] |
---|
| 158 | double **AxoBrho, **AxoBrho2, **AyoBrho, **AyoBrho2; // Ax(y, s), Ay(x, s) |
---|
| 159 | }; |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | /* ID Laurent */ |
---|
| 163 | #define IDXMAX 500 |
---|
| 164 | #define IDZMAX 100 |
---|
| 165 | |
---|
| 166 | struct InsertionType { |
---|
| 167 | int Pmethod; /* Integration Method */ |
---|
| 168 | int PN; /* number of integration steps */ |
---|
| 169 | char fname1[100]; /* Filename for insertion description: first order */ |
---|
| 170 | char fname2[100]; /* Filename for insertion description: second order */ |
---|
| 171 | int nx1; /* Horizontal point number */ |
---|
| 172 | int nx2; /* Horizontal point number */ |
---|
| 173 | int nz1; /* Vertical point number */ |
---|
| 174 | int nz2; /* Vertical point number */ |
---|
| 175 | double scaling1; /* static scaling factor as in BETA ESRF first order*/ |
---|
| 176 | double scaling2; /* static scaling factor as in BETA ESRF second order*/ |
---|
| 177 | bool linear; /* if true linear interpolation else spline */ |
---|
| 178 | bool firstorder; /* true if first order kick map loaded */ |
---|
| 179 | bool secondorder; /* true if second order kick map loaded */ |
---|
| 180 | double tabx1[IDXMAX]; /* spacing in H-plane */ |
---|
| 181 | double tabz1[IDZMAX]; /* spacing in V-plane */ |
---|
| 182 | double tabx2[IDXMAX]; /* spacing in H-plane */ |
---|
| 183 | double tabz2[IDZMAX]; /* spacing in V-plane */ |
---|
| 184 | double thetax2[IDZMAX][IDXMAX], thetax1[IDZMAX][IDXMAX]; /* 1 for 1st order */ |
---|
| 185 | double thetaz2[IDZMAX][IDXMAX], thetaz1[IDZMAX][IDXMAX]; |
---|
| 186 | double **tx2, **tz2, **f2x2, **f2z2; // used for splie2 and splin2 (Spline interpolation) |
---|
| 187 | double **tx1, **tz1, **f2x1, **f2z1; // used for splie2 and splin2 |
---|
| 188 | double *TabxOrd1, *TabzOrd1; // tab of x and z meshes from Radia code in increasing order |
---|
| 189 | double *TabxOrd2, *TabzOrd2; // tab of x and z meshes from Radia code in increasing order |
---|
| 190 | |
---|
| 191 | /* Displacement Error */ |
---|
| 192 | Vector2 PdSsys; /* systematic [m] */ |
---|
| 193 | Vector2 PdSrms; /* rms [m] */ |
---|
| 194 | Vector2 PdSrnd; /* random number */ |
---|
| 195 | /* Roll angle */ |
---|
| 196 | double PdTpar; /* design [deg] */ |
---|
| 197 | double PdTsys; /* systematic [deg] */ |
---|
| 198 | double PdTrms; /* rms [deg] */ |
---|
| 199 | double PdTrnd; /* random number */ |
---|
| 200 | Matrix K55; /* Transport matrix:kick part */ |
---|
| 201 | Matrix D55; /* Transport matrix:drift part */ |
---|
| 202 | Matrix KD55; /* Transport matrix:concatenation of kicks and drifts */ |
---|
| 203 | int Porder; /* The highest order in PB */ |
---|
| 204 | }; |
---|
| 205 | |
---|
| 206 | struct CavityType { |
---|
| 207 | double Pvolt; // Vrf [V] |
---|
| 208 | double Pfreq; // Vrf [Hz] |
---|
| 209 | double phi; // RF phase |
---|
| 210 | int Ph; // Harmonic number |
---|
| 211 | }; |
---|
| 212 | |
---|
| 213 | struct CellType; |
---|
| 214 | |
---|
| 215 | const int Spreader_max = 10; |
---|
| 216 | |
---|
| 217 | struct SpreaderType { |
---|
| 218 | double E_max[Spreader_max]; // energy levels in increasing order |
---|
| 219 | CellType *Cell_ptrs[Spreader_max]; |
---|
| 220 | }; |
---|
| 221 | |
---|
| 222 | struct RecombinerType { |
---|
| 223 | double E_min; |
---|
| 224 | double E_max; |
---|
| 225 | }; |
---|
| 226 | |
---|
| 227 | struct SolenoidType { |
---|
| 228 | int N; // Number of integration steps |
---|
| 229 | // Displacement Errors |
---|
| 230 | Vector2 PdSsys; // systematic [m] |
---|
| 231 | Vector2 PdSrms; // rms [m] |
---|
| 232 | Vector2 PdSrnd; // random number |
---|
| 233 | // Roll angle |
---|
| 234 | double dTpar; // design [deg] |
---|
| 235 | double dTsys; // systematic [deg] |
---|
| 236 | double dTrms; // rms [deg] |
---|
| 237 | double dTrnd; // random number |
---|
| 238 | double BoBrho; // normalized field strength |
---|
| 239 | }; |
---|
| 240 | |
---|
| 241 | struct elemtype { |
---|
| 242 | partsName PName; /* Element name */ |
---|
| 243 | double PL; /* Length[m] */ |
---|
| 244 | PartsKind Pkind; /* Enumeration for magnet types */ |
---|
| 245 | union |
---|
| 246 | { |
---|
| 247 | DriftType *D; // Drift |
---|
| 248 | MpoleType *M; // Multipole |
---|
| 249 | WigglerType *W; // Wiggler |
---|
| 250 | FieldMapType *FM; // Field Map |
---|
| 251 | InsertionType *ID; // Insertion |
---|
| 252 | CavityType *C; // Cavity |
---|
| 253 | SpreaderType *Spr; // Spreader |
---|
| 254 | RecombinerType *Rec; // Recombiner |
---|
| 255 | SolenoidType *Sol; // Solenoid |
---|
| 256 | }; |
---|
| 257 | }; |
---|
| 258 | |
---|
| 259 | struct ElemFamType { |
---|
| 260 | elemtype ElemF; /* Structure (name, type) */ |
---|
| 261 | int nKid; /* number of Kids in a family */ |
---|
| 262 | int KidList[nKidMax]; /* list of kid index in the total lattice*/ |
---|
| 263 | int NoDBN; |
---|
| 264 | DBNameType DBNlist[nKidMax]; |
---|
| 265 | }; |
---|
| 266 | |
---|
| 267 | // LEGO block structure for each element of the lattice |
---|
| 268 | struct CellType { |
---|
| 269 | long int Fnum; // Element Family # |
---|
| 270 | long int Knum; // Element Kid # |
---|
| 271 | double S; // Position in the ring [m] |
---|
| 272 | CellType* next_ptr; // pointer to next cell (for tracking) |
---|
| 273 | Vector2 dS, // displacement error of the element[m] |
---|
| 274 | dT; // rotation error of the element[degree], dT = (cos(dT), sin(dT)) |
---|
| 275 | elemtype Elem; // Structure (name, type) |
---|
| 276 | Vector2 Nu, // Phase advances |
---|
| 277 | Alpha, // Alpha functions (redundant) |
---|
| 278 | Beta, // beta fonctions (redundant) |
---|
| 279 | Eta, Etap; // dispersion and its derivative (redundant) |
---|
| 280 | Vector BeamPos; // position of the beam at the cell; |
---|
| 281 | Matrix A, // Floquet space to phase space transformation |
---|
| 282 | sigma; // sigma matrix (redundant) |
---|
| 283 | Vector2 maxampl[PLANES]; /* Horizontal and vertical physical |
---|
| 284 | apertures: |
---|
| 285 | maxampl[X_][0] < x < maxampl[X_][1] |
---|
| 286 | maxampl[Y_][0] < y < maxampl[Y_][1] */ |
---|
| 287 | }; |
---|