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])
- classmethod from_cavity_settings(several_cavity_settings, compensating_cavities)[source]
Create the proper dictionary.
- Parameters:
several_cavity_settings (
Collection[CavitySettings])compensating_cavities (
Collection[TypeVar(FieldMap)])
- Return type:
Self
- classmethod from_incomplete_set(set_of_cavity_settings, cavities, use_a_copy_for_nominal_settings=True)[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.Todo
Should create the full SetOfCavitySettings directly from the OptimisationAlgorithm. For now, the OptimisationAlgorithm creates a first SetOfCavitySettings. Then, the BeamCalculator calls this method to generate a new SetOfCavitySettings. Ugly, especially given the fact that OptimisationAlgorithm has its ListOfElements.
- Parameters:
set_of_cavity_settings (SetOfCavitySettings | dict[FieldMap, CavitySettings] | None) – Object holding the settings of some cavities (typically, the settings of compensating cavities as given by an
OptimisationAlgorithm). When it is None, everyCavitySettingsis taken from theFieldMapobject (corresponds to run without optimisation).cavities (Sequence[FieldMap]) – All the cavities that should have
CavitySettings(typically, all the cavities in a sub-ListOfElementsstudied during an optimisation process).use_a_copy_for_nominal_settings (bool, optional) – To create new
CavitySettingsfor the cavities not already inset_of_cavity_settings. Allows to compute quantities such as synchronous phase without altering the original one.
- Returns:
A
SetOfCavitySettingswith settings fromset_of_cavity_settingsor fromcavitiesif not inset_of_cavity_settings.- 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:
- _settings_getter(cavity, set_of_cavity_settings, instantiate_new)[source]
Take the settings from the set of settings if possible.
If
cavityis not listed inset_of_cavity_settings, take its nominalCavitySettingsinstead. In the latter case,instantiate_newwill force the creation of a newCavitySettingswith the same settings.- Parameters:
cavity (FieldMap) – Cavity for which you want settings.
set_of_cavity_settings (SetOfCavitySettings) – Different cavity settings (a priori given by an
OptimisationAlgorithm), or an empty dict.instantiate_new (bool, optional) – To force the creation of a new object; will allow to keep the original
CavitySettingsunaltered.
- Returns:
Cavity settings for
cavity.- Return type: