Skip to content

Commit f6cf822

Browse files
committed
Python Twiss Helper: mean & dispersion
Simplify usage & pick-up in dashboard. Straight forwarding of mean and dispersion parameters.
1 parent 669d852 commit f6cf822

2 files changed

Lines changed: 31 additions & 1 deletion

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+
dispX=-0.26669723385388505,
4344
),
44-
dispX=-0.26669723385388505,
4545
)
4646
sim.add_particles(bunch_charge_C, distr, npart)
4747

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: np.float64 = 0.0,
2020
alpha_y: np.float64 = 0.0,
2121
alpha_t: np.float64 = 0.0,
22+
meanX: np.float64 = 0.0,
23+
meanY: np.float64 = 0.0,
24+
meanT: np.float64 = 0.0,
25+
meanPx: np.float64 = 0.0,
26+
meanPy: np.float64 = 0.0,
27+
meanPt: np.float64 = 0.0,
28+
dispX: np.float64 = 0.0,
29+
dispY: np.float64 = 0.0,
30+
dispPx: np.float64 = 0.0,
31+
dispPy: np.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 meanX: offset of the mean (centroid) position in x from that of the reference particle
46+
:param meanY: offset of the mean (centroid) position in y from that of the reference particle
47+
:param meanT: offset of the mean (centroid) position in t from that of the reference particle
48+
:param meanPx: offset of the mean (centroid) momentum in x from that of the reference particle
49+
:param meanPy: offset of the mean (centroid) momentum in y from that of the reference particle
50+
:param meanPt: offset of the mean (centroid) momentum in t from that of the reference particle
51+
:param dispX: dispersion and its derivative in horizontal and vertical directions
52+
:param dispY: dispersion and its derivative in horizontal and vertical directions
53+
:param dispPx: dispersion and its derivative in horizontal and vertical directions
54+
:param dispPy: 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
if beta_x <= 0.0 or beta_y <= 0.0 or beta_t <= 0.0:
@@ -63,4 +83,14 @@ def twiss(
6383
"muxpx": alpha_x / np.sqrt(beta_x * gamma_x),
6484
"muypy": alpha_y / np.sqrt(beta_y * gamma_y),
6585
"mutpt": alpha_t / np.sqrt(beta_t * gamma_t),
86+
"meanX": meanX,
87+
"meanY": meanY,
88+
"meanT": meanT,
89+
"meanPx": meanPx,
90+
"meanPy": meanPy,
91+
"meanPt": meanPt,
92+
"dispX": dispX,
93+
"dispY": dispY,
94+
"dispPx": dispPx,
95+
"dispPy": dispPy,
6696
}

0 commit comments

Comments
 (0)