factory module

Define a factory to easily create Accelerator.

class AcceleratorFactory(beam_calculators, files, beam, **kwargs)[source]

Bases: ABC

A class to create accelerators.

Parameters:
__init__(beam_calculators, files, beam, **kwargs)[source]

Facilitate creation of Accelerator objects.

Parameters:
  • beam_calculators (BeamCalculator | Sequence[BeamCalculator | None]) – Objects that will compute propagation of the beam.

  • files (dict[str, Any]) – Configuration entries for the input/output paths.

  • beam (BeamKwargs) – Configuration dictionary holding the initial beam parameters.

  • kwargs (dict) – Other configuration dictionaries.

run(*args, **kwargs)[source]

Create the object.

Return type:

Accelerator

_generate_folders_tree_structure(out_folders, n_simulations)[source]

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

  • n_simulations (int)

Return type:

list[Path]

_check_consistency_absolute_phases(cavities)[source]

Check that solvers phases are consistent with DAT file.

Parameters:

cavities (Sequence[FieldMap])

Return type:

None

_abc_impl = <_abc._abc_data object at 0x70e24f6d9d00>
class NoFault(beam_calculators, files, beam, **kwargs)[source]

Bases: AcceleratorFactory

Factory used to generate a single accelerator, no faults.

Parameters:
__init__(beam_calculators, files, beam, **kwargs)[source]

Facilitate creation of Accelerator.

Parameters:
  • beam_calculators (BeamCalculator) – A unique object to compute propagation of the field. Even if there is a s at the end of the variable name.

  • files (dict[str, Any]) – Configuration entries for the input/output paths.

  • beam (BeamKwargs) – Configuration dictionary holding the initial beam parameters.

  • kwargs (dict) – Other configuration dictionaries.

property beam_calculator: BeamCalculator

Shortcut to get the only existing BeamCalculator.

run(*args, **kwargs)[source]

Create a single accelerator.

Return type:

Accelerator

_abc_impl = <_abc._abc_data object at 0x70e24f6ddb00>
class StudyWithoutFaultsAcceleratorFactory(beam_calculators, files, beam, **kwargs)[source]

Bases: NoFault

Alias for NoFault.

Parameters:
_abc_impl = <_abc._abc_data object at 0x70e24f6e6280>
class WithFaults(beam_calculators, files, beam, wtf, **kwargs)[source]

Bases: AcceleratorFactory

Factory used to generate several accelerators for a fault study.

Parameters:
__init__(beam_calculators, files, beam, wtf, **kwargs)[source]

Facilitate creation of Accelerator objects.

Parameters:
  • beam_calculators (BeamCalculator | Sequence[BeamCalculator | None]) – Objects that will compute propagation of the beam.

  • files (dict[str, Any]) – Configuration entries for the input/output paths.

  • beam (BeamKwargs) – Configuration dictionary holding the initial beam parameters.

  • wtf (dict[str, Any]) – Dictionary holding the information on what to fit.

  • kwargs (dict) – Other configuration dictionaries.

property n_simulations: int

Determine how much simulations will be made.

run(*args, **kwargs)[source]

Return a single accelerator.

Return type:

Accelerator

run_all(**kwargs)[source]

Create the required Accelerators as well as their output folders.

Return type:

list[Accelerator]

_abc_impl = <_abc._abc_data object at 0x70e24f6e7800>
class FullStudyAcceleratorFactory(beam_calculators, files, beam, wtf, **kwargs)[source]

Bases: WithFaults

Alias for WithFaults.

Parameters:
_abc_impl = <_abc._abc_data object at 0x70e24f6e7480>