workflow_setup module
Define helper functions to set up LightWin workflow.
- set_up_solvers(config)[source]
Create the beam calculators.
- set_up_accelerators(config, beam_calculators)[source]
Create the accelerators.
- Parameters:
config (
dict[str,dict[str,Any] |BeamKwargs]) – The fullTOMLconfiguration dictionary.beam_calculators (
tuple[BeamCalculator,...]) – The objects that will compute the beam propagation.
- Return type:
- 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.
- 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] |BeamKwargs]) – The full TOML configuration dict.beam_calculator (
BeamCalculator) – The object that will be used for the optimization. Usually, a fast solver such asCyEnvelope1D.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, default:None) – If provided, will override theobjective_preset. Used to let user define it’s ownObjectiveFactorywithout altering the source code.
- Return type:
- Returns:
The instantiated fault scenarios.
- set_up(config, **kwargs)[source]
Create all the objects used in a typical LightWin simulation.
- Parameters:
config (
dict[str,dict[str,Any] |BeamKwargs]) – The fullTOMLconfiguration dictionary.- Return type:
tuple[tuple[BeamCalculator,...],list[Accelerator],list[FaultScenario] |None,list[SimulationOutput]]- Returns:
beam_calculators – 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 – 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_scenarios :
The created failures. Will be None if no
"wtf"entry was given inconfig.- ref_simulations_outputs :
A reference
SimulationOutputcorresponding to the nominal linac perBeamCalculator.
- fix(fault_scenarios)[source]
Fix all the generated faults.
- Parameters:
fault_scenarios (
Collection[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 referenceSimulationOutputperBeamCalculator, 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: