@@ -16,110 +16,84 @@ def make_lattice(
1616 fill_frac : float = 0.5 ,
1717 kq : float = 0.65 ,
1818 start : str = "drift" ,
19- sol : float = 0.0 ,
2019) -> AccLattice :
2120 """Create FODO lattice.
2221
2322 Args:
2423 length: Length of lattice [m].
2524 fill_frac: Fraction of lattice occupied by quadrupoles.
26-
25+ kq: Quad coefficient [1/m].
26+ start: Whether to start in drift or quad center. {"drift", "quad"}
2727 """
28- if start == "drift" :
29- return make_lattice_drift_start (length = length , fill_frac = fill_frac , kq = kq )
30- elif start == "quad" :
31- return make_lattice_quad_start (length = length , fill_frac = fill_frac , kq = kq )
32- else :
33- raise ValueError
34-
35-
36- def make_lattice_quad_start (
37- length : float = 5.0 , fill_frac : float = 0.5 , kq : float = 0.65
38- ) -> AccLattice :
39-
4028 length_quad = length * fill_frac / 2.0
4129 length_drift = length * (1.0 - fill_frac ) / 2.0
4230
43- drift_nodes = [
44- DriftTEAPOT ("drift1" ),
45- DriftTEAPOT ("drift2" ),
46- ]
47- quad_nodes = [
48- QuadTEAPOT ("qf1" ),
49- QuadTEAPOT ("qd" ),
50- QuadTEAPOT ("qf2" ),
51- ]
52-
53- drift_nodes [0 ].setLength (length_drift )
54- drift_nodes [1 ].setLength (length_drift )
55-
56- quad_nodes [0 ].setLength (length_quad * 0.5 )
57- quad_nodes [1 ].setLength (length_quad )
58- quad_nodes [2 ].setLength (length_quad * 0.5 )
59-
60- quad_nodes [0 ].setParam ("kq" , + kq )
61- quad_nodes [1 ].setParam ("kq" , - kq )
62- quad_nodes [2 ].setParam ("kq" , + kq )
63-
64- lattice = TEAPOT_Lattice ()
65- lattice .addNode (quad_nodes [0 ])
66- lattice .addNode (drift_nodes [0 ])
67- lattice .addNode (quad_nodes [1 ])
68- lattice .addNode (drift_nodes [1 ])
69- lattice .addNode (quad_nodes [2 ])
70- lattice .initialize ()
71-
72- for node in lattice .getNodes ():
73- try :
74- node .setUsageFringeFieldIN (False )
75- node .setUsageFringeFieldOUT (False )
76- except :
77- pass
31+ if start == "quad" :
32+ drift_nodes = [
33+ DriftTEAPOT ("drift1" ),
34+ DriftTEAPOT ("drift2" ),
35+ ]
36+ quad_nodes = [
37+ QuadTEAPOT ("qf1" ),
38+ QuadTEAPOT ("qd" ),
39+ QuadTEAPOT ("qf2" ),
40+ ]
7841
79- return lattice
80-
42+ drift_nodes [0 ].setLength (length_drift )
43+ drift_nodes [1 ].setLength (length_drift )
44+
45+ quad_nodes [0 ].setLength (length_quad * 0.5 )
46+ quad_nodes [1 ].setLength (length_quad )
47+ quad_nodes [2 ].setLength (length_quad * 0.5 )
48+
49+ quad_nodes [0 ].setParam ("kq" , + kq )
50+ quad_nodes [1 ].setParam ("kq" , - kq )
51+ quad_nodes [2 ].setParam ("kq" , + kq )
8152
82- def make_lattice_drift_start (
83- length : float = 5.0 , fill_frac : float = 0.5 , kq : float = 0.65
84- ) -> AccLattice :
53+ lattice = TEAPOT_Lattice ()
54+ lattice .addNode (quad_nodes [0 ])
55+ lattice .addNode (drift_nodes [0 ])
56+ lattice .addNode (quad_nodes [1 ])
57+ lattice .addNode (drift_nodes [1 ])
58+ lattice .addNode (quad_nodes [2 ])
59+ lattice .initialize ()
8560
86- length_quad = length * fill_frac / 2.0
87- length_drift = length * (1.0 - fill_frac ) / 2.0
61+ elif start == "drift" :
8862
89- drift_nodes = [
90- DriftTEAPOT ("drift1" ),
91- DriftTEAPOT ("drift2" ),
92- DriftTEAPOT ("drift3" ),
93- ]
94- quad_nodes = [
95- QuadTEAPOT ("qf" ),
96- QuadTEAPOT ("qd" ),
97- ]
63+ drift_nodes = [
64+ DriftTEAPOT ("drift1" ),
65+ DriftTEAPOT ("drift2" ),
66+ ]
67+ quad_nodes = [
68+ QuadTEAPOT ("qf1" ),
69+ QuadTEAPOT ("qd" ),
70+ QuadTEAPOT ("qf2" ),
71+ ]
72+
73+ drift_nodes [0 ].setLength (length_drift )
74+ drift_nodes [1 ].setLength (length_drift )
75+
76+ quad_nodes [0 ].setLength (length_quad * 0.5 )
77+ quad_nodes [1 ].setLength (length_quad )
78+ quad_nodes [2 ].setLength (length_quad * 0.5 )
79+
80+ quad_nodes [0 ].setParam ("kq" , + kq )
81+ quad_nodes [1 ].setParam ("kq" , - kq )
82+ quad_nodes [2 ].setParam ("kq" , + kq )
9883
99-
100- drift_nodes [0 ].setLength (length_drift * 0.5 )
101- drift_nodes [1 ].setLength (length_drift )
102- drift_nodes [2 ].setLength (length_drift * 0.5 )
84+ lattice = TEAPOT_Lattice ()
85+ lattice .addNode (quad_nodes [0 ])
86+ lattice .addNode (drift_nodes [0 ])
87+ lattice .addNode (quad_nodes [1 ])
88+ lattice .addNode (drift_nodes [1 ])
89+ lattice .addNode (quad_nodes [2 ])
90+ lattice .initialize ()
10391
104- quad_nodes [ 0 ]. setLength ( length_quad )
105- quad_nodes [ 1 ]. setLength ( length_quad )
92+ else :
93+ raise ValueError
10694
107- quad_nodes [0 ].setParam ("kq" , + kq )
108- quad_nodes [1 ].setParam ("kq" , - kq )
109-
110- lattice = TEAPOT_Lattice ()
111- lattice .addNode (drift_nodes [0 ])
112- lattice .addNode (quad_nodes [0 ])
113- lattice .addNode (drift_nodes [1 ])
114- lattice .addNode (quad_nodes [1 ])
115- lattice .addNode (drift_nodes [2 ])
116- lattice .initialize ()
117-
11895 for node in lattice .getNodes ():
119- try :
120- node .setUsageFringeFieldIN (False )
121- node .setUsageFringeFieldOUT (False )
122- except :
123- pass
124-
96+ node .setUsageFringeFieldIN (False )
97+ node .setUsageFringeFieldOUT (False )
98+
12599 return lattice
0 commit comments