set_of_cavity_settings module
Define a class to store several CavitySettings.
Todo
I should create a SetOfCavitySettings with
CavitySettings for every cavity of the compensation zone. Mandatory to recompute the
synchronous phases.
- class SetOfCavitySettings(several_cavity_settings)[source]
Bases:
dict[FieldMap,CavitySettings]Hold several cavity settings, to try during optimisation process.
- Parameters:
several_cavity_settings (
dict[TypeVar(FieldMap),CavitySettings])
- __init__(several_cavity_settings)[source]
Create the proper dictionary.
- Parameters:
several_cavity_settings (
dict[TypeVar(FieldMap),CavitySettings])- Return type:
None
- classmethod from_incomplete_set(compensating_cavity_settings, cavities, optimization_status)[source]
Create an object with settings for all the field maps.
We give each cavity settings from
set_of_cavity_settingsif they are listed in this object. If they are not, we give them their defaultCavitySettings(FieldMap.cavity_settingsattribute). This method is used to generateSimulationOutputwhere all the cavity settings are explicitly defined.Note
In fact, may be useless. In the future, the nominal cavities will also have their own
CavitySettingsin the compensation zone.- Parameters:
compensating_cavity_settings (
Mapping[TypeVar(FieldMap),CavitySettings] |None) – Maps compensating cavities to their compensation settings.cavities (
Collection[TypeVar(FieldMap)]) – All cavities that should have aCavitySettings(typically, all the cavities in a sub-ListOfElementsstudied during an optimisation process).optimization_status (
Literal['not started','in progress','finished']) – Used whencavityis not incavity_settings(ie, when the cavity is not a compensating cavity). During optimization, we return a copy of itsCavitySettingsto avoid altering the original. When optimization is over, we return the original to set it’s finalphi_s,phi_0_rel,phi_rf, etc.
- Return type:
Self- Returns:
Settings for all cavities in
cavities.
- classmethod nominal(elements)[source]
Get
CavitySettingsfrom objects.- Parameters:
elements (
Collection[Element])- Return type:
Self
- re_set_elements_index_to_absolute_value()[source]
Update cavities index to properly set
ele[n][v]commands.When switching from a sub-
ListOfElementsduring the optimisation process to the fullListOfElementsafter the optimisation, we must update indexnin theele[n][v]]command.- Return type:
- _get_settings(cavity, compensating_cavity_settings, optimization_status)[source]
Take the settings from the set of settings if possible.
If
cavityis not listed inset_of_cavity_settings, take its nominalCavitySettingsinstead.- Parameters:
cavity (
TypeVar(FieldMap)) – Cavity for which you want settings.set_of_cavity_settings – Different cavity settings (a priori given by an
OptimisationAlgorithm), or an empty dict.optimization_status (
Literal['not started','in progress','finished']) – Used whencavityis not incavity_settings(ie, when the cavity is not a compensating cavity). During optimization, we return a copy of itsCavitySettingsto avoid altering the original. When optimization is over, we return the original to set it’s finalphi_s,phi_0_rel,phi_rf, etc.compensating_cavity_settings (
Mapping[TypeVar(FieldMap),CavitySettings])
- Return type:
- Returns:
Cavity settings for
cavity.