factory module

This module holds a factory to create the BeamCalculator.

BEAM_CALCULATORS = ('Envelope1D', 'TraceWin', 'Envelope3D')
_get_beam_calculator(tool, flag_cython, **kwargs)[source]

Get the proper BeamCalculator constructor.

Parameters:
  • tool (Literal['Envelope1D', 'TraceWin', 'Envelope3D'])

  • flag_cython (bool)

Return type:

type

class BeamCalculatorsFactory(beam_calculator, files, beam, beam_calculator_post=None, **other_kw)[source]

Bases: object

A class to create BeamCalculator objects.

Parameters:
__init__(beam_calculator, files, beam, beam_calculator_post=None, **other_kw)[source]

Set up factory with arguments common to all BeamCalculator.

Parameters:
  • beam_calculator (dict[str, Any]) – Configuration entries for the first BeamCalculator, used for optimisation.

  • files (dict[str, Any]) – Configuration entries for the input/output paths.

  • beam (BeamKwargs) – Configuration dictionary holding the initial beam parameters.

  • beam_calculator_post (dict[str, Any] | None, default: None) – Configuration entries for the second optional BeamCalculator, used for a more thorough calculation of the beam propagation once the compensation settings are found.

  • other_kw (dict) – Other keyword arguments, not used for the moment.

Return type:

None

beam_calculators_id: list[str]
_original_dat_dir: Path
_set_out_folders(all_beam_calculator_kw)[source]

Set in which subfolder the results will be saved.

Parameters:

all_beam_calculator_kw (Sequence[dict[str, Any]])

Return type:

list[Path]

_patch_to_remove_misunderstood_key()[source]

Patch to remove a key not understood by TraceWin. Declare id list.

Todo

fixme

Return type:

None

run(reference_phase_policy, tool, export_phase, flag_cython=False, **beam_calculator_kw)[source]

Create a single BeamCalculator.

Parameters:
  • reference_phase_policy (Literal['phi_0_abs', 'phi_0_rel', 'phi_s'] | Literal['as_in_original_dat']) – How reference phase of CavitySettings will be initialized.

  • tool (Literal['Envelope1D', 'TraceWin', 'Envelope3D']) – The name of the beam calculator to construct.

  • export_phase (Literal['phi_0_abs', 'phi_0_rel', 'phi_s'] | Literal['as_in_original_dat'] | Literal['as_in_settings']) – The type of phase you want to export for your FIELD_MAP.

  • flag_cython (bool, default: False) – If the beam calculator involves loading cython field maps.

Return type:

BeamCalculator

Returns:

An instance of the proper beam calculator.

run_all()[source]

Create all the beam calculators.

Return type:

tuple[BeamCalculator, ...]