workflow_setup module
Define helper functions to set up LightWin workflow.
- set_up_solvers(config: dict[str, dict[str, Any]]) tuple[BeamCalculator, ...]
Create the beam calculators.
- set_up_accelerators(config: dict[str, dict[str, Any]], beam_calculators: tuple[BeamCalculator, ...]) list[Accelerator]
Create the accelerators.
- Parameters:
- Returns:
The instantiated
Accelerator. If there is no fault defined, we return a singleAccelerator. If there is a fault, we return a referenceAcceleratorand a broken one.- Return type:
- set_up_faults(config: dict[str, dict[str, Any]], beam_calculator: BeamCalculator, accelerators: list[Accelerator], objective_factory_class: type[ObjectiveFactory] | None = None, **kwargs) list[FaultScenario]
Create all the
Fault, gather them inFaultScenario.- Parameters:
config (dict[str, dict[str, Any]]) – The full TOML configuration dict.
beam_calculator (BeamCalculator) – The object that will be used for the optimization. Usually, a fast solver such as
CyEnvelope1D.accelerators (list[Accelerator]) – First object is the reference linac; second object is the one we will break and fix.
objective_factory_class (type[ObjectiveFactory] | None, optional) – If provided, will override the
objective_preset. Used to let user define it’s ownObjectiveFactorywithout altering the source code.
- Returns:
The instantiated fault scenarios.
- Return type:
- set_up(config: dict[str, dict[str, Any]], **kwargs) tuple[tuple[BeamCalculator, ...], list[Accelerator], list[FaultScenario] | None, list[SimulationOutput]]
Create all the objects used in a typical LightWin simulation.
- Parameters:
config (dict[str, dict[str, Any]]) – The full TOML configuration dictionary.
- Returns:
beam_calculators (tuple[BeamCalculator, …]) – The objects to compute the beam. Typically, they are two: one for the optimization, and a second slower one to run a more precise simulation.
- accelerators (list[Accelerator]) – The objects that will store a linac design. Typically, they are two:
one for the reference linac, and one for the broken/fixed linac.
- fault_scenarioslist[FaultScenario] | None
The created failures. Will be None if no
"wtf"entry was given inconfig.- ref_simulations_outputslist[SimulationOutput]
A reference
SimulationOutputcorresponding to the nominal linac perBeamCalculator.
- fix(fault_scenarios: Collection[FaultScenario] | None) None
Fix all the generated faults.
- Parameters:
fault_scenarios (list[FaultScenario] | None) – The created failures. Will be None if no
"wtf"entry was given inconfig.
- recompute(beam_calculators: Collection[BeamCalculator], references: Collection[SimulationOutput], *accelerators: Accelerator) list[list[SimulationOutput]]
Recompute accelerator after a fix with more precision.
- Parameters:
beam_calculators (Collection[BeamCalculator]) – One or several beam calculators.
references (Collection[SimulationOutput]) – A reference
SimulationOutputperBeamCalculator, ideally generated by the sameBeamCalculator.accelerators (Accelerator) – One or several fixed linacs.
- Returns:
A nested list of simulation results.
- Return type:
- run_simulation(config: dict[str, Any], **kwargs) list[FaultScenario] | list[Accelerator]
Compute propagation of beam; if failures are defined, fix them.
- Parameters:
- Returns:
If no failure is defined, return the created accelerators. If failures were defined, return the full fault scenarios. Note that you can access the accelerator objects with
FaultScenario.ref_accandFaultScenario.fix_acc.- Return type: