source: TRACY3/trunk/tracy/tracy/inc/tracy_global.h @ 32

Last change on this file since 32 was 32, checked in by zhangj, 10 years ago

active the transport of the twiss functions and orbits of the transfer line.

  • Property svn:executable set to *
File size: 12.5 KB
Line 
1#define PLANES 2
2#define BPM_MAX 120
3
4typedef struct globvalrec {
5  double        dPcommon,       // dp for numerical differentiation; defined in lattice
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;         // momentum compaction factor
12  Vector2       Chrom;          // chromaticities
13  double        Energy;         // ring energy; defined in lattice
14  long          Cell_nLoc,      // number of elements in a cell (For example, a lattice can have several same cells)
15                Elem_nFam,      // number of families
16                CODimax;        /* maximum number of cod search before
17                                   failing */
18  double        CODeps;         // precision for closed orbit finder; defined in the lattice
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 or symplectic tracking?
38                Cavity_on,      // if true, cavity turned on
39                radiation,      // if true, radiation turned on
40                emittance,       // calculate emittance?
41                quad_fringe,    /* dipole- and quadrupole hard-edge?
42                                   fringe fields. */
43                H_exact,        // "small ring" or approximation 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
73struct DriftType {
74  Matrix D55; // Linear matrix
75};
76
77
78struct 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  //basic parameters
108  int         Porder;    // The highest order in PB
109  int         n_design;  // multipole order (design, All = 0, Dip = 1, Quad = 2, Sext = 3, Oct = 4, Dec = 5, Dodec = 6)
110  pthicktype  Pthick;    // thick element
111  // dipole type
112  double PTx1;           // horizontal entrance angle [deg]
113  double PTx2;           // horizontal exit angle [deg]
114  double PH1;            // bending curvature of the entrance pole face of dipole, see P116 SAC-75.
115  double PH2;            // bending curvature of the exit pole face of dipole, see P116 SAC-75.
116  double Pgap;           // total dipole gap [m]
117  double Pirho;          // curvature of the dipoles. 1/rho [1/m]
118  double Pc0, Pc1, Ps1;  // corrections for roll error of bend
119  Matrix AU55,           // Upstream 5x5 matrix
120    AD55;           // Downstream 5x5 matrix
121};
122
123const int  n_harm_max = 10;
124
125struct WigglerType {
126  int Pmethod;                // Integration Method
127  int PN;                     // number of integration steps
128  // Displacement Error
129  Vector2 PdSsys;             // systematic [m] 
130  Vector2 PdSrms;             // rms [m]
131  Vector2 PdSrnd;             // random number
132  // Roll angle
133  double PdTpar;              // design [deg]
134  double PdTsys;              // systematic [deg]
135  double PdTrms;              // rms [deg]
136  double PdTrnd;              // random number
137  double lambda;              // lambda
138  int    n_harm;              // no of harmonics
139  int    harm[n_harm_max];    // harmonic number
140  double BoBrhoV[n_harm_max]; // B/Brho vertical
141  double BoBrhoH[n_harm_max]; // B/Brho horizontal
142  double kxV[n_harm_max];     // vertical kx
143  double kxH[n_harm_max];     // horizontal kx
144  double phi[n_harm_max];     // phi
145  mpolArray PBW;
146  Matrix W55;                 // Transport matrix
147  int Porder;                 // The highest order in PB
148};
149
150
151const int  i_max_FM = 100, j_max_FM = 100, k_max_FM = 1000;
152
153struct FieldMapType {
154  int     n_step; // number of integration steps
155  int     n[3];                                         // no of steps
156  double  scl;
157  double  xyz[3][i_max_FM][j_max_FM][k_max_FM];         // [x, y, z]
158  double  B[3][i_max_FM][j_max_FM][k_max_FM];           // [B_x, B_y, B_z]
159  double  **AxoBrho, **AxoBrho2, **AyoBrho, **AyoBrho2; // Ax(y, s), Ay(x, s)
160};
161
162
163/* ID Laurent */
164#define IDXMAX 500
165#define IDZMAX 100
166
167struct InsertionType {
168  int Pmethod;      /* Integration Method */
169  int PN;           /* number of integration steps */
170  char fname1[100]; /* Filename for insertion description: first order */
171  char fname2[100]; /* Filename for insertion description: second order */
172  int nx1;           /* Horizontal point number */
173  int nx2;           /* Horizontal point number */
174  int nz1;           /* Vertical point number */
175  int nz2;           /* Vertical point number */
176  double scaling1;   /* static scaling factor as in BETA ESRF first order*/
177  double scaling2;   /* static scaling factor as in BETA ESRF second order*/
178  bool linear;      /* if true linear interpolation else spline */
179  bool firstorder;  /* true if first order kick map loaded */
180  bool secondorder; /* true if second order kick map loaded */
181  double tabx1[IDXMAX]; /* spacing in H-plane */
182  double tabz1[IDZMAX]; /* spacing in V-plane */
183  double tabx2[IDXMAX]; /* spacing in H-plane */
184  double tabz2[IDZMAX]; /* spacing in V-plane */
185  double thetax2[IDZMAX][IDXMAX], thetax1[IDZMAX][IDXMAX]; /* 1 for 1st order */
186  double thetaz2[IDZMAX][IDXMAX], thetaz1[IDZMAX][IDXMAX];
187  double **tx2, **tz2, **f2x2, **f2z2; // used for splie2 and splin2 (Spline interpolation)
188  double **tx1, **tz1, **f2x1, **f2z1; // used for splie2 and splin2
189  double *TabxOrd1, *TabzOrd1; // tab of x and z meshes from Radia code in increasing order
190  double *TabxOrd2, *TabzOrd2; // tab of x and z meshes from Radia code in increasing order
191 
192  /* Displacement Error */
193  Vector2 PdSsys;   /* systematic [m]  */
194  Vector2 PdSrms;   /* rms [m] */
195  Vector2 PdSrnd;   /* random number */
196  /* Roll angle */
197  double PdTpar;    /* design [deg] */
198  double PdTsys;    /* systematic [deg] */
199  double PdTrms;    /* rms [deg] */
200  double PdTrnd;    /* random number */
201  Matrix K55;        /* Transport matrix:kick part */
202  Matrix D55;        /* Transport matrix:drift part */
203  Matrix KD55;       /* Transport matrix:concatenation of kicks and drifts */
204  int Porder;        /* The highest order in PB */
205};
206
207struct CavityType {
208  double Pvolt;   // Vrf [V]
209  double Pfreq;   // Vrf [Hz]
210  double phi;     // RF phase
211  int    Ph;      // Harmonic number
212};
213
214struct CellType;
215
216const int  Spreader_max = 10;
217
218struct SpreaderType {
219  double    E_max[Spreader_max];      // energy levels in increasing order
220  CellType  *Cell_ptrs[Spreader_max];
221};
222
223struct RecombinerType {
224  double    E_min;
225  double    E_max;
226};
227
228struct SolenoidType {
229  int         N;         // Number of integration steps
230  // Displacement Errors
231  Vector2     PdSsys;    // systematic [m]
232  Vector2     PdSrms;    // rms [m]
233  Vector2     PdSrnd;    // random number
234  // Roll angle
235  double      dTpar;     // design [deg]
236  double      dTsys;     // systematic [deg]
237  double      dTrms;     // rms [deg]
238  double      dTrnd;     // random number
239  double      BoBrho;    // normalized field strength
240};
241
242struct elemtype {
243  partsName PName;   /* Element name */
244  double PL;         /* Length[m]    */
245  PartsKind Pkind;   /* Enumeration  for magnet types */
246  union
247  {
248    DriftType      *D;   // Drift
249    MpoleType      *M;   // Multipole
250    WigglerType    *W;   // Wiggler
251    FieldMapType   *FM;  // Field Map
252    InsertionType  *ID;  // Insertion
253    CavityType     *C;   // Cavity
254    SpreaderType   *Spr; // Spreader
255    RecombinerType *Rec; // Recombiner
256    SolenoidType   *Sol; // Solenoid
257  };
258};
259
260struct ElemFamType {
261  elemtype    ElemF;    /* Structure (name, type) */
262  int         nKid;         /* number of Kids in a family */
263  int         KidList[nKidMax]; /* list of kid index in the total lattice*/
264  int         NoDBN;
265  DBNameType  DBNlist[nKidMax];
266};
267
268// LEGO block structure for each element of the lattice
269struct CellType {
270  long int              Fnum;        // Element Family #
271  long int              Knum;        // Element Kid #
272  double           S;           // Position in the ring [m]
273  CellType*        next_ptr;    // pointer to next cell (for tracking)
274  Vector2          dS,          // displacement error of the element[m]
275                   dT;          // rotation error of the element[degree], dT = (cos(dT), sin(dT))
276  elemtype         Elem;        // Structure (name, type)
277  Vector2          Nu,          // Phase advances
278                   Alpha,       // Alpha functions (redundant)
279                   Beta,        // beta fonctions (redundant)
280                   Eta, Etap;   // dispersion and its derivative (redundant)
281  Vector           BeamPos;     // position of the beam at the cell;
282  Matrix           A,           // Floquet space to phase space transformation
283                   sigma;       // sigma matrix (redundant)
284  Vector2          maxampl[PLANES]; /* Horizontal and vertical physical
285                                       apertures:
286                                         maxampl[X_][0] < x < maxampl[X_][1]
287                                         maxampl[Y_][0] < y < maxampl[Y_][1] */
288
289   Vector        CODvect;        //orbit at the end of the lattice element  Added by Jianfeng Zhang @ LAL, 01/04/2014.
290};
Note: See TracBrowser for help on using the repository browser.