beam_calculation.envelope_1d.envelope_1d module

Define class to compute beam propagation in envelope, 1D, no space-charge.

This solver is fast, but should not be used at low energies.

class Envelope1D(*, flag_phi_abs: bool, flag_cython: bool, n_steps_per_cell: int, method: Literal['RK4', 'leaprog'], out_folder: Path | str, default_field_map_folder: Path | str, phi_s_definition: Literal['historical'] = 'historical')

Bases: BeamCalculator

The fastest beam calculator, adapted to high energies.

__init__(*, flag_phi_abs: bool, flag_cython: bool, n_steps_per_cell: int, method: Literal['RK4', 'leaprog'], out_folder: Path | str, default_field_map_folder: Path | str, phi_s_definition: Literal['historical'] = 'historical') None

Set the proper motion integration function, according to inputs.

_abc_impl = <_abc._abc_data object>
_adapt_cavity_settings(field_map: FieldMap, cavity_settings: CavitySettings, phi_bunch_abs: float, w_kin_in: float) dict[str, Callable | int | float]

Format the given CavitySettings for current solver.

For the transfer matrix function of Envelope1D, we need a dictionary.

_compute_cavity_parameters(results: dict) tuple[float, float]

Compute the cavity parameters by calling _phi_s_func().

Parameters:

results – The dictionary of results as returned by the transfer matrix function wrapper.

Returns:

Accelerating voltage in MV and synchronous phase in radians. If the cavity is failed, two np.nan are returned.

Return type:

tuple[float, float]

_post_treat_cavity_settings(cavity_settings: CavitySettings, results: dict) None

Compute synchronous phase and accelerating field.

_set_up_specific_factories() None

Set up the factories specific to the BeamCalculator.

This method is called in the super().__post_init__(), hence it appears only in the base BeamCalculator.

init_solver_parameters(accelerator: Accelerator) None

Create the number of steps, meshing, transfer functions for elts.

The solver parameters are stored in Element.beam_calc_param.

Parameters:

accelerator (Accelerator) – Object which ListOfElements must be initialized.

property is_a_3d_simulation: bool

Return False.

property is_a_multiparticle_simulation: bool

Return False.

post_optimisation_run_with_this(optimized_cavity_settings: SetOfCavitySettings, full_elts: ListOfElements, **specific_kwargs) SimulationOutput

Run :class:`Envelope1D. with optimized cavity settings.

With this solver, we have nothing to do, nothing to update. Just call the regular run_with_this() method.

run(elts: ListOfElements, update_reference_phase: bool = False, **kwargs) SimulationOutput

Compute beam propagation in 1D, envelope calculation.

Parameters:
  • elts (ListOfElements) – List of elements in which the beam must be propagated.

  • update_reference_phase (bool, optional) – To change the reference phase of cavities when it is different from the one asked in the .toml. To use after the first calculation, if BeamCalculator.flag_phi_abs does not correspond to CavitySettings.reference. The default is False.

Returns:

simulation_output – Holds energy, phase, transfer matrices (among others) packed into a single object.

Return type:

SimulationOutput

run_with_this(set_of_cavity_settings: SetOfCavitySettings | None, elts: ListOfElements, use_a_copy_for_nominal_settings: bool = True) SimulationOutput

Use solver on elts, including the set_of_cavity_settings.

Parameters:
  • set_of_cavity_settings (SetOfCavitySettings | None) – The new cavity settings to try. If it is None, then the cavity settings are taken from the FieldMap objects.

  • elts (ListOfElements) – List of elements in which the beam must be propagated.

  • use_a_copy_for_nominal_settings (bool, optional) – To copy the nominal CavitySettings and avoid altering their nominal counterpart. Set it to True during optimisation, to False when you want to keep the current settings. The default is True.

Returns:

simulation_output – Holds energy, phase, transfer matrices (among others) packed into a single object.

Return type:

SimulationOutput