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: bool, _is_multipart: bool, _solver_id: str)
Bases:
ABCA base class for creation of
SimulationOutput.- __post_init__() None
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().
- 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: ListOfElements, *args, **kwargs) SimulationOutput
Create the
SimulationOutput.
- _generate_element_to_index_func(elts: ListOfElements) Callable[[Element, str | None], int | slice]
Create the func to easily get data at proper mesh index.
- _abc_impl = <_abc._abc_data object at 0x7fd3ce6f7140>
- _element_to_index(_elts: ListOfElements, _shift: int, _solver_id: str, elt: Element | str, pos: Literal['in', 'out'] | None = None, return_elt_idx: bool = False) int | slice
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 of
Elementwhereeltshould be. Must be set by afunctools.partial._shift (int) – Mesh index of first
Element. 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 proper
ElementBeamCalculatorParameters.pos (Literal["in", "out"] | None, optional) – Index of entry or exit of the
Element. If None, return full indexes array. The default is None.return_elt_idx (bool, optional) – If True, the returned index is the position of the element in
_elts.
- Returns:
Index of range of indexes where
eltis.- Return type: