Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:04

0001 #ifndef MAD_NODE_H
0002 #define MAD_NODE_H
0003 
0004 // types
0005 
0006 struct element;
0007 struct command;
0008 struct sequence;
0009 struct expression;
0010 struct constraint_list;
0011 struct double_array;
0012 struct name_list;
0013 
0014 struct align_info
0015 {
0016   struct expression* dx_expr;
0017   double             dx_value;
0018   struct expression* dy_expr;
0019   double             dy_value;
0020   struct expression* ds_expr;
0021   double             ds_value;
0022   struct expression* dtheta_expr;
0023   double             dtheta_value;
0024   struct expression* dphi_expr;
0025   double             dphi_value;
0026   struct expression* dpsi_expr;
0027   double             dpsi_value;
0028 };
0029 struct node                /* the sequence is a linked list of nodes */
0030 {
0031   char name[200];
0032   char* base_name;         /* basic type */
0033   struct node* previous;
0034   struct node* next;
0035   struct node* master;     /* ancestor for interpolated nodes */
0036   int occ_cnt;             /* element occurrence count at node */
0037   int obs_point;           /* observation point number (tracking) */
0038   int sel_err;             /* error select flag */
0039   int sel_sector;          /* sectormap select flag */
0040   int con_cnt;             /* constraint counter */
0041   int enable;              /* flag for correctors and monitors: 0 off, 1 on */
0042   int moved;               /* temporary flag during sequence editing */
0043   int stamp;
0044   double pass_flag;        /* set to 1 at first pass of use-triggered survey */
0045   double position;         /* s position in sequence [m] */
0046   double at_value;
0047   double length;
0048   double dipole_bv;        /* +1 or -1 (if beam_bv AND element_bv) */
0049   double other_bv;         /* equal to beam_bv (+1 or -1) */
0050   double chkick;           /* calculated by orbit correction module */
0051   double cvkick;           /* calculated by orbit correction module */
0052   double surv_data[7];     /* x,y,z,theta,phi,psi,s for use with survey */
0053   struct expression* at_expr;
0054   char* from_name;
0055   struct element* p_elem;  /* pointer to element if any */
0056   struct sequence* p_sequ;  /* pointer to sequence if any */
0057   struct double_array* p_al_err; /* pointer to alignment error array */
0058   struct double_array* p_fd_err; /* pointer to field error array */
0059   struct command* savebeta; /* pointer to savebeta command if any */
0060   struct constraint_list* cl; /* pointer to constraint list during match */
0061   struct double_array* obs_orbit; /* for track observation point */
0062   struct double_array* orbit_ref; /* for threader orbit + cum. matrix */
0063 
0064   struct double_array* interp_at; /* array of positions for intermediate values */
0065   struct double_array* closed_orbit; /* closed orbit for WIRE */
0066   /* RF-Multipole errors (EFCOMP) */
0067   struct double_array* p_ph_err; /* pointer to rf-multipole phase error array AL: */
0068   /* RF-Multipoles */
0069   double rfm_volt;   /* volt of the main rf-multipole field  AL: */
0070   double rfm_freq;   /* frequency of the rf-multipole fields  AL: */
0071   int    rfm_harmon; /* harmonic number of the rf-multipole fields  AL: */
0072   double rfm_lag;    /* lag of the rf-multipole fields  AL: */
0073   int    perm_misalign; /* flag to tell if permanent misalignments are applied */
0074   struct align_info* perm_align;
0075 };
0076 struct node_list /* contains list of node pointers sorted by name */
0077 {
0078   int stamp;
0079   char name[NAME_L];
0080   int  max,                     /* max. pointer array size */
0081        curr;                    /* current occupation */
0082   struct name_list* list;       /* index list of node (!) names */
0083                                 /* node_name = el_name:occ_cnt */
0084   struct node** nodes;          /* node pointer list */
0085 };
0086 
0087 // interface
0088 
0089 struct node* new_node(char* name);
0090 struct node* clone_node(struct node*, int flag);
0091 struct node* delete_node(struct node*);
0092 struct node* expand_node(struct node*, struct sequence* top, struct sequence* seq, double position);
0093 void         dump_node(struct node*);
0094 int          advance_node(void);
0095 void         node_name(char* name, int* l);
0096 void         node_name_f_lower(char* name, int* l);
0097 double       node_value(const char* par);
0098 
0099 struct node_list* new_node_list(int length);
0100 struct node_list* delete_node_list(struct node_list*);
0101 struct node*      delete_node_ring(struct node*);
0102 //void              grow_node_list(struct node_list* p);
0103 void              add_to_node_list(struct node*, int inf, struct node_list*);
0104 
0105 struct node*      find_node_by_name(const char* name, struct node_list*, struct node* fst, struct node* lst);
0106 double  get_node_pos(struct node*, struct sequence*); /* recursive */
0107 double  get_refpos(struct sequence* sequ);
0108 double  hidden_node_pos(char* name, struct sequence*);
0109 void    link_in_front(struct node*, struct node* el);
0110 void    resequence_nodes(struct sequence*);
0111 void    store_node_value(const char* par, double* value);
0112 void    store_node_vector(char* par, int* length, double* vector);
0113 int     store_no_fd_err(double* errors, int* curr);
0114 int     count_nodes(struct sequence*);
0115 void    current_node_name(char* name, int* lg);
0116 int     get_node_count(struct node*);
0117 double  line_nodes(struct char_p_array* flat);
0118 void    node_string(const char* key, char* string, int* l);
0119 int     remove_one(struct node*);
0120 void    replace_one(struct node*, struct element*);
0121 int     retreat_node(void);
0122 void    set_node_bv(struct sequence*);
0123 void    set_new_position(struct sequence*);
0124 int     advance_to_pos(char* table, int* t_pos);
0125 int     node_apertype(void);
0126 int     inside_userdefined_geometry(double *x, double *y);
0127 int     get_userdefined_geometry(double* x, double *y, int* maxlen);
0128 int     get_userdefined_geometry_len(void);
0129 int     is_permalign(void);
0130 double  get_length_(void);
0131 void    node_aperture_vector(double * vec);
0132 void    node_aperture_offset(double * vec);
0133 void    alloc_tt_attrib(int *length);
0134 void    set_tt_attrib(int *index, double *value);
0135 double  get_tt_attrib(int *index);
0136 void    set_tt_multipoles(int *maxmul);
0137 void    get_tt_multipoles(int *nn, double *knl, int *ns, double *ksl);
0138 double  node_obs_point(void);
0139 void    store_orbit_correctors(void);
0140 double  get_closed_orb_node(int *index);
0141 void    set_closed_orb_node(int *index, double *pos);
0142 
0143 #endif // MAD_NODE_H
0144