failures.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: dict[FieldMap, CavitySettings])
Bases:
dict
[FieldMap
,CavitySettings
]Hold several cavity settings, to try during optimisation process.
- __init__(several_cavity_settings: dict[FieldMap, CavitySettings]) None
Create the proper dictionary.
- _order() tuple[Sequence[FieldMap], Sequence[CavitySettings]]
Return all the
Element
inself
in good order.
- classmethod from_cavity_settings(several_cavity_settings: Collection[CavitySettings], compensating_cavities: Collection[FieldMap]) Self
Create the proper dictionary.
- classmethod from_incomplete_set(set_of_cavity_settings: Self | dict[FieldMap, CavitySettings] | None, cavities: Collection[FieldMap], use_a_copy_for_nominal_settings: bool = True) Self
Create an object with settings for all the field maps.
We give each cavity settings from
set_of_cavity_settings
if they are listed in this object. If they are not, we give them their defaultCavitySettings
(FieldMap.cavity_settings
attribute). This method is used to generateSimulationOutput
where all the cavity settings are explicitly defined.Note
In fact, may be useless. In the future, the nominal cavities will also have their own
CavitySettings
in 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, everyCavitySettings
is taken from theFieldMap
object (corresponds to run without optimisation).cavities (Sequence[FieldMap]) – All the cavities that should have
CavitySettings
(typically, all the cavities in a sub-ListOfElements
studied during an optimisation process).use_a_copy_for_nominal_settings (bool, optional) – To create new
CavitySettings
for the cavities not already inset_of_cavity_settings
. Allows to compute quantities such as synchronous phase without altering the original one.
- Returns:
A
SetOfCavitySettings
with settings fromset_of_cavity_settings
or fromcavities
if not inset_of_cavity_settings
.- Return type:
Self
- re_set_elements_index_to_absolute_value() None
Update cavities index to properly set
ele[n][v]
commands.When switching from a sub-
ListOfElements
during the optimisation process to the fullListOfElements
after the optimisation, we must update indexn
in theele[n][v]]
command.
- _settings_getter(cavity: FieldMap, set_of_cavity_settings: SetOfCavitySettings, instantiate_new: bool) CavitySettings
Take the settings from the set of settings if possible.
If
cavity
is not listed inset_of_cavity_settings
, take its nominalCavitySettings
instead. In the latter case,instantiate_new
will force the creation of a newCavitySettings
with 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
CavitySettings
unaltered.
- Returns:
Cavity settings for
cavity
.- Return type: