-
Notifications
You must be signed in to change notification settings - Fork 39
MAD X main data structures
Riccardo De Maria edited this page Mar 2, 2023
·
4 revisions
-
varl->list->inform[pos] == 0
-> undefined reference in expression -
varl->list->inform[pos] == 1
-> variable definined -
varl->list->inform[pos] == 2
-> separate list, do not drop variable ??? -
var->type == 3
-> string -
var->type == 0
-> const -
var->val_type == 0
-> int
Simple arrays
struct <type>_array { int stamp; int max, curr; <type>* <c|p|i|a|ca>;};
where types is char
, int
, double
, char_p
,char_array*
. int
, char_p
, char_array_list
has also char name[NAME_L]
name_list and vector_list
struct name_list /* contains list of index sorted names plus int inform. */
{
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
int* index; /* index for alphabetic access */
int* inform; /* array parallel to names with integer */
int stamp;
const char** names; /* element names for sort */
};
struct vector_list /* contains named vectors */
{
int curr, max;
struct name_list* names;
struct double_array** vectors;
};
struct table
{
char name[NAME_L],
type[NAME_L]; /* like "twiss", "survey" etc. */
int max, /* max. # rows */
curr, /* current # rows */
num_cols, /* total # columns - fixed */
org_cols, /* original # columns from definition */
dynamic, /* if != 0, values taken from current row */
origin; /* 0 if created in job, 1 if read */
struct char_p_array* header; /* extra lines for file header */
struct int_array* col_out; /* column no.s to be written (in this order) */
struct int_array* row_out; /* flag for row: 1 write, 0 don't */
struct char_p_array* node_nm; /* names of nodes at each row */
struct char_p_array** l_head; /* extra lines to be put in front of a line */
struct node** p_nodes; /* pointers to nodes at each row */
char*** s_cols; /* string columns */
double** d_cols; /* double precision columns */
int stamp;
struct name_list* columns; /* names + types (in inform):
1 double, 3 string */
struct sequence* org_sequ; /* pointer to sequence it refers to */
};
struct table_list
{
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
struct name_list* names; /* index list of tables */
struct table** tables;
int stamp;
};
struct table_list_list
{
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
struct table_list** table_lists;
int stamp;
};
struct expression
{
char name[NAME_L];
char* string; /* expression in string form */
int status; /* status flag: 0 not evaluated
1 evaluated */
struct int_array* polish; /* pointer to Polish notation, or NULL */
double value; /* actual value */
int stamp;
};
struct expr_list
{
int stamp;
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
struct expression** list; /* expression pointer list */
};
struct command_parameter /* holds one command parameter */
{
char name[NAME_L];
int type; /* 0 logical 1 integer 2 double
3 string 4 constraint */
/* 11 int array 12 double array
13 string array */
int c_type; /* for type 4:
1 min, 2 max, 3 both, 4 value */
double double_value; /* type 0, 1, 2, 4 */
double c_min; /* type 4 */
double c_max; /* type 4 */
struct expression* expr; /* type 1, 2, 4 */
struct expression* min_expr; /* type 4 */
struct expression* max_expr; /* type 4 */
char* string; /* type 3 */
int stamp;
struct double_array* double_array; /* type 11, 12 */
struct expr_list* expr_list; /* type 11, 12 */
struct char_p_array* m_string; /* type 13 */
struct command_parameter* call_def; /* contains definitions for "bare"
parameter input, e.g. option,echo */
};
struct command_parameter_list /* contains list of command parameter pointers */
{
int stamp;
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
struct command_parameter** parameters; /* command_parameter pointer list */
};
struct command /* holds one command */
{
char name[NAME_L];
char module[NAME_L]; /* name of module it belongs to */
char group[NAME_L]; /* command group it belongs to */
int stamp;
int link_type; /* 0 none, 1 start, 2 end of group */
int mad8_type; /* 0 none, else mad-8 element code */
int beam_def; /* beam commands: 1 if defined */
struct name_list* par_names; /* names + input flag of parameters */
struct command_parameter_list* par; /* parameter pointer list */
};
struct command_list /* contains list of command pointers sorted by name */
{
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
struct name_list* list; /* index list of names */
int stamp;
struct command** commands; /* command pointer list */
};
struct command_list_list /* contains list of command lists */
{
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
struct name_list* list; /* index list of names */
struct command_list** command_lists; /* command_list pointer list */
int stamp;
};
struct element /* each element is unique */
{
char name[NAME_L];
int def_type; /* 0 if defined separately,
1 if inside sequence */
int bv; /* bv: 0 false, 1 true (invert angle for
sequence bv = -1) */
double length;
struct command* def; /* pointer to defining command */
struct element* parent; /* pointer to parent of element */
/* *this for base_type elements (rbend etc.) */
int stamp;
struct element* base_type; /* pointer to base_type of element */
/* *this for base_type elements (rbend etc.) */
struct aperture* aper;
double *tt_attrib;
double *tt_closed_x;
double *tt_closed_y;
struct multipole* multip;
int perm_misalign;
};
struct aperture
{
enum en_apertype apertype;
double *aper_offset;
double *aperture;
double *xlist;
double *ylist;
int length;
int custom_inter;
};
struct multipole
{
int nn;
int ns;
double *knl;
double *ksl;
};
struct el_list /* contains list of element pointers sorted by name */
{
int stamp;
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
struct name_list* list; /* index list of names */
struct element** elem; /* element pointer list */
};
struct align_info
{
struct expression* dx_expr;
double dx_value;
struct expression* dy_expr;
double dy_value;
struct expression* ds_expr;
double ds_value;
struct expression* dtheta_expr;
double dtheta_value;
struct expression* dphi_expr;
double dphi_value;
struct expression* dpsi_expr;
double dpsi_value;
};
struct node /* the sequence is a linked list of nodes */
{
char name[200];
char* base_name; /* basic type */
struct node* previous;
struct node* next;
struct node* master; /* ancestor for interpolated nodes */
int occ_cnt; /* element occurrence count at node */
int obs_point; /* observation point number (tracking) */
int sel_err; /* error select flag */
int sel_sector; /* sectormap select flag */
int con_cnt; /* constraint counter */
int enable; /* flag for correctors and monitors: 0 off, 1 on */
int moved; /* temporary flag during sequence editing */
int stamp;
double pass_flag; /* set to 1 at first pass of use-triggered survey */
double position; /* s position in sequence [m] */
double at_value;
double length;
double dipole_bv; /* +1 or -1 (if beam_bv AND element_bv) */
double other_bv; /* equal to beam_bv (+1 or -1) */
double chkick; /* calculated by orbit correction module */
double cvkick; /* calculated by orbit correction module */
double surv_data[7]; /* x,y,z,theta,phi,psi,s for use with survey */
struct expression* at_expr;
char* from_name;
struct element* p_elem; /* pointer to element if any */
struct sequence* p_sequ; /* pointer to sequence if any */
struct double_array* p_al_err; /* pointer to alignment error array */
struct double_array* p_fd_err; /* pointer to field error array */
struct command* savebeta; /* pointer to savebeta command if any */
struct constraint_list* cl; /* pointer to constraint list during match */
struct double_array* obs_orbit; /* for track observation point */
struct double_array* orbit_ref; /* for threader orbit + cum. matrix */
struct double_array* interp_at; /* array of positions for intermediate values */
struct double_array* closed_orbit; /* closed orbit for WIRE */
/* RF-Multipole errors (EFCOMP) */
struct double_array* p_ph_err; /* pointer to rf-multipole phase error array AL: */
/* RF-Multipoles */
double rfm_volt; /* volt of the main rf-multipole field AL: */
double rfm_freq; /* frequency of the rf-multipole fields AL: */
int rfm_harmon; /* harmonic number of the rf-multipole fields AL: */
double rfm_lag; /* lag of the rf-multipole fields AL: */
int perm_misalign; /* flag to tell if permanent misalignments are applied */
struct align_info* perm_align;
};
struct node_list /* contains list of node pointers sorted by name */
{
int stamp;
char name[NAME_L];
int max, /* max. pointer array size */
curr; /* current occupation */
struct name_list* list; /* index list of node (!) names */
/* node_name = el_name:occ_cnt */
struct node** nodes; /* node pointer list */
};