pyaml.lattice.abstract_impl#

Read/write interfaces for simulated lattice elements.

This module adapts Accelerator Toolbox lattice elements to PyAML accessors for magnet strengths, hardware values, BPM readings, RF parameters, and tune data.

Functions

update_bpm_transform_matrix(element)

Update the coordinate transform for a beam-position monitor.

Classes

BPMHScalarAggregator(ring)

Horizontal BPM simulator aggregator

BPMScalarAggregator(ring)

BPM simulator aggregator

BPMVScalarAggregator(ring)

Vertical BPM simulator aggregator

RBetatronTuneArray(ring)

Class providing read-only access to the betatron tune of a ring.

RBpmArray(element, lattice)

Class providing read access to a BPM position (array) of a simulator.

RWBpmOffsetArray(element)

Class providing read write access to a BPM offset (array) of a simulator.

RWBpmTiltScalar(element)

Provide read/write access to a simulated BPM tilt.

RWHardwareArray(elements, poly, model)

Class providing read write access to a magnet of a simulator in hardware units.

RWHardwareScalar(elements, poly, model)

Provide read/write access to a simulated magnet in hardware units.

RWRFATFrequencyScalar(ring)

Provide read/write access to simulated RF frequency through AT methods.

RWRFATotalVoltageScalar(ring)

Provide read/write access to total simulated RF voltage.

RWRFFrequencyScalar(elements, harmonics)

Class providing read write access to RF frequency of a simulator.

RWRFPhaseScalar(elements)

Provide read/write access to the phase of simulated RF cavities.

RWRFVoltageScalar(elements)

Class providing read write access to a cavity voltage of a simulator for a given RF trasnmitter.

RWSerializedHardware(elements, element_index)

RWSerializedHardware configuration or runtime object.

RWSerializedStrength(elements_strength, ...)

RWSerializedStrength configuration or runtime object.

RWStrengthArray(elements, poly, model)

Class providing read write access to a strength (array) of a simulator

RWStrengthScalar(elements, poly, model)

Provide read/write access to a simulated magnet strength.

class pyaml.lattice.abstract_impl.BPMHScalarAggregator(ring)#

Bases: BPMScalarAggregator

Horizontal BPM simulator aggregator

Methods

get()

Return the current value.

get()#

Return the current value.

class pyaml.lattice.abstract_impl.BPMScalarAggregator(ring)#

Bases: ScalarAggregator

BPM simulator aggregator

Parameters:

ring (at.Lattice) – Lattice used to resolve element positions into reference points.

Methods

add_elem()

Add a lattice element to the aggregate.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

get()

Return the current value.

readback()

Return the current readback value.

unit()

Return the value unit.

add_elem(elem)#

Add a lattice element to the aggregate.

Parameters:

elem (at.Element) – BPM lattice element to append to the aggregate.

get()#

Return the current value.

readback()#

Return the current readback value.

set(value)#

Set the current value.

Parameters:

value (NDArray[np.float64]) – Ignored. BPM readings derive from the closed orbit and cannot be written.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (NDArray[np.float64]) – Ignored. BPM readings derive from the closed orbit and cannot be written.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.BPMVScalarAggregator(ring)#

Bases: BPMScalarAggregator

Vertical BPM simulator aggregator

Methods

get()

Return the current value.

get()#

Return the current value.

class pyaml.lattice.abstract_impl.RBetatronTuneArray(ring)#

Bases: ReadFloatArray

Class providing read-only access to the betatron tune of a ring.

Parameters:

ring (at.Lattice) – Accelerator Toolbox lattice whose betatron tunes are computed.

Methods

get()

Return the current value.

unit()

Return the value unit.

get()#

Return the current value.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RBpmArray(element, lattice)#

Bases: ReadFloatArray

Class providing read access to a BPM position (array) of a simulator. Position in pyAT is calculated using find_orbit function, which returns the orbit at a specified index. The position is then extracted from the orbit array as the first two elements (x, y).

Parameters:
  • element (at.Element) – BPM lattice element whose position is read.

  • lattice (at.Lattice) – Lattice on which the closed orbit is computed.

Methods

get()

Return the current value.

unit()

Return the value unit.

get()#

Return the current value.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWBpmOffsetArray(element)#

Bases: ReadWriteFloatArray

Class providing read write access to a BPM offset (array) of a simulator. Offset in pyAT is defined in Offset attribute as a 2-element array.

Parameters:

element (at.Element) – BPM lattice element whose Offset attribute is accessed.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (np.array) – Two-element array with the horizontal and vertical offsets, in metres.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (np.array) – Two-element array with the horizontal and vertical offsets, in metres.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWBpmTiltScalar(element)#

Bases: ReadWriteFloatScalar

Provide read/write access to a simulated BPM tilt.

