pyaml.magnet.serialized_magnet#

Serialized magnet elements.

This module defines magnet elements composed of multiple serialized magnets.

Classes

ReadWriteSerializedHardwares(elements[, model])

Read/write aggregate for serialized-magnet hardware values.

ReadWriteSerializedStrengths(elements[, model])

Read/write aggregate for serialized-magnet strengths.

SerializedMagnets(name, function, elements)

Serialized group of magnets that share the same set point.

class pyaml.magnet.serialized_magnet.ReadWriteSerializedHardwares(elements, model=None)#

Bases: ReadWriteSerializedStrengths

Read/write aggregate for serialized-magnet hardware values.

Parameters:
  • elements (list[abstract.ReadWriteFloatScalar]) – Per-magnet accessors sharing the group setpoint.

  • model (MagnetModel | None) – Magnet model used to convert between strength and hardware value. Optional for a hardware-only group.

Methods

unit()

Return the hardware-value unit.

set_magnet_rigidity()

Set the magnetic rigidity used for conversion.

set_magnet_rigidity(brho)#

Set the magnetic rigidity used for conversion.

Parameters:

brho (np.double) – Magnetic rigidity in tesla metres, forwarded to the magnet model.

unit()#

Return the hardware-value unit.

class pyaml.magnet.serialized_magnet.ReadWriteSerializedStrengths(elements, model=None)#

Bases: ReadWriteFloatScalar

Read/write aggregate for serialized-magnet strengths.

Parameters:
  • elements (list[abstract.ReadWriteFloatScalar]) – Per-magnet accessors sharing the group setpoint.

  • model (MagnetModel | None) – Magnet model used to convert between strength and hardware value. Optional for a hardware-only group.

Methods

get()

Return the sum of the serialized element strengths.

set()

Set the shared serialized-magnet strength.

set_and_wait()

Set the shared strength and wait for convergence.

unit()

Return the physical strength unit.

get_model()

Return the magnet conversion model.

get_elements()

Return the underlying scalar element accessors.

set_magnet_rigidity()

Set the magnetic rigidity used for conversion.

get()#

Return the sum of the serialized element strengths.

get_elements()#

Return the underlying scalar element accessors.

get_model()#

Return the magnet conversion model.

set(value)#

Set the shared serialized-magnet strength.

Parameters:

value (float) – Strength applied to every magnet of the group.

set_and_wait(value)#

Set the shared strength and wait for convergence.

Parameters:

value (float) – Strength applied to every magnet of the 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, forwarded to the magnet model.

unit()#

Return the physical strength unit.

class pyaml.magnet.serialized_magnet.SerializedMagnets(name, function, elements, model=None, description=None, peer=None)#

Bases: Element, DynamicValidation

Serialized group of magnets that share the same set point.

This class represents a set of magnets that are controlled together as a single logical device. The serialized magnets may be driven by one power supply or by several power supplies, but they share a common physics or hardware set point through a combined read/write interface.

Parameters:
  • name (str) – Name of the serialized magnet group.

  • function (str) – Magnet function identifier used to select the concrete virtual magnet type.

  • elements (list[str] | str) – Names of the individual magnets in the group.

  • model (MagnetModel | None, optional) – Magnet model used to convert between strengths and hardware values.

  • description (str | None, optional) – Human-readable description of the serialized magnet group.

  • peer (object, optional) – Control-system or simulator peer used when attaching the magnet group.

Attributes

strength

Gives access to the strengths of those magnets in physics unit

hardware

Gives access to the strengths of this those magnets in hardware unit when possible

Methods

get_nb_magnets()

Return the number of magnets in the serialized group.

get_magnets()

Return the group’s virtual single-function magnets.

attach()

Attach the group and its virtual magnets to a runtime peer.

set_energy()

Set beam energy for serialized-magnet strength conversion.

get_device_names()

Return the associated device names.

Raises:

PyAMLException – If the requested function is not implemented or if the configuration is invalid.

Notes

The serialized group stores a virtual magnet for each underlying element. When attached, each virtual magnet is bound to the same peer and the group exposes aggregate strength and hardware accessors.

Configuration

The model can be defined inline or in a separate file. See pyaml.magnet.model and its subclasses for model configuration.

- type: pyaml.magnet.serialized_magnet
  name: SERIALIZED_QUADRUPOLES
  function: B1
  elements:
    - QUADRUPOLE_1
    - QUADRUPOLE_2
  model: path/to/serialized_magnet_model.yaml
attach(peer, strengths, hardwares)#

Attach the group and its virtual magnets to a runtime peer.

Parameters:
  • peer (object) – Control system or simulator the group is bound to.

  • strengths (list[abstract.ReadWriteFloatScalar]) – Strength accessor of each magnet in the group, in declaration order.

  • hardwares (list[abstract.ReadWriteFloatScalar]) – Hardware accessor of each magnet in the group, in declaration order.

Returns:

list[Magnet] – Virtual magnets of the group, each bound to peer.

Return type:

list[Magnet]

get_device_names()#

Return the associated device names.

get_magnets()#

Return the group’s virtual single-function magnets.

get_nb_magnets()#

Return the number of magnets in the serialized group.

set_energy(energy)#

Set beam energy for serialized-magnet strength conversion.

The energy is converted to magnetic rigidity and propagated to the serialized magnet model.

Parameters:

energy (float) – Beam energy in electronvolts.

property hardware: ReadWriteFloatScalar#

Gives access to the strengths of this those magnets in hardware unit when possible

property strength: ReadWriteFloatScalar#

Gives access to the strengths of those magnets in physics unit