beam_calculation.simulation_output.simulation_output module
Define a class to store outputs from different BeamCalculator
.
Todo
Do I really need the r_zz_elt
key??
Todo
Do I really need z_abs? Envelope1D does not uses it while TraceWin does.
Todo
Transfer matrices are stored in TransferMatrix
, but also in
BeamParameters.zdelta
.
Todo
Maybe the synchronous phase model should appear somewhere in here?
- class SimulationOutput(out_folder: Path, is_multiparticle: bool, is_3d: bool, synch_trajectory: ParticleFullTrajectory, cav_params: dict[str, float | None] | None, beam_parameters: BeamParameters, element_to_index: Callable[[str | Element, str | None], int | slice] | None, set_of_cavity_settings: SetOfCavitySettings, transfer_matrix: TransferMatrix | None = None, z_abs: ndarray | None = None, in_tw_fashion: DataFrame | None = None, r_zz_elt: list[ndarray] | None = None)
Bases:
object
Stores the information produced by a
BeamCalculator
.Used for fitting, post-processing, plotting.
- out_folder
Results folder used by the
BeamCalculator
that created this.- Type:
Path
- is_multiparticle
Tells if the simulation is a multiparticle simulation.
- Type:
bool
- is_3d
Tells if the simulation is in 3D.
- Type:
bool
- synch_trajectory
Holds energy, phase of the synchronous particle.
- Type:
ParticleFullTrajectory | None
- cav_params
Holds amplitude, synchronous phase, absolute phase, relative phase of cavities.
- Type:
dict[str, float | None] | None
- beam_parameters
Holds emittance, Twiss parameters, envelopes in the various phase spaces.
- Type:
BeamParameters | None
- element_to_index
Takes an
Element
, its name, ‘first’ or ‘last’ as argument, and returns corresponding index. Index should be the same in all the arrays attributes of this class:z_abs
,beam_parameters
attributes, etc. Used to easilyget
the desired properties at the proper position.- Type:
Callable[[str | Element, str | None], int | slice] | None
- set_of_cavity_settings
The cavity parameters used for the simulation.
- Type:
- transfer_matrix
Holds absolute and relative transfer matrices in all planes.
- Type:
- z_abs
Absolute position in the linac in m. The default is None.
- Type:
np.ndarray | None, optional
- in_tw_fashion
A way to output the
SimulationOutput
in the same way as theData
tab of TraceWin. The default is None.- Type:
pd.DataFrame | None, optional
- r_zz_elt
Cumulated transfer matrices in the [z-delta] plane. The default is None.
- Type:
list[np.ndarray] | None, optional
- __init__(out_folder: Path, is_multiparticle: bool, is_3d: bool, synch_trajectory: ParticleFullTrajectory, cav_params: dict[str, float | None] | None, beam_parameters: BeamParameters, element_to_index: Callable[[str | Element, str | None], int | slice] | None, set_of_cavity_settings: SetOfCavitySettings, transfer_matrix: TransferMatrix | None = None, z_abs: ndarray | None = None, in_tw_fashion: DataFrame | None = None, r_zz_elt: list[ndarray] | None = None) None
- __post_init__() None
Save complementary data, such as
Element
indexes.
- property beam_calculator_information: Path
Use
out_path
to retrieve info onBeamCalculator
.
- beam_parameters: BeamParameters
- cav_params: dict[str, float | None] | None
- compute_complementary_data(elts: ListOfElements, ref_simulation_output: Self | None = None) None
Compute some other indirect quantities.
- Parameters:
elts (ListOfElements) – Must be a full
ListOfElements
, containing all the elements of the linac.ref_simulation_output (SimulationOutput | None, optional) – For calculation of mismatch factors. The default is None, in which case the calculation is simply skipped.
- classmethod from_pickle(pickler: MyPickler, path: Path | str) Self
Instantiate object from previously pickled file.
- get(*keys: str, to_numpy: bool = True, to_deg: bool = False, elt: Element | str | None = None, pos: str | None = None, none_to_nan: bool = False, **kwargs: str | bool | None) Any
Shorthand to get attributes from this class or its attributes.
- Parameters:
*keys (str) – Name of the desired attributes.
to_numpy (bool, optional) – If you want the list output to be converted to a np.ndarray. The default is True.
to_deg (bool, optional) – To apply np.rad2deg function over every
key
containing the string.elt (Element | str | None, optional) – If provided, return the attributes only at the considered element.
pos ('in' | 'out' | None) – If you want the attribute at the entry, exit, or in the whole element.
none_to_nan (bool, optional) – To convert None to np.nan. The default is False.
**kwargs (str | bool | None) – Other arguments passed to recursive getter.
- Returns:
out – Attribute(s) value(s).
- Return type:
Any
- has(key: str) bool
Tell if the required attribute is in this class.
We also call the
BeamParameters.has()
, as it is designed to handle the alias (such astwiss_zdelta
<=>zdelta.twiss
).
- in_tw_fashion: DataFrame | None = None
- is_3d: bool
- is_multiparticle: bool
- out_folder: Path
- pickle(pickler: MyPickler, path: Path | str | None = None) Path
Pickle (save) the object.
This is useful for debug and temporary saves; do not use it for long time saving.
- r_zz_elt: list[ndarray] | None = None
- set_of_cavity_settings: SetOfCavitySettings
- synch_trajectory: ParticleFullTrajectory
- transfer_matrix: TransferMatrix | None = None
- z_abs: ndarray | None = None
- _to_deg(val: ndarray | list | float | None) ndarray | list | float | None
Convert the
val[key]
into deg if it is not None.