The value is read from and written to the Accelerator Toolbox Tilt attribute. Writing the tilt also refreshes the BPM coordinate transform.

Parameters:

element (at.Element) – BPM lattice element whose Tilt attribute is accessed.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (float) – Tilt angle to apply, in radians.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Tilt angle to apply, in radians.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWHardwareArray(elements, poly, model)#

Bases: ReadWriteFloatArray

Class providing read write access to a magnet of a simulator in hardware units. Hardware units are converted from strengths using the magnet model

Parameters:
  • elements (list[at.Element]) – Accelerator Toolbox elements of every magnet in the array.

  • poly (list[PolynomInfo]) – Polynomial component for each magnet, giving the PolynomA/PolynomB attribute name, multipole index and sign convention.

  • model (MagnetModel) – Magnet model used to convert between physical strength and hardware value.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (np.array) – Hardware values to apply, one per magnet and ordered like the array.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (np.array) – Hardware values to apply, one per magnet and ordered like the array.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWHardwareScalar(elements, poly, model)#

Bases: ReadWriteFloatScalar

Provide read/write access to a simulated magnet in hardware units.

Hardware values are converted through the associated magnet model while the underlying lattice polynomial is updated on writes.

Parameters:
  • elements (list[at.Element]) – Accelerator Toolbox elements making up the magnet; their contributions are summed.

  • poly (PolynomInfo) – Polynomial component driven by this accessor: the PolynomA/PolynomB attribute name, its multipole index and the sign convention.

  • model (MagnetModel) – Magnet model used to convert between physical strength and hardware value.

Methods

get_length()

Return the total length of the lattice elements.

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get_model()

Return the associated magnet model.

get()#

Return the current value.

get_length()#

Return the total effective length of the lattice elements (1.0 per element when they are all thin).

get_model()#

Return the associated magnet model.

is_thin()#

Return True when every lattice element of this magnet has zero length.

set(value)#

Set the current value.

Parameters:

value (float) – Hardware value to apply, in the unit reported by the magnet model.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Hardware value to apply, in the unit reported by the magnet model.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWRFATFrequencyScalar(ring)#

Bases: ReadWriteFloatScalar

Provide read/write access to simulated RF frequency through AT methods.

The accessor delegates frequency reads and writes to Lattice.get_rf_frequency and Lattice.set_rf_frequency.

Parameters:

ring (at.Lattice) – Accelerator Toolbox lattice whose RF frequency is accessed.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (float) – RF frequency to apply, in hertz.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – RF frequency to apply, in hertz.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWRFATotalVoltageScalar(ring)#

Bases: ReadWriteFloatScalar

Provide read/write access to total simulated RF voltage.

The accessor delegates to the Accelerator Toolbox lattice methods get_rf_voltage and set_rf_voltage.

Parameters:

ring (at.Lattice) – Accelerator Toolbox lattice whose total RF voltage is accessed.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (float) – Total RF voltage to apply over the whole ring, in volts.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Total RF voltage to apply over the whole ring, in volts.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWRFFrequencyScalar(elements, harmonics)#

Bases: ReadWriteFloatScalar

Class providing read write access to RF frequency of a simulator.

Parameters:
  • elements (list[at.Element]) – RF cavity elements driven by this frequency setpoint.

  • harmonics (list[float]) – Multiplier applied to the requested frequency for each cavity.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (float) – Fundamental RF frequency to apply, in hertz.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Frequency setpoint. Not implemented by the simulator.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWRFPhaseScalar(elements)#

Bases: ReadWriteFloatScalar

Provide read/write access to the phase of simulated RF cavities.

Accelerator Toolbox represents the phase through each cavity’s TimeLag attribute. This accessor uses the first cavity’s frequency and keeps the phase synchronized across all cavities in the transmitter.

Parameters:

elements (list[at.Element]) – RF cavity elements sharing the transmitter phase.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (float) – Cavity phase to apply, in radians.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Cavity phase to apply, in radians.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWRFVoltageScalar(elements)#

Bases: ReadWriteFloatScalar

Class providing read write access to a cavity voltage of a simulator for a given RF trasnmitter.

Parameters:

elements (list[at.Element]) – RF cavity elements sharing this voltage setpoint.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (float) – Cavity voltage to apply, in volts.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Cavity voltage to apply, in volts.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWSerializedHardware(elements, element_index)#

Bases: ReadWriteFloatScalar

RWSerializedHardware configuration or runtime object.

Parameters:
  • elements (list[RWHardwareScalar]) – Hardware accessors of the magnets sharing the serialized power supply.

  • element_index (int) – Index of the magnet this accessor represents within the serialized group.

Methods

get_element_length()

Return the total length of the represented element.

get_total_length()

Return the total length of the represented elements.

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

set_magnet_rigidity()

