Skip to content

Commit a52aeb8

Browse files
committed
new closed_orbit module: add **kwargs for particles...
... such that mass and charge can be changed to other than proton default.
1 parent 0755d6a commit a52aeb8

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

pysixtrack/closed_orbit.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
from .particles import Particles
33

44

5-
def get_init_particles_for_linear_map(closed_orbit, p0c, d, longitudinal_coordinate, longitudinal_momentum):
6-
part = Particles(p0c=p0c)
5+
def get_init_particles_for_linear_map(
6+
closed_orbit, p0c, d, longitudinal_coordinate,
7+
longitudinal_momentum, **kwargs):
8+
part = Particles(p0c=p0c, **kwargs)
79
# part = Particles()
810
# part.p0c = p0c
911
part.x = closed_orbit[0] + np.array([0.0, 1.0 * d, 0.0, 0.0, 0.0, 0.0, 0.0])
@@ -32,20 +34,27 @@ def part_to_array(part, longitudinal_coordinate, longitudinal_momentum):
3234
return X_array
3335

3436

35-
def linearize_around_closed_orbit(line, closed_orbit, p0c, d, longitudinal_coordinate, longitudinal_momentum):
37+
def linearize_around_closed_orbit(
38+
line, closed_orbit, p0c, d, longitudinal_coordinate,
39+
longitudinal_momentum, **kwargs):
3640

37-
part = get_init_particles_for_linear_map(closed_orbit, p0c, d, longitudinal_coordinate, longitudinal_momentum)
38-
X_init = part_to_array(part, longitudinal_coordinate, longitudinal_momentum)
41+
part = get_init_particles_for_linear_map(
42+
closed_orbit, p0c, d, longitudinal_coordinate,
43+
longitudinal_momentum, **kwargs)
44+
X_init = part_to_array(
45+
part, longitudinal_coordinate, longitudinal_momentum)
3946

4047
line.track(part)
41-
X_fin = part_to_array(part, longitudinal_coordinate, longitudinal_momentum)
48+
X_fin = part_to_array(
49+
part, longitudinal_coordinate, longitudinal_momentum)
4250

4351
m = X_fin[:, 0] - X_init[:, 0]
4452
M = np.empty([6, 6])
4553
for j in range(6):
4654
M[:, j] = (X_fin[:, j + 1] - X_fin[:, 0]) / d
4755

48-
X_CO = X_init[:, 0] + np.matmul(np.linalg.inv(np.identity(6) - M), m.T)
56+
X_CO = X_init[:, 0] + np.matmul(
57+
np.linalg.inv(np.identity(6) - M), m.T)
4958

5059
return X_CO, M
5160

@@ -71,7 +80,8 @@ def healy_symplectify(M):
7180
V = np.matmul(S, np.matmul(I - M, np.linalg.inv(I + M)))
7281
W = (V + V.T) / 2
7382
if np.linalg.det(I - np.matmul(S, W)) != 0:
74-
M_new = np.matmul(I + np.matmul(S, W), np.linalg.inv(I - np.matmul(S, W)))
83+
M_new = np.matmul(I + np.matmul(S, W),
84+
np.linalg.inv(I - np.matmul(S, W)))
7585
else:
7686
print("WARNING: det(I - SW) = 0!")
7787
V_else = np.matmul(S, np.matmul(I + M, np.linalg.inv(I - M)))

0 commit comments

Comments
 (0)