element_envelope3d_parameters module

Define a class to hold solver parameters for Envelope3D.

This module holds ElementEnvelope3DParameters, that inherits from the Abstract Base Class ElementBeamCalculatorParameters. It holds the transfer matrix function that is used, as well as the meshing in accelerating elements.

In a first time, only Runge-Kutta (no leapfrog) and only Python (no Cython).

The list of implemented transfer matrices is PARAMETERS_3D.

class ElementEnvelope3DParameters(length_m: float, n_steps: int, beam_kwargs: dict[str, Any], transf_mat_function: Callable | None = None, **kwargs)

Bases: ElementEnvelope1DParameters

Hold the parameters to compute beam propagation in an Element.

has and get method inherited from ElementCalculatorParameters parent class.

__init__(length_m: float, n_steps: int, beam_kwargs: dict[str, Any], transf_mat_function: Callable | None = None, **kwargs) None

Save useful parameters as attribute.

Parameters:
  • length_m (float) – length_m

  • n_steps (int) – n_steps

  • beam_kwargs (dict[str, Any]) – Configuration dict holding initial beam parameters.

  • transf_mat_function (Callable | None, optional) – Function to compute transfer matrix of element. The default is None, in which case we fall back on Drift transfer matrix.

_transfer_matrix_results_to_dict(transfer_matrix: ndarray, gamma_phi: ndarray, integrated_field: float | None) dict

Convert the results given by the transf_mat function to dict.

_proper_transfer_matrix_func(element_nature: str, method: str | None = None) Callable

Get the proper transfer matrix function.

_abc_impl = <_abc._abc_data object at 0x7f36f8b06440>
class DriftEnvelope3DParameters(elt: Drift | FieldMap, beam_kwargs: dict[str, Any], n_steps: int = 1, **kwargs: str)

Bases: ElementEnvelope3DParameters

Hold the properties to compute transfer matrix of a Drift.

__init__(elt: Drift | FieldMap, beam_kwargs: dict[str, Any], n_steps: int = 1, **kwargs: str) None

Create the specific parameters for a drift.

_abc_impl = <_abc._abc_data object at 0x7f36f8b46440>
class QuadEnvelope3DParameters(elt: Quad, beam_kwargs: dict[str, Any], n_steps: int = 1, **kwargs: str)

Bases: ElementEnvelope3DParameters

Hold the properties to compute transfer matrix of a Quad.

__init__(elt: Quad, beam_kwargs: dict[str, Any], n_steps: int = 1, **kwargs: str) None

Create the specific parameters for a drift.

transfer_matrix_kw(*args, **kwargs) dict[str, Any]

Give the element parameters necessary to compute transfer matrix.

_abc_impl = <_abc._abc_data object at 0x7f36f8b46980>
class SolenoidEnvelope3DParameters(elt: Solenoid, beam_kwargs: dict[str, Any], n_steps: int = 1, **kwargs: str)

Bases: ElementEnvelope3DParameters

Hold properties to compute transfer matrix of a Solenoid.

__init__(elt: Solenoid, beam_kwargs: dict[str, Any], n_steps: int = 1, **kwargs: str) None

Create the specific parameters for a drift.

_abc_impl = <_abc._abc_data object at 0x7f36f8b46a00>
class FieldMapEnvelope3DParameters(elt: FieldMap, method: str, n_steps_per_cell: int, solver_id: str, beam_kwargs: dict[str, Any], phi_s_model: Literal['historical', 'lagniel'] = 'historical', **kwargs: str)

Bases: ElementEnvelope3DParameters

Hold the properties to compute transfer matrix of a FieldMap.

Non-accelerating cavities will use DriftEnvelope3DParameters instead.

__init__(elt: FieldMap, method: str, n_steps_per_cell: int, solver_id: str, beam_kwargs: dict[str, Any], phi_s_model: Literal['historical', 'lagniel'] = 'historical', **kwargs: str) None

Create the specific parameters for a drift.

transfer_matrix_kw(w_kin: float, cavity_settings: CavitySettings, *args, phi_0_rel: float | None = None, **kwargs) dict[str, Any]

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) – 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\). The default is None.

Returns:

Keyword arguments that will be passed to the 3D transfer matrix function defined in envelope_3d.transfer_matrices_p.

Return type:

dict[str, Any]

_transfer_matrix_results_to_dict(transfer_matrix: ndarray, gamma_phi: ndarray, integrated_field: float | None) dict

Convert the results given by the transf_mat function to dict.

Overrides the default method defined in the ABC.

re_set_for_broken_cavity() Callable

Make beam calculator call Drift func instead of FieldMap.

_broken_transfer_matrix_results_to_dict(transfer_matrix: ndarray, gamma_phi: ndarray, integrated_field: float | None) dict

Convert the results given by the transf_mat function to a dict.

_broken_transfer_matrix_kw(*args, **kwargs) dict[str, Any]

Give the element parameters necessary to compute transfer matrix.

_abc_impl = <_abc._abc_data object at 0x7f36f8b46ac0>
class BendEnvelope3DParameters(elt: Bend, beam_kwargs: dict[str, Any], n_steps: int = 1, **kwargs: str)

Bases: ElementEnvelope3DParameters

Hold specific parameters to compute Bend transfer matrix.

__init__(elt: Bend, beam_kwargs: dict[str, Any], n_steps: int = 1, **kwargs: str)

Instantiate object and pre-compute some parameters for speed.

Parameters:
  • transf_mat_module (types.ModuleType) – Module where the transfer matrix function is defined.

  • elt (Bend) – BEND element.

  • kwargs – kwargs

_abc_impl = <_abc._abc_data object at 0x7f36f8b46b40>
_add_cavity_phase(solver_id: str, w_kin_in: float, cavity_settings: CavitySettings, rf_kwargs: dict[str, Callable | int | float]) None

Set reference phase and function to compute \(\phi_s\).