transfer_matrices_p module
Define every element transfer matrix.
Units are taken exactly as in TraceWin, i.e. fifth line is z (m) and
sixth line is dp/p.
Todo
3D field maps?
Todo
Maybe it would be clearer to compose r_xx, r_yy, r_zz. As an example, the zz_drift is used in several places.
Todo
Will be necessary to separate this module into several sub-packages
Todo
more math, less numpy. look at envelope 1d version
- e_func(z, e_spat, phi, phi_0)[source]
Give the electric field at position z and phase phi.
The field is normalized and should be multiplied by k_e.
- drift(gamma_in, delta_s, omega_0_bunch, n_steps=1, **kwargs)[source]
Calculate the transfer matrix of a drift.
- Parameters:
gamma_in (float) – Lorentz gamma at entry of drift.
delta_s (float) – Size of the drift in mm.
omega_0_bunch (float) – Pulsation of the beam.
n_steps (int, optional) – Number of integration steps. The number of integration steps has no influence on the results. The default is one. It is different from unity when crossing a failed field map, as it allows to keep the same size of
transfer_matrixandgamma_phibetween nominal and fixed linacs.
- Return type:
- Returns:
transfer_matrix (np.ndarray) – (n_steps, 6, 6) array containing the transfer matrices.
gamma_phi (numpy.ndarray) – (n_steps, 2) with Lorentz gamma in first column and relative phase in second column.
itg_field (None) – Dummy variable for consistency with the field map function.
- quad(gamma_in, delta_s, gradient, omega_0_bunch, q_adim, e_rest_mev, **kwargs)[source]
Calculate the transfer matrix of a quadrupole.
- Parameters:
delta_s (float) – Size of the drift in m.
gamma_in (float) – Lorentz gamma at entry of drift.
n_steps (int, optional) – Number of integration steps. The number of integration steps has no influence on the results. The default is one. It is different from unity when crossing a failed field map, as it allows to keep the same size of
transfer_matrixandgamma_phibetween nominal and fixed linacs.gradient (float) – Quadrupole gradient in T/m.
omega_0_bunch (float) – Pulsation of the beam.
q_adim (float) – Adimensioned charge of accelerated particle.
e_rest_mev (float) – Rest energy of the accelerated particle.
- Return type:
- Returns:
transfer_matrix (np.ndarray) – (1, 6, 6) array containing the transfer matrices.
gamma_phi (numpy.ndarray) – (1, 2) with Lorentz gamma in first column and relative phase in second column.
itg_field (None) – Dummy variable for consistency with the field map function.
- _horizontal_focusing_quadrupole(focusing_strength, delta_s, gamma_in_min2)[source]
Transfer matrix of a quadrupole focusing in horizontal plane.
- _horizontal_defocusing_quadrupole(focusing_strength, delta_s, gamma_in_min2)[source]
Transfer matrix of a quadrupole defocusing in horizontal plane.
- field_map_rk4(gamma_in, d_z, n_steps, omega0_rf, k_e, phi_0_rel, e_spat, q_adim, inv_e_rest_mev, omega_0_bunch, **kwargs)[source]
Calculate the transfer matrix of a FIELD_MAP using Runge-Kutta.
- thin_lense(gamma_in, gamma_out, gamma_phi_m, half_dz, delta_gamma_m_max, phi_0, omega0_rf, delta_e_max, omega_0_bunch)[source]
Thin lense approximation: drift-acceleration-drift.
- Parameters:
gamma_in (float) – gamma at entrance of first drift.
gamma_out (float) – gamma at exit of first drift.
gamma_phi_m (numpy.ndarray) – gamma and phase at the thin acceleration drift.
half_dz (float) – Half a spatial step in m.
delta_gamma_m_max (float) – Max gamma increase if the cos(phi + phi_0) of the acc. field is 1.
phi_0 (float) – Input phase of the cavity.
omega0_rf (float) – Pulsation of the cavity.
delta_e_max (float) – Derivative of the electric field.
omega_0_bunch (float) – Pulsation of the beam.
- Returns:
transfer_matrix – Transfer matrix of the thin lense.
- Return type:
- _magnetic_rigidity(beta, gamma, e_rest_mev, **kwargs)[source]
Compute magnetic rigidity of particle.
- _focusing_strength(gradient, magnetic_rigidity)[source]
Compute focusing strength of the quadrupole.