factory module
Define a class to easily generate the SimulationOutput.
This class should be subclassed by every BeamCalculator to match its
own specific outputs.
- class SimulationOutputFactory(_is_3d, _is_multipart, _solver_id, _beam_kwargs)[source]
Bases:
ABCA base class for creation of
SimulationOutput.- Parameters:
_is_3d (
bool)_is_multipart (
bool)_solver_id (
str)_beam_kwargs (
BeamKwargs)
-
_beam_kwargs:
BeamKwargs
- __post_init__()[source]
Create the factories.
The created factories are
TransferMatrixFactoryandBeamParametersFactory. The sub-class that is used is declared in_transfer_matrix_factory_class()and_beam_parameters_factory_class().- Return type:
- abstract property _transfer_matrix_factory_class: ABCMeta
Declare the class of the transfer matrix factory.
- abstract property _beam_parameters_factory_class: ABCMeta
Declare the class of the beam parameters factory.
- abstract run(elts, *args, **kwargs)[source]
Create the
SimulationOutput.- Parameters:
elts (
ListOfElements)- Return type:
- _generate_element_to_index_func(elts)[source]
Create the func to easily get data at proper mesh index.
- Parameters:
elts (
ListOfElements)- Return type:
- __init__(_is_3d, _is_multipart, _solver_id, _beam_kwargs)
- Parameters:
_is_3d (
bool)_is_multipart (
bool)_solver_id (
str)_beam_kwargs (
BeamKwargs)
- _abc_impl = <_abc._abc_data object at 0x70e253aefc40>
- _element_to_index(_elts, _shift, _solver_id, elt, pos=None, return_elt_idx=False, handle_missing_elt=False)[source]
Convert
eltandposinto a mesh index.This way, you can call
get('w_kin', elt='FM5', pos='out')and systematically get the energy at the exit of FM5, whatever theBeamCalculatoror the mesh size is.Todo
different functions, for different outputs. At least, an _element_to_index and a _element_to_indexes. And also a different function for when the index element is desired.
- Parameters:
_elts (
ListOfElements) – List ofElementwhereeltshould be. Must be set by afunctools.partial._shift (
int) – Mesh index of firstElement. Used when the firstElementof_eltsis not the first of theAccelerator. Must be set byfunctools.partial._solver_id (
str) – Name of the solver, to identify and take the properElementBeamCalculatorParameters.pos (
Literal['in','out'] |None, default:None) – Index of entry or exit of theElement. If None, return full indexes array.return_elt_idx (
bool, default:False) – If True, the returned index is the position of the element in_elts.handle_missing_elt (
bool, default:False) – Look for an equivalent element wheneltis not in_elts.
- Returns:
Index of range of indexes where
eltis.- Return type: