fault module
Define the class Fault.
Its purpose is to hold information on a failure and to fix it.
Todo
not clear what happens here. separate __init__ in several functions
Todo
store DesignSpace as attribute rather than Variable Constraint compute_constraints
- class Fault(reference_elts, broken_elts, failed_elements, compensating_elements, skip_optimization=False)[source]
Bases:
objectHandle and fix a single failure.
- Parameters:
reference_elts (
ListOfElements)broken_elts (
ListOfElements)skip_optimization (
bool, default:False)
- __init__(reference_elts, broken_elts, failed_elements, compensating_elements, skip_optimization=False)[source]
Create the Fault object.
- Parameters:
reference_elts (
ListOfElements) – Holds nominal linac elements.broken_elts (
ListOfElements) – Holds nominal linac elements.failed_elements (
Sequence[Element]) – List of failed cavities.compensating_elements (
Sequence[Element]) – Holds the compensating elements.skip_optimization (
bool, default:False) – Used when the fixedAcceleratorwas unpikcled and therefore already holds the fixed settings.
- Return type:
None
- optimisation_algorithm: OptimisationAlgorithm | None
This attribute is set at the start of the optimization process in order to save information on the objectives, variables, best solution, etc.
- subset_elts: ListOfElements
This attribute is set at the start of the optimization process in order to keep information on the compensation zone.
- fix(optimisation_algorithm)[source]
Fix the
Fault. Setself.optimized_cavity_settings.Also display information on the parametrization of the optimization problem, the solution that was found.
- Parameters:
optimisation_algorithm (
OptimisationAlgorithm|None) – The optimization algorithm to be used, already initialized.simulation_output – The most recent simulation, that includes the compensation settings of all
Faultupstream ofself.
- Return type:
- postprocess_fix(fix_acc, beam_calculator, ref_simulation_output, reference_phase_policy)[source]
Run post-optimization propagation and update elements status.
- Parameters:
fix_acc (
Accelerator) – Holds accelerator being fixed.beam_calculator (
BeamCalculator) – Object performing propagation.ref_simulation_output (
SimulationOutput) – Reference simulation, obtained withbeam_calculator.reference_phase_policy (
Literal['phi_0_abs','phi_0_rel','phi_s'] |Literal['as_in_original_dat']) – Which phase should be kept when the beam phase changes.
- Return type:
- Returns:
Most recent simulation, that includes the compensation settings of upstream
Faultas well as of this one.
- pre_compensation_status()[source]
Mark failed and compensating cavities.
Skipped if the optimization was already performed.
- Return type:
- _post_compensation_status(reference_phase_policy, fix_elts)[source]
Update cavities status after compensation.
Skipped if the optimization was already performed.
Compensating cavities of the current fault are marked as retuned, meaning they should not be modified further. Their status changes from
"compensate (in progress)"to either"compensate (ok)"or"compensate (not ok)"depending on the compensation success.If the reference phase policy does not preserve absolute phases, all cavities following the last altered one are marked as rephased. Their status changes from
"rephased (in progress)"to"rephased (ok)", stopping at the first element belonging to the next failure (i.e., a compensating or failed cavity).- Parameters:
success – Wether the compensation was successful.
reference_phase_policy (
Literal['phi_0_abs','phi_0_rel','phi_s'] |Literal['as_in_original_dat']) – Phase reference policy applied during compensation.fix_elts (
ListOfElements) – All accelerator elements.
- Return type:
- property packed_elements: PackedElements
Return arguments for
ObjectiveFactory.
- property info: dict
Return the dictionary holding information on the solution.
Deprecated since version 0.8.2: Prefer using the
opti_solattribute.
- property _compensation_settings: dict[FieldMap, CavitySettings]
Get the settings found by the optimizer.
If optimization was already performed (unpickled
Accelerator) , we return the settings stored in the compensating cavities.