Twiss Optics¶
Main Classes Twiss Optics¶
Module twiss_optics.optics_class¶
Provides Classes to calculate optics from twiss parameters.
The calculation is based on formulas in [1] and [2].
Only works properly for on-orbit twiss files.
References
[1] | M. Aiba et al., First simultaneous measurement of sextupolar and octupolar resonance driving terms in a circular accelerator from turn-by-turn beam position monitor data, Phys. Rev. ST Accel. Beams 17, 074001 (2014). https://journals.aps.org/prab/pdf/10.1103/PhysRevSTAB.17.074001 |
[2] | (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) A. Franchi et al., Analytic formulas for the rapid evaluation of the orbit response matrix and chromatic functions from lattice parameters in circular accelerators https://arxiv.org/abs/1711.06589 |
[3] | (1, 2) R. Calaga et al., ‘Betatron coupling: Merging Hamiltonian and matrix approaches’ Phys. Rev. ST Accel. Beams, vol. 8, no. 3, p. 034001, Mar. 2005. |
-
class
twiss_optics.optics_class.
TwissOptics
(model_path_or_df, quick_init=True)[source]¶ Class for calculating optics parameters from twiss-model.
Parameters: - model_path_or_df -- Path to twissfile of model or DataFrame of model.
- quick_init -- Initializes without calculating phase advances. Default: False
-
calc_ac_dipole_driving_terms
(order_or_terms, spectral_line, plane, ac_tunes, acd_name)[source]¶ Calculates the Hamiltonian Terms under Forced Motion.
Parameters: - order_or_terms -- int, string or list of strings If an int is given all Resonance Driving Terms up to this order will be calculated. The strings are assumed to be the desired driving term names, e.g. “F1001”
- spectral_line -- tuple Needed to determine what phase advance is needed before and after AC dipole location, depends on detal+ and delta-. Sample input: (2,-1)
- plane -- string Either ‘H’ or ‘V’ to determine phase term of AC dipole before and after ACD location.
- ac_tunes -- tuple Contains horizontal and vertical AC dipole tunes, i.e. (0.302, 0.33)
-
calc_rdts
(order_or_rdts)[source]¶ Calculates the Resonance Driving Terms.
Eq. A8 in [2]
Parameters: order_or_rdts -- int, string or list of strings If an int is given all Resonance Driving Terms up to this order will be calculated. The strings are assumed to be the desired driving term names, e.g. “F1001”
-
get_chromatic_beating
()[source]¶ Return the Chromatic Beating
Available after calc_chromatic_beating
-
get_coupling
(method='rdt')[source]¶ Returns the coupling term.
Warning
This function changes sign of the real part of the RDTs compared to [2] to be consistent with the RDT calculations from [3] .
Parameters: method -- ‘rdt’ - Returns the values calculated by calc_rdts() ‘cmatrix’ - Returns the values calculated by calc_cmatrix()
-
get_linear_chromaticity
()[source]¶ Return the Linear Chromaticity
Available after calc_linear_chromaticity
-
get_linear_dispersion
()[source]¶ Return the Linear Dispersion.
Available after calc_linear_dispersion!
-
plot_chromatic_beating
(combined=True)[source]¶ Plot the Chromatic Beating
Available after calc_chromatic_beating
Parameters: combined (bool) -- If ‘True’ plots x and y into the same axes.
-
plot_linear_dispersion
(combined=True)[source]¶ Plot the Linear Dispersion.
Available after calc_linear_dispersion!
Parameters: combined (bool) -- If ‘True’ plots x and y into the same axes.
Helpers Twiss Optics¶
Module twiss_optics.twiss_functions¶
Common Functions not attached to any class in this module.
-
twiss_optics.twiss_functions.
dphi
(data, q)[source]¶ Return dphi from phase advances in data, see Eq. 8 in [2]
-
twiss_optics.twiss_functions.
get_all_rdts
(n)[source]¶ Returns list of all valid RDTs of order 2 to n
-
twiss_optics.twiss_functions.
get_phase_advances
(twiss_df)[source]¶ Calculate phase advances between all elements
Returns: Matrices similar to DPhi(i,j) = Phi(j) - Phi(i)
-
twiss_optics.twiss_functions.
rdt_generator
(orders, normal=True, skew=True, complex_conj=True)[source]¶ Generates lists of RDT-4-tuples sorted into a dictionary by order.
Parameters: - orders (list) -- list of orders to be generated. Orders < 2 raise errors.
- normal (bool) -- calculate normal RDTs (default: True)
- skew (bool) -- calculate skew RDTs (default: True)
- complex_conj (bool) -- Have both, RDT and it’s complex conjugate RDT in the list (default: True)
Returns: Dictionary with keys of orders containing lists of 4-Tuples for the RDTs of that order.