Source code for lightwin.beam_calculation.simulation_output.factory

"""Define a class to easily generate the |SO|.

This class should be subclassed by every |BC| to match its own specific
outputs.

"""

from abc import ABC, ABCMeta, abstractmethod

from lightwin.beam_calculation.simulation_output.simulation_output import (
    SimulationOutput,
)
from lightwin.core.list_of_elements.list_of_elements import ListOfElements
from lightwin.util.typing import BeamKwargs, CavParams


[docs] class SimulationOutputFactory(ABC): """A base class for creation of |SO|.""" _is_3d: bool
[docs] def __init__( self, is_multipart: bool, beam_calculator_id: str, beam_kwargs: BeamKwargs, ) -> None: """Create the object. Parameters ---------- is_multipart : If |SO| are obtained with a multiparticle solver. beam_calculator_id : ID of solver that created this object. Also used as the name of the subdirectory where results should be saved. Typically, ``"0_Envelope1D"`` or ``"1_TraceWin"``. beam_kwargs : Beam properties. """ self._is_multipart = is_multipart self._beam_calculator_id = beam_calculator_id self._beam_kwargs = beam_kwargs self.transfer_matrix_factory = self._transfer_matrix_factory_class( self._is_3d ) self.beam_parameters_factory = self._beam_parameters_factory_class( self._is_3d, self._is_multipart, beam_kwargs=self._beam_kwargs, )
@property @abstractmethod def _transfer_matrix_factory_class(self) -> ABCMeta: """Declare the **class** of the transfer matrix factory.""" @property @abstractmethod def _beam_parameters_factory_class(self) -> ABCMeta: """Declare the **class** of the beam parameters factory."""
[docs] @abstractmethod def create( self, accelerator_id: str, elts: ListOfElements, *args, **kwargs ) -> SimulationOutput: """Create the |SO|.""" pass
[docs] @abstractmethod def _get_cav_params(self, *args, **kwargs) -> CavParams: """Load and format a dict containing cavity parameters."""