factory module
Define a factory for the BeamParameters.
- class BeamParametersFactory(is_3d, is_multipart, beam_kwargs)[source]
Bases:
ABCDeclare factory method, that returns the
BeamParameters.Subclassed by every
BeamCalculator.- Parameters:
is_3d (
bool)is_multipart (
bool)beam_kwargs (
BeamKwargs)
- __init__(is_3d, is_multipart, beam_kwargs)[source]
Initialize the class.
- Parameters:
is_3d (
bool)is_multipart (
bool)beam_kwargs (
BeamKwargs)
- Return type:
None
- abstractmethod factory_method(*args, **kwargs)[source]
Create the
BeamParametersobject.- Return type:
- _check_and_set_arrays(z_abs, gamma_kin)[source]
Ensure that inputs are arrays with proper shape, compute beta.
- _set_from_other_phase_space(beam_parameters, other_phase_space_name, phase_space_names, gamma_kin, beta_kin)[source]
Instantiate a phase space from another one.
- Parameters:
beam_parameters (
BeamParameters) – Object holding the beam parameters in different phase spaces.other_phase_space_name (
Literal['zdelta']) – Name of the phase space from which the new phase space will be initialized.phase_space_names (
Sequence[Literal['phiw','z']]) – Name of the phase spaces that will be created.gamma_kin (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Lorentz gamma factor.beta_kin (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Lorentz beta factor.
- Return type:
- _set_only_emittance(beam_parameters, phase_space_names, emittances)[source]
Set only the emittance.
- _set_from_transfer_matrix(beam_parameters, phase_space_names, transfer_matrices, gamma_kin, beta_kin)[source]
Initialize phase spaces from their transfer matrices.
- Parameters:
beam_parameters (
BeamParameters) – Object holding the different phase spaces.phase_space_names (
Sequence[str]) – Names of the phase spaces to initialize.transfer_matrices (
Sequence[ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]]) – Transfer matrix corresponding to each phase space.gamma_kin (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Lorentz gamma factor.beta_kin (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Lorentz beta factor.beam_kwargs – Configuration dictionary holding initial beam parameters.
- Return type:
- _set_transverse_from_x_and_y(beam_parameters, other_phase_space_names, phase_space_name)[source]
Initialize
t(transverse) phase space.
- _set_from_sigma(beam_parameters, phase_space_names, sigmas, gamma_kin, beta_kin)[source]
Initialize transfer matrices from \(\sigma\) beam matrix.
- Parameters:
- Return type:
- _abc_impl = <_abc._abc_data object at 0x7318fb342440>
- class InitialBeamParametersFactory(is_3d, is_multipart, beam_kwargs)[source]
Bases:
ABCThis is used when creating new
ListOfElements.This factory is not subclassed. Only one instance should be created.
Todo
Remove the
is_3d,is_multipartas I always create the same object withTrue,True.- Parameters:
is_3d (
bool)is_multipart (
bool)beam_kwargs (
BeamKwargs)
- __init__(is_3d, is_multipart, beam_kwargs)[source]
Create factory and list of phase spaces to generate.
- Parameters:
is_3d (
bool) – If the simulation is in 3D.is_multipart (
bool) – If the simulation is a multiparticle.beam_kwargs (
BeamKwargs) – Configuration dict holding some constants of the beam.
- Return type:
None
- factory_new(sigma_in, w_kin, z_abs=0.0)[source]
Create the beam parameters for the beginning of the linac.
- Parameters:
- Returns:
Beam parameters at the start of the linac.
- Return type:
- factory_subset(simulation_output, get_kw)[source]
Generate
InitialBeamParametersfor a linac portion.- Parameters:
- Returns:
Holds information on the beam at the beginning of the linac portion.
- Return type:
- _initial_beam_parameters_kw(simulation_output, get_kw)[source]
Generate the kw to instantiate the
InitialBeamParameters.
- _initial_phase_space_beam_parameters_kw(original_beam_parameters, phase_space_names, get_kw, skip_missing_phase_spaces)[source]
Get all beam data at proper position and store it in a dict.
- Parameters:
original_beam_parameters (
BeamParameters) – Object holding original beam parameters.get_kw (
dict[str,Element|str|bool|None]) – dict that can be passed to thegetmethod and that will return the data at the beginning of the linac portion.skip_missing_phase_spaces (
bool) – To handle when a phase space fromphase_spacesfromselfis not defined inoriginal_beam_parameters, and is therefore not initializable. If True, we just skip it. If False and such a case happens, anAttributeErrorwill be raised.
- Return type:
dict[str,dict[str,float|ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]]]- Returns:
Keys are the name of the phase spaces. The values are other dictionaries, which keys-values are
InitialPhaseSpaceBeamParametersattributes.
- _set_from_sigma(initial_beam_parameters, phase_space_names, sigmas)[source]
Initialize transfer matrices from \(\sigma\) beam matrix.
- _set_from_other_phase_space(initial_beam_parameters, other_phase_space_name, phase_space_names)[source]
Instantiate a phase space from another one.
- Parameters:
initial_beam_parameters (
InitialBeamParameters) – Object holding the beam parameters in different phase spaces.other_phase_space_name (
Literal['zdelta']) – Name of the phase space from which the new phase space will be initialized.phase_space_names (
Sequence[Literal['phiw','z']]) – Name of the phase spaces that will be created.gamma_kin – Lorentz gamma factor.
beta_kin – Lorentz beta factor.
- Return type:
- _abc_impl = <_abc._abc_data object at 0x7318fb341d40>