factory module
Define a factory to easily create Accelerator.
- class AcceleratorFactory(dat_file: Path, project_folder: Path, beam_calculators: BeamCalculator | Sequence[BeamCalculator | None], **files_kw: str | Path)
Bases:
ABCA class to create accelerators.
- __init__(dat_file: Path, project_folder: Path, beam_calculators: BeamCalculator | Sequence[BeamCalculator | None], **files_kw: str | Path) None
Create the object from the
project_folder.- Parameters:
dat_file (pathlib.Path) – The original
.datfile, as understood by TraceWin.project_folder (pathlib.Path) – Base folder where results will be saved. If the
project_folderkey is not given in the configuration file, it is a folder in the same base folder asdat_file.files_kw – Other arguments from the
fileentry of the.ini.
- run(*args, **kwargs) Accelerator
Create the object.
- _generate_folders_tree_structure(out_folders: Sequence[Path], n_simulations: int) list[Path]
Create the proper folders for every
Accelerator.The default structure is:
where_original_dat_is/YYYY.MM.DD_HHhMM_SSs_MILLIms/<-project_folder(absolute)000000_ref/<-accelerator_path(absolute)0_FirstBeamCalculatorName/<-out_folder(relative)(
1_SecondBeamCalculatorName/) <-out_folder(relative)
000001/0_FirstBeamCalculatorName/(
1_SecondBeamCalculatorName/)
000002/0_FirstBeamCalculatorName/(
1_SecondBeamCalculatorName/)
etc
- Parameters:
out_folders (Sequence[pathlib.Path]) – Name of the folders that will store outputs. By default, it is the name of the solver, preceeded by its position in the list of
BeamCalculator.
- _check_consistency_absolute_phases(cavities: Sequence[FieldMap]) None
Check that solvers phases are consistent with
.datfile.
- _abc_impl = <_abc._abc_data object at 0x7fd3cc77d540>
- class NoFault(dat_file: Path, project_folder: Path, beam_calculator: BeamCalculator, **files_kw)
Bases:
AcceleratorFactoryFactory used to generate a single accelerator, no faults.
- __init__(dat_file: Path, project_folder: Path, beam_calculator: BeamCalculator, **files_kw) None
Initialize.
- property beam_calculator: BeamCalculator
Shortcut to get the only existing
BeamCalculator.
- run(*args, **kwargs) Accelerator
Create a single accelerator.
- _abc_impl = <_abc._abc_data object at 0x7fd3cc77ec40>
- class StudyWithoutFaultsAcceleratorFactory(dat_file: Path, project_folder: Path, beam_calculator: BeamCalculator, **files_kw)
Bases:
NoFaultAlias for
NoFault.- _abc_impl = <_abc._abc_data object at 0x7fd3cc77ec80>
- class WithFaults(dat_file: Path, project_folder: Path, beam_calculators: BeamCalculator | Sequence[BeamCalculator | None], failed: list[list[int]] | None = None, **kwargs: Path | str | float | list[int])
Bases:
AcceleratorFactoryFactory used to generate several accelerators for a fault study.
- __init__(dat_file: Path, project_folder: Path, beam_calculators: BeamCalculator | Sequence[BeamCalculator | None], failed: list[list[int]] | None = None, **kwargs: Path | str | float | list[int]) None
Initialize.
- run(*args, **kwargs) Accelerator
Return a single accelerator.
- run_all(**kwargs) list[Accelerator]
Create the required Accelerators as well as their output folders.
- _abc_impl = <_abc._abc_data object at 0x7fd3cc77ec00>
- class FullStudyAcceleratorFactory(dat_file: Path, project_folder: Path, beam_calculators: BeamCalculator | Sequence[BeamCalculator | None], failed: list[list[int]] | None = None, **kwargs: Path | str | float | list[int])
Bases:
WithFaultsAlias for
WithFaults.- _abc_impl = <_abc._abc_data object at 0x7fd3cc77ebc0>