Skip to content

Commit 16a5bb4

Browse files
committed
Python Twiss Helper: mean & dispersion
Simplify usage & pick-up in dashboard. Straight forwarding of mean and dispersion parameters.
1 parent 427c63a commit 16a5bb4

4 files changed

Lines changed: 33 additions & 3 deletions

File tree

examples/dogleg/run_dogleg_reverse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
alpha_x=1.3385830279518021,
4141
alpha_y=-1.3479109197361046,
4242
alpha_t=92.624347459169869,
43+
dispersion_x=-0.26669723385388505,
4344
),
44-
dispX=-0.26669723385388505,
4545
)
4646
sim.add_particles(bunch_charge_C, distr, npart)
4747

examples/htu_beamline/run_impactx_offenergy1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
alpha_x=0.0,
6767
alpha_y=0.0,
6868
alpha_t=0.0,
69+
mean_pt=-mu_p,
6970
),
70-
meanPt=-mu_p,
7171
)
7272
sim.add_particles(bunch_charge_C, distr, npart)
7373

examples/htu_beamline/run_impactx_offenergy2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
alpha_x=0.0,
6767
alpha_y=0.0,
6868
alpha_t=0.0,
69+
mean_pt=-mu_p,
6970
),
70-
meanPt=-mu_p,
7171
)
7272
sim.add_particles(bunch_charge_C, distr, npart)
7373

src/python/impactx/distribution_input_helpers.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ def twiss(
1919
alpha_x: numpy.float64 = 0.0,
2020
alpha_y: numpy.float64 = 0.0,
2121
alpha_t: numpy.float64 = 0.0,
22+
mean_x: numpy.float64 = 0.0,
23+
mean_y: numpy.float64 = 0.0,
24+
mean_t: numpy.float64 = 0.0,
25+
mean_px: numpy.float64 = 0.0,
26+
mean_py: numpy.float64 = 0.0,
27+
mean_pt: numpy.float64 = 0.0,
28+
dispersion_x: numpy.float64 = 0.0,
29+
dispersion_y: numpy.float64 = 0.0,
30+
dispersion_px: numpy.float64 = 0.0,
31+
dispersion_py: numpy.float64 = 0.0,
2232
):
2333
"""
2434
Helper function to convert Courant-Snyder / Twiss input into phase space ellipse input.
@@ -32,6 +42,16 @@ def twiss(
3242
:param alpha_x: Alpha function value () in the x dimension, default is 0.0.
3343
:param alpha_y: Alpha function value in the y dimension, default is 0.0.
3444
:param alpha_t: Alpha function value in the t dimension, default is 0.0.
45+
:param mean_x: offset of the mean (centroid) position in x from that of the reference particle
46+
:param mean_y: offset of the mean (centroid) position in y from that of the reference particle
47+
:param mean_t: offset of the mean (centroid) position in t from that of the reference particle
48+
:param mean_px: offset of the mean (centroid) momentum in x from that of the reference particle
49+
:param mean_py: offset of the mean (centroid) momentum in y from that of the reference particle
50+
:param mean_pt: offset of the mean (centroid) momentum in t from that of the reference particle
51+
:param dispersion_x: dispersion and its derivative in horizontal and vertical directions
52+
:param dispersion_y: dispersion and its derivative in horizontal and vertical directions
53+
:param dispersion_px: dispersion and its derivative in horizontal and vertical directions
54+
:param dispersion_py: dispersion and its derivative in horizontal and vertical directions
3555
:return: A dictionary containing calculated phase space input: 'lambdaX', 'lambdaY', 'lambdaT', 'lambdaPx', 'lambdaPy', 'lambdaPt', 'muxpx', 'muypy', 'mutpt'.
3656
"""
3757
import numpy as np
@@ -65,4 +85,14 @@ def twiss(
6585
"muxpx": alpha_x / np.sqrt(beta_x * gamma_x),
6686
"muypy": alpha_y / np.sqrt(beta_y * gamma_y),
6787
"mutpt": alpha_t / np.sqrt(beta_t * gamma_t),
88+
"meanX": mean_x,
89+
"meanY": mean_y,
90+
"meanT": mean_t,
91+
"meanPx": mean_px,
92+
"meanPy": mean_py,
93+
"meanPt": mean_pt,
94+
"dispX": dispersion_x,
95+
"dispY": dispersion_y,
96+
"dispPx": dispersion_px,
97+
"dispPy": dispersion_py,
6898
}

0 commit comments

Comments
 (0)