Set the magnetic rigidity used for conversion.

get()#

Return the current value.

get_element_length()#

Return the total length of the represented element.

get_total_length()#

Return the total length of the represented elements.

set(value)#

Set the current value.

Parameters:

value (float) – Hardware value to apply to the whole serialized group.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Hardware value to apply to the whole serialized group.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

set_magnet_rigidity(brho)#

Set the magnetic rigidity used for conversion.

Parameters:

brho (np.double) – Magnetic rigidity in tesla metres, used to convert strengths to hardware values.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWSerializedStrength(elements_strength, elements_hardware, element_index)#

Bases: ReadWriteFloatScalar

RWSerializedStrength configuration or runtime object.

Parameters:
  • elements_strength (list[RWStrengthScalar]) – Strength accessors of the magnets sharing the serialized power supply.

  • elements_hardware (list[RWHardwareScalar]) – Hardware accessors of the same magnets, used to apply the shared setpoint.

  • element_index (int) – Index of the magnet this accessor represents within the serialized group.

Methods

get_element_length()

Return the total length of the represented element.

get_total_length()

Return the total length of the represented elements.

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

set_magnet_rigidity()

Set the magnetic rigidity used for conversion.

get()#

Return the current value.

get_element_length()#

Return the total length of the represented element.

get_total_length()#

Return the total length of the represented elements.

set(value)#

Set the current value.

Parameters:

value (float) – Strength to apply to the magnet, converted to the shared hardware setpoint.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Strength to apply to the magnet, converted to the shared hardware setpoint.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

set_magnet_rigidity(brho)#

Set the magnetic rigidity used for conversion.

Parameters:

brho (np.double) – Magnetic rigidity in tesla metres, used to convert strengths to hardware values.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWStrengthArray(elements, poly, model)#

Bases: ReadWriteFloatArray

Class providing read write access to a strength (array) of a simulator

Parameters:
  • elements (list[at.Element]) – Accelerator Toolbox elements of every magnet in the array.

  • poly (list[PolynomInfo]) – Polynomial component for each magnet, giving the PolynomA/PolynomB attribute name, multipole index and sign convention.

  • model (MagnetModel) – Magnet model used to convert between physical strength and hardware value.

Methods

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get()#

Return the current value.

set(value)#

Set the current value.

Parameters:

value (np.array) – Integrated strengths to apply, one per magnet and ordered like the array.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (np.array) – Integrated strengths to apply, one per magnet and ordered like the array.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

class pyaml.lattice.abstract_impl.RWStrengthScalar(elements, poly, model)#

Bases: ReadWriteFloatScalar

Provide read/write access to a simulated magnet strength.

The accessor aggregates the selected lattice polynomial over all mapped elements and distributes writes across those elements.

Parameters:
  • elements (list[at.Element]) – Accelerator Toolbox elements making up the magnet; their contributions are summed.

  • poly (PolynomInfo) – Polynomial component driven by this accessor: the PolynomA/PolynomB attribute name, its multipole index and the sign convention.

  • model (MagnetModel) – Magnet model used to convert between physical strength and hardware value.

Methods

get_element_length()

Return the total length of the represented element.

get()

Return the current value.

set()

Set the current value.

set_and_wait()

Set the value and wait for readback convergence.

unit()

Return the value unit.

get_model()

Return the associated magnet model.

get(polynom=None, polyidx=None)#

Return the current value.

Parameters:
  • polynom (str) – Lattice polynomial to address, "PolynomA" or "PolynomB". Defaults to the component configured for this accessor.

  • polyidx (int) – Multipole index within polynom. Only used when polynom is given.

Returns:

float – Integrated strength summed over the lattice elements.

Return type:

float

get_element_length()#

Return the total length of the represented element.

get_model()#

Return the associated magnet model.

set(value, polynom=None, polyidx=None)#

Set the current value.

Parameters:
  • value (float) – Integrated strength to apply, distributed over the lattice elements.

  • polynom (str) – Lattice polynomial to address, "PolynomA" or "PolynomB". Defaults to the component configured for this accessor.

  • polyidx (int) – Multipole index within polynom. Only used when polynom is given.

set_and_wait(value)#

Set the value and wait for readback convergence.

Parameters:

value (float) – Integrated strength to apply, distributed over the lattice elements.

Raises:

NotImplementedError – Waiting for readback convergence is not implemented for this accessor.

unit()#

Return the value unit.

pyaml.lattice.abstract_impl.update_bpm_transform_matrix(element)#

Update the coordinate transform for a beam-position monitor.

The transform combines the BPM element’s horizontal and vertical offsets with its tilt, allowing measured positions to be expressed in the BPM coordinate system.

Parameters:

element (at.Element) – BPM lattice element with Offset and Tilt attributes. The resulting matrix is stored on the element as _transform.