pyaml.magnet.model#

Abstract interfaces for magnet conversion models.

The MagnetModel contract covers conversion between physical strengths and hardware setpoints, unit metadata, device names, and magnetic rigidity.

Classes

MagnetModel()

Define the interface for magnet strength and hardware conversion.

class pyaml.magnet.model.MagnetModel#

Bases: object

Define the interface for magnet strength and hardware conversion.

Concrete models implement the relationship between accelerator physics strengths and power-supply values for one or more magnet functions.

Methods

compute_hardware_values()

Compute hardware value(s) from magnet strength(s)

compute_strengths()

Compute magnet strength(s) from hardware value(s)

get_strength_units()

Get strength units

get_device_names()

Return the control-system device names used by this model.

set_magnet_rigidity()

Set the magnet rigidity.

has_hardware()

Tells if the model allows to work in hardware unit.

has_physics()

Tells if the model allows to work in physics unit.

abstractmethod compute_hardware_values(strengths)#

Compute hardware value(s) from magnet strength(s)

Parameters:

strengths (npt.NDArray[np.float64]) – Array of strengths. For a single multipole, strengths is an array of 1 item.

Returns:

npt.NDArray[np.float64] – Array of hardware values (i.e. currents or voltages).

Return type:

NDArray[float64]

abstractmethod compute_strengths(hardware_values)#

Compute magnet strength(s) from hardware value(s)

Parameters:

hardware_values (npt.NDArray[np.float64]) – Array of hardware values (i.e. currents or voltages)

Returns:

npt.NDArray[np.float64] – Array of strengths. For a single multipole, returns an array of 1 item

Return type:

NDArray[float64]

abstractmethod get_device_names()#

Return the control-system device names used by this model.

Returns:

list[str | None] – Array of associated device names.

Return type:

list[str | None]

abstractmethod get_strength_units()#

Get strength units

Returns:

list[str] – Array of strength units. For a single multipole, returns a list of 1 item

Return type:

list[str]

has_hardware()#

Tells if the model allows to work in hardware unit.

Returns:

bool – True if the model supports hardware unit

Return type:

bool

has_physics()#

Tells if the model allows to work in physics unit.

Returns:

bool – True if the model supports physics unit

Return type:

bool

abstractmethod set_magnet_rigidity(brho)#

Set the magnet rigidity.

Parameters:

brho (np.double) – Magnet rigidity used to calculate power supply setpoints