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, n_steps, beam_kwargs, transf_mat_function=None, **kwargs)[source]

Bases: ElementEnvelope1DParameters

Hold the parameters to compute beam propagation in an Element.

has and get method inherited from ElementCalculatorParameters parent class.

Parameters:
__init__(length_m, n_steps, beam_kwargs, transf_mat_function=None, **kwargs)[source]

Save useful parameters as attribute.

Parameters:
  • length_m (float) – Length of elemet in \(\mathrm{m}\).

  • n_steps (int) – Number of solver steps.

  • beam_kwargs (BeamKwargs) – Configuration dict holding initial beam parameters.

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

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.

Return type:

dict[str, Any]

_transfer_matrix_results_to_dict(transfer_matrix, gamma_phi, integrated_field)[source]

Convert the results given by the transf_mat function to dict.

Parameters:
Return type:

dict

_proper_transfer_matrix_func(element_nature, method=None)[source]

Get the proper transfer matrix function.

Parameters:
  • element_nature (str)

  • method (str | None, default: None)

Return type:

Callable

_abc_impl = <_abc._abc_data object at 0x7c8f66b15b80>
class DriftEnvelope3DParameters(elt, beam_kwargs, n_steps=1, **kwargs)[source]

Bases: ElementEnvelope3DParameters

Hold the properties to compute transfer matrix of a Drift.

Parameters:
__init__(elt, beam_kwargs, n_steps=1, **kwargs)[source]

Create the specific parameters for a drift.

Parameters:
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.

Return type:

dict[str, Any]

_abc_impl = <_abc._abc_data object at 0x7c8f6a293240>
class QuadEnvelope3DParameters(elt, beam_kwargs, n_steps=1, **kwargs)[source]

Bases: ElementEnvelope3DParameters

Hold the properties to compute transfer matrix of a Quad.

Parameters:
__init__(elt, beam_kwargs, n_steps=1, **kwargs)[source]

Create the specific parameters for a drift.

Parameters:
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.

Return type:

dict[str, Any]

_abc_impl = <_abc._abc_data object at 0x7c8f699b9e80>
class SolenoidEnvelope3DParameters(elt, beam_kwargs, n_steps=1, **kwargs)[source]

Bases: ElementEnvelope3DParameters

Hold properties to compute transfer matrix of a Solenoid.

Parameters:
__init__(elt, beam_kwargs, n_steps=1, **kwargs)[source]

Create the specific parameters for a drift.

Parameters:
Return type:

None

_abc_impl = <_abc._abc_data object at 0x7c8f699ba500>
class FieldMapEnvelope3DParameters(elt, method, n_steps_per_cell, solver_id, beam_kwargs, phi_s_model='historical', **kwargs)[source]

Bases: ElementEnvelope3DParameters

Hold the properties to compute transfer matrix of a FieldMap.

Non-accelerating cavities will use DriftEnvelope3DParameters instead.

Parameters:
__init__(elt, method, n_steps_per_cell, solver_id, beam_kwargs, phi_s_model='historical', **kwargs)[source]

Create the specific parameters for a drift.

Parameters:
Return type:

None

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

Return type:

dict[str, Any]

Returns:

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

_transfer_matrix_results_to_dict(transfer_matrix, gamma_phi, integrated_field)[source]

Convert the results given by the transf_mat function to dict.

Overrides the default method defined in the ABC.

Parameters:
Return type:

dict

re_set_for_broken_cavity()[source]

Make beam calculator call Drift func instead of FieldMap.

Return type:

Callable

_broken_transfer_matrix_results_to_dict(transfer_matrix, gamma_phi, integrated_field)[source]

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

Parameters:
Return type:

dict

_broken_transfer_matrix_kw(*args, **kwargs)[source]

Give the element parameters necessary to compute transfer matrix.

Return type:

dict[str, Any]

_abc_impl = <_abc._abc_data object at 0x7c8f68117600>
_get_phi_0_rel(cavity_settings)[source]

Get the phase from the object.

Parameters:

cavity_settings (CavitySettings)

Return type:

float

class BendEnvelope3DParameters(elt, beam_kwargs, n_steps=1, **kwargs)[source]

Bases: ElementEnvelope3DParameters

Hold specific parameters to compute Bend transfer matrix.

Parameters:
__init__(elt, beam_kwargs, n_steps=1, **kwargs)[source]

Instantiate object and pre-compute some parameters for speed.

Parameters:
  • transf_mat_module – Module where the transfer matrix function is defined.

  • elt (Bend) – BEND element.

  • kwargs (str) – kwargs

  • beam_kwargs (BeamKwargs)

  • n_steps (int, default: 1)

_abc_impl = <_abc._abc_data object at 0x7c8f67e19440>
_add_cavity_phase(solver_id, w_kin_in, cavity_settings, rf_kwargs)[source]

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

Parameters:
Return type:

None