element_envelope1d_parameters module
Define a class to hold solver parameters for Envelope1D.
This module holds ElementEnvelope1DParameters, that inherits
from the Abstract Base Class ElementBeamCalculatorParameters.
It holds the transfer matrix function that is used, according to the solver
(Runge-Kutta or leapfrog) and their version (Python or Cython), as well as the
meshing in accelerating elements.
The Element objects with a transfer matrix are DRIFT, SOLENOID, QUAD,
FIELD_MAP, BEND.
- class ElementEnvelope1DParameters(length_m, n_steps, beam_kwargs, transf_mat_function=None, **kwargs)[source]
Bases:
ElementBeamCalculatorParametersHold the parameters to compute beam propagation in an Element.
hasandgetmethod inherited fromElementBeamCalculatorParametersparent class.- Parameters:
- __init__(length_m, n_steps, beam_kwargs, transf_mat_function=None, **kwargs)[source]
Set the actually useful parameters.
- set_absolute_meshes(pos_in, s_in)[source]
Set the absolute indexes and arrays, depending on previous elem.
- abstractmethod transfer_matrix_kw(*args, **kwargs)[source]
Give the element parameters necessary to compute transfer matrix.
The only missing argument is
gamma_in, as it does not convern the element directly.
- transf_mat_function_wrapper(w_kin, phi_0_rel=None, cavity_settings=None, **kwargs)[source]
Calculate beam propagation in the
Element.
- _transfer_matrix_results_to_dict(r_zz, gamma_phi, integrated_field)[source]
Convert the results given by the transf_mat function to dict.
- _proper_transfer_matrix_func(element_nature, method=None)[source]
Get the proper transfer matrix function.
- _abc_impl = <_abc._abc_data object at 0x7318fb2b9900>
- class DriftEnvelope1DParameters(elt, beam_kwargs, n_steps=1, **kwargs)[source]
Bases:
ElementEnvelope1DParametersHold the properties to compute transfer matrix of a
Drift.As this is 1D, it is also used for
Solenoid,Quad, brokenFieldMap.- Parameters:
elt (
Element)beam_kwargs (
BeamKwargs)n_steps (
int, default:1)
- __init__(elt, beam_kwargs, n_steps=1, **kwargs)[source]
Create the specific parameters for a drift.
- Parameters:
elt (
Element)beam_kwargs (
BeamKwargs)n_steps (
int, default:1)
- Return type:
None
- transfer_matrix_kw(*args, **kwargs)[source]
Give the element parameters necessary to compute transfer matrix.
The only missing argument is
gamma_in, as it does not convern the element directly.
- _abc_impl = <_abc._abc_data object at 0x7318fb2fe300>
- class FieldMapEnvelope1DParameters(elt, method, n_steps_per_cell, solver_id, beam_kwargs, phi_s_model='historical', **kwargs)[source]
Bases:
ElementEnvelope1DParametersHold the properties to compute transfer matrix of a
FieldMap.Non-accelerating cavities will use
DriftEnvelope1DParametersinstead.- Parameters:
- __init__(elt, method, n_steps_per_cell, solver_id, beam_kwargs, phi_s_model='historical', **kwargs)[source]
Create the specific parameters for a field map.
- transfer_matrix_kw(w_kin, cavity_settings, *args, phi_0_rel=None, **kwargs)[source]
Give the element parameters necessary to compute transfer matrix.
- Parameters:
w_kin (
float) – Kinetic energy at the entrance of cavity in \(\mathrm{MeV}\).cavity_settings (
CavitySettings) – Object holding the cavity parameters that can be changed.phi_0_rel (
float|None, default:None) – Relative entry phase of the cavity. When provided, it means that we are trying to find the \(\phi_{0,\,\mathrm{rel}}\) matching a given \(\phi_s\).
- Return type:
- Returns:
Keyword arguments that will be passed to the 1D transfer matrix function defined in
envelope_1d.transfer_matrices.
- _transfer_matrix_results_to_dict(r_zz, gamma_phi, integrated_field)[source]
Convert the results given by the transf_mat function to a dict.
Overrides the default method defined in the ABC.
- re_set_for_broken_cavity()[source]
Make beam calculator call Drift func instead of FieldMap.
- Return type:
- _broken_transfer_matrix_results_to_dict(r_zz, gamma_phi, integrated_field)[source]
Convert the results given by the transf_mat function to a dict.
- _broken_transfer_matrix_kw(*args, **kwargs)[source]
Give the element parameters necessary to compute transfer matrix.
- _abc_impl = <_abc._abc_data object at 0x7318faa67f00>
- _get_phi_0_rel(cavity_settings)[source]
Get the phase from the object.
- Parameters:
cavity_settings (
CavitySettings)- Return type:
- class SuperposedFieldMapEnvelope1DParameters(elt, method, n_steps_per_cell, solver_id, beam_kwargs, phi_s_model='historical', **kwargs)[source]
Bases:
ElementEnvelope1DParametersHold properties to compute transfer matrix of
SuperposedFieldMap.- Parameters:
elt (
SuperposedFieldMap)method (
Literal['RK4'])n_steps_per_cell (
int)solver_id (
str)beam_kwargs (
BeamKwargs)phi_s_model (
Literal['historical','lagniel'], default:'historical')
- __init__(elt, method, n_steps_per_cell, solver_id, beam_kwargs, phi_s_model='historical', **kwargs)[source]
Create the specific parameters for a field map.
- Parameters:
elt (
SuperposedFieldMap)method (
Literal['RK4'])n_steps_per_cell (
int)solver_id (
str)beam_kwargs (
BeamKwargs)phi_s_model (
Literal['historical','lagniel'], default:'historical')
- Return type:
None
- transfer_matrix_kw(w_kin, *args, **kwargs)[source]
Give the element parameters necessary to compute transfer matrix.
The only missing argument is
gamma_in, as it does not convern the element directly.
- _transfer_matrix_results_to_dict(r_zz, gamma_phi, integrated_field)[source]
Convert the results given by the transf_mat function to a dict.
Overrides the default method defined in the ABC.
- re_set_for_broken_cavity()[source]
Make beam calculator call Drift func instead of FieldMap.
- Return type:
- _abc_impl = <_abc._abc_data object at 0x7318fc057c40>
- class BendEnvelope1DParameters(elt, beam_kwargs, n_steps=1, **kwargs)[source]
Bases:
ElementEnvelope1DParametersHold the specific parameters to compute
Bendtransfer matrix.In particular, we define
factor_1,factor_2andfactor_3to speed-up calculations.- Parameters:
elt (
Bend)beam_kwargs (
BeamKwargs)n_steps (
int, default:1)
- __init__(elt, beam_kwargs, n_steps=1, **kwargs)[source]
Instantiate object and pre-compute some parameters for speed.
- Parameters:
elt (
Bend) –BENDelement.beam_kwargs (
BeamKwargs) – Configuration dict holding all initial beam properties.n_steps (
int, default:1) – Number of integration steps.
- Return type:
None
- _pre_compute_factors_for_transfer_matrix(length_m, h_squared, k_x, index_is_lower_than_unity)[source]
Compute factors to speed up the transfer matrix calculation.
factor_1is:\[\frac{-h^2\Delta s}{k_x^2}\]factor_2is:\[\frac{h^2 \sin{(k_x\Delta s)}}{k_x^3}\]if \(n \leq 1\). Else:
\[\frac{h^2 \sinh{(k_x\Delta s)}}{k_x^3}\]factor_3is:\[\Delta s \left(1 - \frac{h^2}{k_x^2}\right)\]
- transfer_matrix_kw(*args, **kwargs)[source]
Give the element parameters necessary to compute transfer matrix.
The only missing argument is
gamma_in, as it does not convern the element directly.
- _abc_impl = <_abc._abc_data object at 0x7318fb487c40>
- class DummyEnvelope1DParameters(elt, beam_kwargs, n_steps=1, **kwargs)[source]
Bases:
ElementEnvelope1DParametersCreate dummy arguments for dummy element.
- Parameters:
elt (
Element)beam_kwargs (
BeamKwargs)n_steps (
int, default:1)
- __init__(elt, beam_kwargs, n_steps=1, **kwargs)[source]
Create no specific parameters.
- Parameters:
elt (
Element)beam_kwargs (
BeamKwargs)n_steps (
int, default:1)
- Return type:
None
- transfer_matrix_kw(*args, **kwargs)[source]
Give the element parameters necessary to compute transfer matrix.
The only missing argument is
gamma_in, as it does not convern the element directly.
- _abc_impl = <_abc._abc_data object at 0x7318fb2ff840>