forked from MethodicalAcceleratorDesign/MAD-X
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mad_node.h
144 lines (134 loc) · 5.91 KB
/
mad_node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef MAD_NODE_H
#define MAD_NODE_H
// types
struct element;
struct command;
struct sequence;
struct expression;
struct constraint_list;
struct double_array;
struct name_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 */
};
// interface
struct node* new_node(char* name);
struct node* clone_node(struct node*, int flag);
struct node* delete_node(struct node*);
struct node* expand_node(struct node*, struct sequence* top, struct sequence* seq, double position);
void dump_node(struct node*);
int advance_node(void);
void node_name(char* name, int* l);
void node_name_f_lower(char* name, int* l);
double node_value(const char* par);
struct node_list* new_node_list(int length);
struct node_list* delete_node_list(struct node_list*);
struct node* delete_node_ring(struct node*);
//void grow_node_list(struct node_list* p);
void add_to_node_list(struct node*, int inf, struct node_list*);
struct node* find_node_by_name(const char* name, struct node_list*, struct node* fst, struct node* lst);
double get_node_pos(struct node*, struct sequence*); /* recursive */
double get_refpos(struct sequence* sequ);
double hidden_node_pos(char* name, struct sequence*);
void link_in_front(struct node*, struct node* el);
void resequence_nodes(struct sequence*);
void store_node_value(const char* par, double* value);
void store_node_vector(char* par, int* length, double* vector);
int store_no_fd_err(double* errors, int* curr);
int count_nodes(struct sequence*);
void current_node_name(char* name, int* lg);
int get_node_count(struct node*);
double line_nodes(struct char_p_array* flat);
void node_string(const char* key, char* string, int* l);
int remove_one(struct node*);
void replace_one(struct node*, struct element*);
int retreat_node(void);
void set_node_bv(struct sequence*);
void set_new_position(struct sequence*);
int advance_to_pos(char* table, int* t_pos);
int node_apertype(void);
int inside_userdefined_geometry(double *x, double *y);
int get_userdefined_geometry(double* x, double *y, int* maxlen);
int get_userdefined_geometry_len(void);
int is_permalign(void);
double get_length_(void);
void node_aperture_vector(double * vec);
void node_aperture_offset(double * vec);
void alloc_tt_attrib(int *length);
void set_tt_attrib(int *index, double *value);
double get_tt_attrib(int *index);
void set_tt_multipoles(int *maxmul);
void get_tt_multipoles(int *nn, double *knl, int *ns, double *ksl, double ktap);
double node_obs_point(void);
void store_orbit_correctors(void);
double get_closed_orb_node(int *index);
void set_closed_orb_node(int *index, double *pos);
#endif // MAD_NODE_H