accelerator module
Define Accelerator, the highest-level class of LightWin.
It holds, well… an accelerator. This accelerator has a
ListOfElements. For each BeamCalculator defined, it has a
SimulationOutput. Additionally, it has a
ParticleInitialState, which describes energy, phase, etc of the beam
at the entry of its ListOfElements.
Todo
Compute_transfer_matrices: simplify, add a calculation of missing phi_0 at the end
- class Accelerator(name: str, dat_file: Path, accelerator_path: Path, list_of_elements_factory: ListOfElementsFactory, e_mev: float, sigma: ndarray, **kwargs)
Bases:
objectClass holding a
ListOfElements.- __init__(name: str, dat_file: Path, accelerator_path: Path, list_of_elements_factory: ListOfElementsFactory, e_mev: float, sigma: ndarray, **kwargs) None
Create object.
- Parameters:
name (str) – Name of the accelerator, used in plots.
dat_file (pathlib.Path) – Absolute path to the linac
.datfile.accelerator_path (pathlib.Path) – Absolute path where results for each
BeamCalculatorwill be stored.list_of_elements_factory (ListOfElementsFactory) – A factory to create the list of elements.
e_mev (float) – Initial beam energy in \(\mathrm{MeV}\).
sigma (numpy.ndarray) – Initial beam \(\sigma\) matrix in \(\mathrm{m}\) and \(\mathrm{rad}\).
- property l_cav
Shortcut to easily get list of cavities.
- get(*keys: str, to_numpy: bool = True, none_to_nan: bool = False, elt: str | Element | None = None, **kwargs: bool | str) 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.
none_to_nan (bool, optional) – To convert None to np.nan. The default is False.
elt (str | Element | None, optional) – If provided, and if the desired keys are in SimulationOutput, the attributes will be given over the Element only. You can provide an Element name, such as
QP1. If the given Element is not in the Accelerator.ListOfElements, the Element with the same name that is present in this list will be used.**kwargs (bool | str) – Other arguments passed to recursive getter.
- Returns:
out – Attribute(s) value(s).
- Return type:
Any
- keep_settings(simulation_output: SimulationOutput, exported_phase: Literal['phi_0_abs', 'phi_0_rel', 'phi_s', 'as_in_settings', 'as_in_original_dat']) None
Save cavity parameters in Elements and new .dat file.
- keep_simulation_output(simulation_output: SimulationOutput, beam_calculator_id: str) None
Save
SimulationOutput. Store info on currentAcceleratorin it.In particular, we want to save a results path in the
SimulationOutputso we can study it and save Figures/study results in the proper folder.
- elt_at_this_s_idx(s_idx: int, show_info: bool = False) Element | None
Give the element where the given index is.
- equivalent_elt(elt: Element | str) Element
Return element from
self.eltswith the same name aselt.