pyaml.magnet.linear_cfm_model#

Linear conversion model for combined-function magnets.

This model converts multiple multipole strengths to hardware values using per-function linear calibration parameters.

Classes

LinearCFMagnetModel(multipoles, curves, ...)

Linear combined-function magnet model.

class pyaml.magnet.linear_cfm_model.LinearCFMagnetModel(multipoles, curves, powerconverters, hardware_units, calibration_factors=None, calibration_offsets=None, pseudo_factors=None, pseudo_offsets=None, matrix=None, units=None)#

Bases: MagnetModel, DynamicValidation

Linear combined-function magnet model.

This model converts between magnet strengths and hardware currents using precomputed excitation curves, optional calibration and pseudo-current corrections, and an optional coupling matrix to separate or combine multipole responses. It is intended for combined-function magnets where several multipoles share a common hardware representation.

Parameters

multipoles : list[str] Names of the supported multipoles, for example [“B0”, “A1”, “B2”]. curves : list[Curve] Excitation curves, one per multipole. powerconverters : list[str | None] Names of the power converter devices associated with the hardware currents. hardware_units : list[str] Units of the hardware variables, one per power converter. calibration_factors : list[float] | None, optional Multiplicative correction factors applied to the excitation curves. Defaults to ones. calibration_offsets : list[float] | None, optional Additive correction offsets applied to the excitation curves. Defaults to zeros. pseudo_factors : list[float] | None, optional Multiplicative factors applied to pseudo currents. Defaults to ones. pseudo_offsets : list[float] | None, optional Additive offsets applied to pseudo currents. Defaults to zeros. matrix : Matrix | None, optional Coupling matrix mapping power-supply currents to pseudo currents. Defaults to the identity matrix. units : list[str] | None, optional Strength units, one per multipole.

Raises

PyAMLException If the list lengths do not match, if the matrix has the wrong shape, or if the configuration is otherwise inconsistent.

Parameters:
  • multipoles (list[str]) – Names of the supported multipoles, for example [“B0”, “A1”, “B2”].

  • curves (list[Curve]) – Excitation curves, one per multipole.

  • powerconverters (list[str | None]) – Names of the power converter devices associated with the hardware currents.

  • hardware_units (list[str]) – Units of the hardware variables, one per power converter.

  • calibration_factors (list[float] | None) – Multiplicative correction factors applied to the excitation curves. Defaults to ones.

  • calibration_offsets (list[float] | None) – Additive correction offsets applied to the excitation curves. Defaults to zeros.

  • pseudo_factors (list[float] | None) – Multiplicative factors applied to pseudo currents. Defaults to ones.

  • pseudo_offsets (list[float] | None) – Additive offsets applied to pseudo currents. Defaults to zeros.

  • matrix (Matrix | None) – Coupling matrix mapping power-supply currents to pseudo currents. Defaults to the identity matrix.

  • units (list[str] | None) – Strength units, one per multipole.

Methods

compute_hardware_values()

Convert magnet strengths to hardware values.

compute_strengths()

Convert hardware values to magnet strengths.

get_strength_units()

Return the units of magnet strengths.

get_hardware_units()

Return the units of hardware values.

get_device_names()

Return the associated device names.

set_magnet_rigidity()

Set the magnetic rigidity used for conversion.

has_hardware()

Return whether the model provides hardware values.

Configuration

type: pyaml.magnet.linear_cfm_model
multipoles: [B0, A0]
units: [rad, rad]
hardware_units: [A, A]
curves:
  - type: pyaml.magnet.csvcurve
    file: path/to/horizontal_excitation_curve.csv
  - type: pyaml.magnet.csvcurve
    file: path/to/vertical_excitation_curve.csv
powerconverters:
  - DEVICE/HORIZONTAL_POWER_CONVERTER_CURRENT
  - DEVICE/VERTICAL_POWER_CONVERTER_CURRENT
compute_hardware_values(strengths)#

Convert magnet strengths to hardware values.

Parameters:

strengths (np.array) – Strength of each magnet function, ordered as declared by the model.

Returns:

np.array – Hardware value of each power converter, ordered as declared by the model.

Return type:

array

compute_strengths(currents)#

Convert hardware values to magnet strengths.

Parameters:

currents (np.array) – Hardware value of each power converter, ordered as declared by the model.

Returns:

np.array – Strength of each magnet function, ordered as declared by the model.

Return type:

array

get_device_names()#

Return the associated device names.

get_hardware_units()#

Return the units of hardware values.

get_strength_units()#

Return the units of magnet strengths.

has_hardware()#

Return whether the model provides hardware values.

set_magnet_rigidity(brho)#

Set the magnetic rigidity used for conversion.

Parameters:

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