workflow_setup module
Define helper functions to set up LightWin workflow.
- set_up_accelerators(config, beam_calculators)[source]
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, beam_calculator, accelerators, objective_factory_class=None, **kwargs)[source]
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, **kwargs)[source]
Create all the objects used in a typical LightWin simulation.
- Parameters:
config (dict[str, dict[str, Any]]) – The full TOML configuration dictionary.
- Return type:
tuple[tuple[BeamCalculator,...],list[Accelerator],list[FaultScenario] |None,list[SimulationOutput]]- 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)[source]
Fix all the generated faults.
- Parameters:
fault_scenarios (list[FaultScenario] | None) – The created failures. Will be None if no
"wtf"entry was given inconfig.- Return type:
- recompute(beam_calculators, references, *accelerators)[source]
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, **kwargs)[source]
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: