-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrr_sextupoles.py
131 lines (115 loc) · 3.3 KB
/
rr_sextupoles.py
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
#!/usr/bin/env python
import os
import sys
import numpy as np
import synergia
# manipulate the chromaticity RR trim sextupole magnets
# In the lattice file, the sextupole currents are set by two
# parameters SF_I for "focussing" sextupole currents and SD_I
# for "defocussing" sextupole currents. In turn, these are fanned
# out to other parametrized currents:
# Focussing:
focussing_currents = ["s112_i", "s128_i", "s330_i", "s412_i", "s428_i", "s630_i"]
defocussing_currents = ["s111_i", "s113_i", "s119_i", "s207_i", "s411_i", "s413_i", "s419_i", "s507_i", "s633_i"]
# S331_I is set to 0 because this magnets aren't installed [email protected] 2014-09-10
# list of focussing sextupoles
SF = [
"s112",
"s114",
"s116",
"s118", # these magnets depend on s112_i
"s128",
"s130",
"s202",
"s204", # these magnets depend on s128_i
"s330",
"s332",
"s334",
"s336", # these magnets depend on s330_i
"s412",
"s414",
"s416",
"s418", # these magnets depend on s412_i
"s428",
"s430",
"s502",
"s504", # these magnets depend on s428_i
# "s630", "s632", "s634", "s636"] # these magnets depend on s630_i
"s634",
"s636",
] # these magnets depend on s630_i
# list of defocussing sextupoles
SD = [
"s111", # this magnet depends on s111_i
"s113",
"s115",
"s117", # these magnets depend on s113_i
"s119",
"s121",
"s123",
"s125",
"s127",
"s129", # these magnets depend on s119_i
"s203",
"s205",
"s207",
"s209",
"s211",
"s213", # these magnets depend on s207_i
# "s331", "s333", these magnets depend on s331_i which is set to 0
"s411", # this magnet depends on s411_i
"s413",
"s415",
"s417", # these magnets depend on s413_i
"s419",
"s421",
"s423",
"s425",
"s427",
"s429", # these magnets depend on s419_i
"s501",
"s503",
"s507",
"s509",
"s511",
"s513", # these magnets depend on s507_i
"s633",
"s635",
] # these magnets depend on s633_i
# extract focussing and defocussing sextupoles from the lattice
# return ( [list of focussing], [list of defocussing])
def get_fd_sextupoles(lattice):
f_sext = []
d_sext = []
for elem in lattice.get_elements():
ename = elem.get_name()
# print elem.as_string()
in_f = False
in_d = False
if ename in SF:
f_sext.append(elem)
# print "elem in SF"
in_f = True
if ename in SD:
d_sext.append(elem)
# print "elem in SD"
in_d = True
if in_f and in_d:
print("Error: element %s is in both focussing and defocussing sextupoles" % ename)
return (f_sext, d_sext)
def print_focussing():
print(len(SF), " focussing sextupoles: ", SF)
def print_defocussing():
print(len(SD), "defocussing sextupoles: ", SD)
if __name__ == "__main__":
# print_focussing()
# print_defocussing()
lattice = synergia.lattice.Lattice()
synergia.lattice.xml_load_lattice(lattice, "rrnova_flat_fixed.xml")
f_sext, d_sext = get_fd_sextupoles(lattice)
print(len(f_sext), " focussing sextupoles")
for elem in f_sext:
print(elem.as_string())
print(len(d_sext), " defocussing sextupoles")
for elem in d_sext:
print(elem.as_string())