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
BeamCalculatorconstructor.
- class BeamCalculatorsFactory(files, beam, **kwargs)[source]
Bases:
objectA class to create
BeamCalculatorobjects.Respects singleton pattern, so that only one factory can be created.
- classmethod reset()[source]
Allow creation of a new factory.
Use this when the
filesor thebeamTOMLconfiguration dicts were updated.- Return type:
- __init__(files, beam, **kwargs)[source]
Set up factory with arguments common to all
BeamCalculator.Note
This object was designed to work with constant
filesandbeam. If those dictionaries happen to change during the execution of the script, executeBeamCalculatorsFactory.reset().Note
This object was designed to work with constant
filesandbeam. If those dictionaries happen to change during the execution of the script, executeBeamCalculatorsFactory.reset().- Parameters:
files (
dict[str,Any]) – Configuration entries for the input/output paths.beam (
BeamKwargs) – Configuration dictionary holding the initial beam parameters.kwargs (
dict) – Other keyword arguments, not used for the moment.
- Return type:
None
- _patch_to_remove_misunderstood_key(beam_calculator_kw)[source]
Patch to remove a key not understood by TraceWin. Declare id list.
Todo
fixme
- run(reference_phase_policy, tool, export_phase, flag_cython=False, force_new=False, **beam_calculator_kw)[source]
Create a single
BeamCalculator.If a
BeamCalculatorwas already created with this factory and with the same arguments, we return it instead of instantiating a new one. Unlessforce_newis set toTrue.If a
BeamCalculatorwas already created with this factory and with the same arguments, we return it instead of instantiating a new one. Unlessforce_newis set toTrue.- Parameters:
reference_phase_policy (
Literal['phi_0_abs','phi_0_rel','phi_s'] |Literal['as_in_original_dat']) – How reference phase ofCavitySettingswill 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 yourFIELD_MAP.flag_cython (
bool, default:False) – If the beam calculator involves loading cython field maps.force_new (
bool, default:False) – To force creation of a newBeamCalculator.
- Return type:
- Returns:
An instance of the proper beam calculator.
- _make_cache_key(reference_phase_policy, tool, export_phase, flag_cython=False, **beam_calculator_kw)[source]
Create unique cache key to avoid re-creating BeamCalculators.
- Parameters:
reference_phase_policy (
Literal['phi_0_abs','phi_0_rel','phi_s'] |Literal['as_in_original_dat'])tool (
Literal['Envelope1D','TraceWin','Envelope3D'])export_phase (
Literal['phi_0_abs','phi_0_rel','phi_s'] |Literal['as_in_original_dat'] |Literal['as_in_settings'])flag_cython (
bool, default:False)
- Return type: