at.lattice.cavity_access#

Access to properties of RF cavities

See Cavity Control for a guide on using these functions.

Functions

frequency_control(func)

Function to be used as decorator for func(ring, *args, **kwargs)

get_rf_frequency(ring, **kwargs)

Return the RF frequency

set_rf_frequency(ring[, frequency])

Set the RF frequency

get_rf_voltage(ring, **kwargs)

Return the total RF voltage (full ring including periodicity)

set_rf_voltage(ring, voltage, **kwargs)

Set the RF voltage for the full ring

get_rf_timelag(ring, **kwargs)

Return the RF time lag

set_rf_timelag(ring, timelag, **kwargs)

Set the RF time lag

set_cavity(ring[, Voltage, Frequency, ...])

Set the parameters of the RF cavities

Classes

Frf(*values)

Enum class for frequency setting

class Frf(*values)[source]#

Bases: Enum

Enum class for frequency setting

NOMINAL = 'nominal'#

Constant used as a frequency value, standing for the nominal frequency

frequency_control(func)[source]#

Function to be used as decorator for func(ring, *args, **kwargs)

If ring.is_6d is True and dp, dct or df is specified in kwargs, make a copy of ring with a modified RF frequency, remove dp, dct or df from kwargs and call func with the modified ring.

If ring.is_6d is False or no dp, dct or df is specified in kwargs, func is called with ring unchanged.

Example

>>> @frequency_control
... def func(ring, *args, dp=None, dct=None, df=None, **kwargs):
...     pass
get_rf_frequency(ring, **kwargs)[source]#

Return the RF frequency

Parameters:

ring (Lattice) – Lattice description

Keyword Arguments:
  • cavpts (Refpts | None) – If None, look for ring.cavpts, or otherwise take all cavities. The main cavities are those with the lowest frequency among the selected ones.

  • array (bool) –

    If False, return the frequency of the main cavities (selected cavities with the lowest frequency).

    If True, return the frequency of each selected cavity.

Returns:

rf_freq – RF frequency [Hz]

get_rf_timelag(ring, **kwargs)[source]#

Return the RF time lag

Parameters:

ring (Lattice) – Lattice description

Keyword Arguments:
  • cavpts (Refpts | None) – If None, look for ring.cavpts, or otherwise take all cavities. The main cavities are those with the lowest frequency among the selected ones.

  • array (bool) –

    If False, return the timelag of the main cavities (selected cavities with the lowest frequency).

    If True, return the timelag of each selected cavity.

Returns:

rf_timelag – RF time lag as path lengthening [m]

get_rf_voltage(ring, **kwargs)[source]#

Return the total RF voltage (full ring including periodicity)

Parameters:

ring (Lattice) – Lattice description

Keyword Arguments:
  • cavpts (Refpts | None) – If None, look for ring.cavpts, or otherwise take all cavities. The main cavities are those with the lowest frequency among the selected ones.

  • array (bool) –

    If False, return the sum of the voltage of the main cavities (selected cavities with the lowest frequency).

    If True, return the voltage of each selected cavity.

Returns:

rf_v – Total voltage (full ring including periodicity) [V]

set_cavity(ring, Voltage=None, Frequency=None, TimeLag=None, cavpts=None, copy=False, array=False, **kwargs)[source]#

Set the parameters of the RF cavities

Parameters:
  • ring (Lattice) – lattice description

  • Frequency (float | Frf | None) – RF frequency [Hz]. Use Frf.NOMINAL to specify the nominal frequency corresponding to the given off-momentum.

  • Voltage (float | None) – Total RF voltage [V]

  • TimeLag (float | None) – RF time shift expressed as path lengthening [m]

  • cavpts (Type[Element] | Element | Callable[[Element], bool] | str | None | int | Sequence[int] | bool | Sequence[bool] | RefptsCode) – Cavity location. If None, look for ring.cavpts, or otherwise take all cavities

  • array (bool) –

    If False, the value is applied as described for set_rf_voltage(), set_rf_timelag() and set_rf_frequency().

    If True, directly apply the values to the selected cavities. The values must be broadcastable to the number of cavities.

  • copy (bool) – If True, returns a shallow copy of ring with new cavity elements. Otherwise (default), modify ring in-place.

set_rf_frequency(ring, frequency=Frf.NOMINAL, **kwargs)[source]#

Set the RF frequency

Parameters:
  • ring (Lattice) – Lattice description

  • frequency (float | Frf) – RF frequency [Hz]. Use Frf.NOMINAL to specify the nominal frequency corresponding to the given off-momentum.

Keyword Arguments:
  • dp (float | None) – Momentum deviation. Defaults to None

  • dct (float | None) – Path lengthening. Defaults to None

  • df (float | None) – Deviation of RF frequency. Defaults to None

  • cavpts (Refpts | None) – If None, look for ring.cavpts, or otherwise take all cavities.

  • array (bool) –

    If False (default), frequency is applied to the selected cavities with the lowest frequency. The frequency of all the other selected cavities is scaled by the same ratio.

    If True, directly apply frequency to the selected cavities. The value must be broadcastable to the number of cavities.

  • copy (bool) – If True, returns a shallow copy of ring with new cavity elements. Otherwise (default), modify ring in-place.

set_rf_timelag(ring, timelag, **kwargs)[source]#

Set the RF time lag

Parameters:
  • ring (Lattice) – Lattice description

  • timelag (float) – RF time lag, expressed as path lengthening [m]

Keyword Arguments:
  • cavpts (Refpts | None) – If None, look for ring.cavpts, or otherwise take all cavities.

  • array (bool) –

    If False (default), timelag is applied to the main cavities. The timelag of the other cavities is shifted by the same amount.

    If True, directly apply timelag to the selected cavities. The value must be broadcastable to the number of cavities.

  • copy (bool) – If True, returns a shallow copy of ring with new cavity elements. Otherwise (default), modify ring in-place.

set_rf_voltage(ring, voltage, **kwargs)[source]#

Set the RF voltage for the full ring

Parameters:
  • ring (Lattice) – Lattice description

  • voltage (float) – Total RF voltage (full ring taking periodicity into account) [V]

Keyword Arguments:
  • cavpts (Refpts | None) – If None, look for ring.cavpts, or otherwise take all cavities.

  • array (bool) –

    If False (default), the voltage of the main cavities is scaled to achieve the desired voltage. The voltage of the other cavities is scaled by the same ratio.

    If True, directly apply voltage to the selected cavities. The value must be broadcastable to the number of cavities.

  • copy (bool) – If True, returns a shallow copy of ring with new cavity elements. Otherwise (default), modify ring in-place.