util.pass_beauty module

Define utility functions to perform a “pass beauty”.

After a LightWin optimisation, perform a second optimisation with TraceWin. As for now, the implementation is kept very simple:

  • The phase of compensating cavities can be retuned at +/- tol_phi_deg around their compensated value.

  • The amplitude of compensating cavities can be retuned at +/- tol_k_e around their compensated value.

  • We try to keep the phase dispersion between start of compensation zone, and number_of_dsize lattices after.

Todo

fix colors in plots after pass beauty

_cavity_settings_to_adjust(cavity_settings: CavitySettings, dat_idx: int, number: int, tol_phi_deg: float = 5, tol_k_e: float = 0.05, link_index: int = 0, phase_nature: str = '') tuple[Adjust, Adjust] | tuple[Adjust, Adjust, Adjust]

Create a ADJUST command with small bounds around current value.

_is_adapted_to_pass_beauty(beam_calculator: BeamCalculator) bool

Check if the provided beam calculator can perform beauty pass.

_pass_beauty_instructions(fault_scenario: FaultScenario, number_of_dsize: int, number: int = 666333, link_k_g: bool = True) list[Instruction]

Perform a beauty pass.

elements_to_diagnostics(fix_elts: ListOfElements, compensating: Collection[Element], number: int, number_of_dsize: int) list[Diagnostic]

Create the DSize3 commands that will be needed.

insert_pass_beauty_instructions(fault_scenario: FaultScenario | Collection[FaultScenario], beam_calculator: BeamCalculator, number_of_dsize: int = 10, number: int = 666333, link_k_g: bool = True) None

Overwrite ListOfElements to include pass beauty instructions.

The FaultScenario.fix_acc.elts (a ListOfElements) will be overwritten.

set_of_cavity_settings_to_adjust(set_of_cavity_settings: SetOfCavitySettings, number: int, tol_phi_deg: float = 5, link_k_g: bool = False, tol_k_e: float = 0.05, phase_nature: str = 'phi_0_rel') list[Adjust]

Create adjust commands for every compensating cavity.