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:
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_settings if they are listed in this object. If they are not, we give them their default CavitySettings (FieldMap.cavity_settings attribute). This method is used to generate SimulationOutput 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 (Self | dict[TypeVar(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, every CavitySettings is taken from the FieldMap object (corresponds to run without optimisation).

  • cavities (Collection[TypeVar(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, default: True) – To create new CavitySettings for the cavities not already in set_of_cavity_settings. Allows to compute quantities such as synchronous phase without altering the original one.

Return type:

Self

Returns:

A SetOfCavitySettings with settings from set_of_cavity_settings or from cavities if not in set_of_cavity_settings.

re_set_elements_index_to_absolute_value()[source]

Update cavities index to properly set ele[n][v] commands.

When switching from a sub-ListOfElements during the optimisation process to the full ListOfElements after the optimisation, we must update index n in the ele[n][v]] command.

Return type:

None

_order()[source]

Return all the Element in self in good order.

Return type:

tuple[Sequence[TypeVar(FieldMap)], Sequence[CavitySettings]]

_settings_getter(cavity, set_of_cavity_settings, instantiate_new)[source]

Take the settings from the set of settings if possible.

If cavity is not listed in set_of_cavity_settings, take its nominal CavitySettings instead. In the latter case, instantiate_new will force the creation of a new CavitySettings with the same settings.

Parameters:
  • cavity (TypeVar(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) – To force the creation of a new object; will allow to keep the original CavitySettings unaltered.

Return type:

CavitySettings

Returns:

Cavity settings for cavity.