1 | #include "madx.h" |
---|
2 | |
---|
3 | void |
---|
4 | print_rfc(void) |
---|
5 | /* prints the rf cavities present */ |
---|
6 | { |
---|
7 | double freq0, harmon, freq; |
---|
8 | int i, n = current_sequ->cavities->curr; |
---|
9 | struct element* el; |
---|
10 | if (n == 0) return; |
---|
11 | freq0 = command_par_value("freq0", probe_beam); |
---|
12 | printf("\n RF system: \n"); |
---|
13 | printf(v_format(" %S %NFs %NFs %NFs %NFs %NFs\n"), |
---|
14 | "Cavity","length[m]","voltage[MV]","lag","freq[MHz]","harmon"); |
---|
15 | for (i = 0; i < n; i++) |
---|
16 | { |
---|
17 | el = current_sequ->cavities->elem[i]; |
---|
18 | if ((harmon = el_par_value("harmon", el)) > zero) |
---|
19 | { |
---|
20 | freq = freq0 * harmon; |
---|
21 | printf(v_format(" %S %F %F %F %F %F\n"), |
---|
22 | el->name, el->length, el_par_value("volt", el), |
---|
23 | el_par_value("lag", el), freq, harmon); |
---|
24 | } |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | void |
---|
29 | adjust_rfc(void) |
---|
30 | { |
---|
31 | /* adjusts rfc frequency to given harmon number */ |
---|
32 | double freq0, harmon, freq; |
---|
33 | int i; |
---|
34 | struct element* el; |
---|
35 | freq0 = command_par_value("freq0", probe_beam); |
---|
36 | for (i = 0; i < current_sequ->cavities->curr; i++) |
---|
37 | { |
---|
38 | el = current_sequ->cavities->elem[i]; |
---|
39 | if ((harmon = command_par_value("harmon", el->def)) > zero) |
---|
40 | { |
---|
41 | freq = freq0 * harmon; |
---|
42 | store_comm_par_value("freq", freq, el->def); |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | double |
---|
48 | rfc_slope(void) |
---|
49 | /* calculates the accumulated "slope" of all cavities */ |
---|
50 | { |
---|
51 | double slope = zero, harmon, charge, pc; |
---|
52 | struct node* c_node = current_sequ->range_start; |
---|
53 | struct element* el; |
---|
54 | charge = command_par_value("charge", current_beam); |
---|
55 | pc = command_par_value("pc", current_beam); |
---|
56 | do |
---|
57 | { |
---|
58 | el = c_node->p_elem; |
---|
59 | if (strcmp(el->base_type->name, "rfcavity") == 0 && |
---|
60 | (harmon = command_par_value("harmon", el->def)) > zero) |
---|
61 | { |
---|
62 | double volt = command_par_value("volt", el->def); |
---|
63 | double lag = command_par_value("lag", el->def); |
---|
64 | slope += ten_m_3 * charge * volt * harmon * cos(twopi * lag) / pc; |
---|
65 | } |
---|
66 | if (c_node == current_sequ->range_end) break; |
---|
67 | c_node = c_node->next; |
---|
68 | } |
---|
69 | while (c_node != NULL); |
---|
70 | return slope; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|