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_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.

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 a CavitySettings (typically, all the cavities in a sub-ListOfElements studied during an optimisation process).

  • optimization_status (Literal['not started', 'in progress', 'finished']) – Used when cavity is not in cavity_settings (ie, when the cavity is not a compensating cavity). During optimization, we return a copy of its CavitySettings to avoid altering the original. When optimization is over, we return the original to set it’s final phi_s, phi_0_rel, phi_rf, etc.

Return type:

Self

Returns:

Settings for all cavities in cavities.

classmethod nominal(elements)[source]

Get CavitySettings from 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-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]]

_get_settings(cavity, compensating_cavity_settings, optimization_status)[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.

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 when cavity is not in cavity_settings (ie, when the cavity is not a compensating cavity). During optimization, we return a copy of its CavitySettings to avoid altering the original. When optimization is over, we return the original to set it’s final phi_s, phi_0_rel, phi_rf, etc.

  • compensating_cavity_settings (Mapping[TypeVar(FieldMap), CavitySettings])

Return type:

CavitySettings

Returns:

Cavity settings for cavity.