Example code to find a closed orbit.
2 \namespace xboa::examples::closed_orbit
4 Example code to find a closed orbit
6 \include xboa/examples/closed_orbit.py
18 Create a tracking object. This tracking object uses a list of matrices to
19 generate tracking. The tracking goes like
20 - x is a conventional phase space ellipse
21 - y has phase advance of exactly pi
22 - t has phase advance is complex i.e. on a resonance.
23 Each cell or turn we advance through another transfer matrix. The closed
24 orbit is generated by a hard coded offset.
26 Return value is a tuple consisting of a hit object on the closed_orbit and
27 a tracking object that will propagate hit objects through the matrices.
33 data = [[1.0, 0.5, 0.0, 0.0, 0.0, 0.0],
34 [-0.5, 0.75, 0.0, 0.0, 0.0, 0.0],
35 [0.0, 0.0, 0.0, -1.0, 0.0, 0.0],
36 [0.0, 0.0, 1.0, 0.0, 0.0, 0.0],
37 [0.0, 0.0, 0.0, 0.0, 2.0, 2.0],
38 [0.0, 0.0, 0.0, 0.0, 2.0, 2.5]]
39 matrix = numpy.matrix(data)
40 matrix_list = [matrix**(i+1)
for i
in range(number_of_turns)]
41 offset = numpy.matrix([10., 7., 0., 0., 0., 1000.])
42 offset_list = [offset]*number_of_turns
43 offset_in = numpy.matrix([10., 7., 0., 0., 0., 1000.])
44 tracking = MatrixTracking(matrix_list,
47 closed_orbit_hit = Hit.new_from_dict({
'x':10.,
'px':7.,
'energy':1000.,
48 'pid':2212,
'mass':common.pdg_pid_to_mass[2212]},
50 return closed_orbit_hit, tracking
55 Find the closed orbit in x and y
58 We start with a hit displaced from the closed orbit by 1 mm in x and y,
59 track it through the lattice and examine the output, try to fit an ellipse
60 to the output. The iteration finishes if either the signal noise is larger
61 than the ellipse, we reach the numerical precision limit of the numpy
62 library or we reach the maximum number of iterations (default 100).
65 test_hit = closed_orbit_hit
68 co_finder = EllipseClosedOrbitFinder(tracking, test_hit)
69 co_generator = co_finder.find_closed_orbit_generator([
"x",
"x'"],
73 for i, my_co
in enumerate(co_generator):
75 canvas, hist, ellipse, graph = my_co.plot_ellipse(
77 "mm",
"", canvas=canvas)
79 if __name__ ==
"__main__":