pyaml.magnet.magnet#

Base interfaces for physical and simulated magnets.

This module defines the common magnet element interface and its access to strength, hardware, and magnet-model information.

Classes

Magnet(name[, model, lattice_names, description])

Access one magnet of a physical or simulated lattice.

class pyaml.magnet.magnet.Magnet(name, model=None, lattice_names=None, description=None)#

Bases: Element

Access one magnet of a physical or simulated lattice.

A magnet couples a device to its calibration: the attached MagnetModel owns the strength to hardware-current conversion and the underlying control-system device names. The same magnet is therefore readable and writable both as a physical strength and as a raw hardware value.

Parameters:
  • name (str) – Element name.

  • model (MagnetModel | None, optional) – Magnet model used to convert between strength and hardware value, and to resolve the underlying control-system device names.

  • lattice_names (str | None, optional) – Name or names of the matching element(s) in the simulated lattice. Defaults to name.

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

Attributes

strength

Read/write accessor for the physical strength, in the model’s strength unit.

hardware

Read/write accessor for the hardware value, in the model’s hardware unit.

model

Magnet model performing the strength to hardware conversion.

Methods

attach()

Return a copy of this magnet bound to a control system or simulator.

set_energy()

Set the energy in eV to compute and set the magnet rigidity on the underlying magnet model.

set_model_name()

Sets the name of this magnet in the model (Used for combined function magnet)

get_model_name()

Returns the model name of this magnet

attach(peer, strength, hardware)#

Return a copy of this magnet bound to a control system or simulator.

Parameters:
Returns:

Self – Copy of this magnet bound to peer.

Return type:

Self

get_model_name()#

Returns the model name of this magnet

set_energy(energy)#

Set the energy in eV to compute and set the magnet rigidity on the underlying magnet model.

set_model_name(name)#

Sets the name of this magnet in the model (Used for combined function magnet)

property hardware: ReadWriteFloatScalar#

Gives access to the strength of this magnet in hardware unit when possible

property model: MagnetModel#

Returns a handle to the underlying magnet model

property model_name: str#

Name used to identify this magnet in its model.

property strength: ReadWriteFloatScalar#

Gives access to the strength of this magnet in physics unit