|
18 | 18 | shift_x = 0.3e-2 |
19 | 19 | shift_y = 0.5e-2 |
20 | 20 |
|
21 | | -ctx = xo.context_default |
22 | | -buf = ctx.new_buffer() |
23 | | - |
24 | 21 | logger = logging.getLogger('xtrack') |
25 | 22 | logger.setLevel(logging.DEBUG) |
26 | 23 |
|
27 | 24 | # Define aper_0 |
28 | | -aper_0 = xt.LimitEllipse(_buffer=buf, a=2e-2, b=2e-2) |
| 25 | +aper_0 = xt.LimitEllipse(a=2e-2, b=2e-2) |
29 | 26 | shift_aper_0 = (shift_x, shift_y) |
30 | 27 | rot_deg_aper_0 = 10. |
31 | 28 |
|
32 | 29 | # Define aper_1 |
33 | | -aper_1 = xt.LimitEllipse(_buffer=buf, a=1e-2, b=1e-2) |
| 30 | +aper_1 = xt.LimitEllipse(a=1e-2, b=1e-2) |
34 | 31 | shift_aper_1 = (shift_x, shift_y) |
35 | 32 | rot_deg_aper_1 = 10. |
36 | 33 |
|
37 | 34 | # aper_0_sandwitch |
38 | 35 | line_aper_0 = xt.Line( |
39 | | - elements=[xt.XYShift(_buffer=buf, dx=shift_aper_0[0], dy=shift_aper_0[1]), |
40 | | - xt.SRotation(_buffer=buf, angle=rot_deg_aper_0), |
| 36 | + elements=[xt.XYShift(dx=shift_aper_0[0], dy=shift_aper_0[1]), |
| 37 | + xt.SRotation(angle=rot_deg_aper_0), |
41 | 38 | aper_0, |
42 | | - xt.Multipole(_buffer=buf, knl=[0.00]), |
43 | | - xt.SRotation(_buffer=buf, angle=-rot_deg_aper_0), |
44 | | - xt.XYShift(_buffer=buf, dx=-shift_aper_0[0], dy=-shift_aper_0[1])]) |
45 | | -line_aper_0.build_tracker(_buffer=buf) |
| 39 | + xt.Multipole(knl=[0.00]), |
| 40 | + xt.SRotation(angle=-rot_deg_aper_0), |
| 41 | + xt.XYShift(dx=-shift_aper_0[0], dy=-shift_aper_0[1])]) |
46 | 42 |
|
47 | 43 | # aper_1_sandwitch |
48 | 44 | line_aper_1 = xt.Line( |
49 | | - elements=[xt.XYShift(_buffer=buf, dx=shift_aper_1[0], dy=shift_aper_1[1]), |
50 | | - xt.SRotation(_buffer=buf, angle=rot_deg_aper_1), |
| 45 | + elements=[xt.XYShift(dx=shift_aper_1[0], dy=shift_aper_1[1]), |
| 46 | + xt.SRotation(angle=rot_deg_aper_1), |
51 | 47 | aper_1, |
52 | | - xt.Multipole(_buffer=buf, knl=[0.00]), |
53 | | - xt.SRotation(_buffer=buf, angle=-rot_deg_aper_1), |
54 | | - xt.XYShift(_buffer=buf, dx=-shift_aper_1[0], dy=-shift_aper_1[1])]) |
55 | | -line_aper_1.build_tracker(_buffer=buf) |
| 48 | + xt.Multipole(knl=[0.00]), |
| 49 | + xt.SRotation(angle=-rot_deg_aper_1), |
| 50 | + xt.XYShift(dx=-shift_aper_1[0], dy=-shift_aper_1[1])]) |
56 | 51 |
|
57 | 52 | # Build example line |
58 | 53 | line=xt.Line( |
59 | | - elements = ((xt.Drift(_buffer=buf, length=0.5),) |
| 54 | + elements = ((xt.Drift(length=0.5),) |
60 | 55 | + line_aper_0.elements |
61 | | - + (xt.Drift(_buffer=buf, length=1), |
62 | | - xt.Multipole(_buffer=buf, knl=[0.]), |
63 | | - xt.Drift(_buffer=buf, length=1), |
64 | | - xt.Cavity(_buffer=buf, voltage=3e6, frequency=400e6), |
65 | | - xt.Drift(_buffer=buf, length=1.),) |
| 56 | + + (xt.Drift(length=1), |
| 57 | + xt.Multipole(knl=[0.]), |
| 58 | + xt.Drift(length=1), |
| 59 | + xt.Cavity(voltage=3e6, frequency=400e6), |
| 60 | + xt.Drift(length=1.),) |
66 | 61 | + line_aper_1.elements)) |
67 | 62 | num_elements = len(line) |
68 | 63 |
|
69 | | -line.build_tracker() |
70 | | - |
71 | 64 | # Test on full line |
72 | 65 | r = np.linspace(0, 0.018, n_part) |
73 | 66 | theta = np.linspace(0, 8*np.pi, n_part) |
74 | | -particles = xt.Particles(_context=ctx, |
| 67 | +particles = xt.Particles( |
75 | 68 | p0c=6500e9, |
76 | 69 | x=r*np.cos(theta)+shift_x, |
77 | 70 | y=r*np.sin(theta)+shift_y) |
78 | 71 |
|
79 | 72 | line.track(particles) |
80 | 73 |
|
81 | | - |
82 | 74 | loss_loc_refinement = xt.LossLocationRefinement(line, |
83 | 75 | n_theta = 360, |
84 | 76 | r_max = 0.5, # m |
|
118 | 110 | loss_loc_refinement.i_apertures[1]] |
119 | 111 | s0 = interp_line.s0 |
120 | 112 | s1 = interp_line.s1 |
121 | | -polygon_0 = interp_line.elements[0] |
122 | | -polygon_1 = interp_line.elements[-1] |
| 113 | +polygon_0 = interp_line._elements[0] |
| 114 | +polygon_1 = interp_line._elements[-1] |
123 | 115 | for ii, (trkr, poly) in enumerate( |
124 | 116 | zip([line_aper_0,line_aper_1], |
125 | 117 | [polygon_0, polygon_1])): |
|
0 commit comments