Skip to content

Commit fb2035d

Browse files
committed
Check tunes against transfer matrix
1 parent 12cc93a commit fb2035d

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

examples/Diagnostics/Tunes/test_tune.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,19 @@
153153
"action_y",
154154
]
155155
)
156-
print(particles.iloc[:, 6:])
156+
print(particles.iloc[:, 6:])
157+
158+
# Check against tune from transfer matrix
159+
tune_x_true = lattice_params["fractional tune x"]
160+
tune_y_true = lattice_params["fractional tune y"]
161+
tune_x_pred = np.mean(phase_data["tune_x"])
162+
tune_y_pred = np.mean(phase_data["tune_y"])
163+
164+
tune_x_err = tune_x_pred - tune_x_true
165+
tune_y_err = tune_y_pred - tune_y_true
166+
167+
print("tune_x_err", tune_x_err)
168+
print("tune_y_err", tune_y_err)
169+
170+
assert np.abs(tune_x_err) < 1.00e-08
171+
assert np.abs(tune_y_err) < 1.00e-08

examples/Diagnostics/Tunes/test_tune_4d_uncoupled.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,19 @@ def build_norm_matrix_from_twiss_2d(alpha: float, beta: float) -> np.ndarray:
156156
"action_2",
157157
]
158158
)
159-
print(particles.iloc[:, 6:])
159+
print(particles.iloc[:, 6:])
160+
161+
# Check against tune from transfer matrix
162+
tune_x_true = lattice_params["fractional tune x"]
163+
tune_y_true = lattice_params["fractional tune y"]
164+
tune_x_pred = np.mean(phase_data["tune_x"])
165+
tune_y_pred = np.mean(phase_data["tune_y"])
166+
167+
tune_x_err = tune_x_pred - tune_x_true
168+
tune_y_err = tune_y_pred - tune_y_true
169+
170+
print("tune_x_err", tune_x_err)
171+
print("tune_y_err", tune_y_err)
172+
173+
assert np.abs(tune_x_err) < 1.00e-08
174+
assert np.abs(tune_y_err) < 1.00e-08

0 commit comments

Comments
 (0)