core.accelerator.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: ABC

A 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 (Path) – The original .dat file, as understood by TraceWin.

  • project_folder (Path) – Base folder where results will be saved. If the project_folder key is not given in the configuration file, it is a folder in the same base folder as dat_file.

  • files_kw – Other arguments from the file entry of the .ini.

_abc_impl = <_abc._abc_data object>
_check_consistency_absolute_phases(cavities: Sequence[FieldMap]) None

Check that solvers phases are consistent with .dat file.

_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 (abs)
000000_ref/ <- accelerator_path (abs)

0_FirstBeamCalculatorName/ <- out_folder (rel) (1_SecondBeamCalculatorName/) <- out_folder (rel)

000001/

0_FirstBeamCalculatorName/ (1_SecondBeamCalculatorName/)

000002/

0_FirstBeamCalculatorName/ (1_SecondBeamCalculatorName/)

etc

Parameters:

out_folders (Sequence[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.

run(*args, **kwargs) Accelerator

Create the object.

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: WithFaults

Alias for WithFaults.

_abc_impl = <_abc._abc_data object>
class NoFault(dat_file: Path, project_folder: Path, beam_calculator: BeamCalculator, **files_kw)

Bases: AcceleratorFactory

Factory used to generate a single accelerator, no faults.

__init__(dat_file: Path, project_folder: Path, beam_calculator: BeamCalculator, **files_kw) None

Initialize.

_abc_impl = <_abc._abc_data object>
property beam_calculator: BeamCalculator

Shortcut to get the only existing BeamCalculator.

run(*args, **kwargs) Accelerator

Create a single accelerator.

class StudyWithoutFaultsAcceleratorFactory(dat_file: Path, project_folder: Path, beam_calculator: BeamCalculator, **files_kw)

Bases: NoFault

Alias for NoFault.

_abc_impl = <_abc._abc_data object>
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: AcceleratorFactory

Factory 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.

_abc_impl = <_abc._abc_data object>
property n_simulations: int

Determine how much simulations will be made.

run(*args, **kwargs) Accelerator

Return a single accelerator.

run_all(**kwargs) list[Accelerator]

Create the required Accelerators as well as their output folders.