Accelerators

pymadng_utils.accelerators contains the machine descriptors consumed by the MAD-facing interfaces.

Overview

  • Accelerator defines the minimum contract needed by MAD helpers: sequence file, sequence name, beam parameters, BPM pattern, and tune metadata.

  • LHC, PSB and FCC provide concrete machine descriptors used by the tests and model-creation workflows.

  • Accelerators can optionally expose perturbation-family metadata and startup-error hooks for interfaces that support those workflows.

Package exports

Accelerator, LHC, PSB, FCC and the mass and energy constants are re-exported here from the submodules below, which hold their canonical documentation.

Accelerator descriptors used by MAD-facing helpers.

Base descriptor

Minimal accelerator definitions for MAD-facing helpers.

class pymadng_utils.accelerators.base.Accelerator(sequence_file, kinetic_energy, bpm_pattern='BPM', particle='proton', **kwargs)[source]

Bases: ABC

Machine descriptor consumed by the MAD-NG interfaces.

Holds the sequence path, MAD sequence name, beam energy, BPM pattern, tune knobs and integer tunes, and the AC-dipole element name.

Parameters:
  • sequence_file (Path | str)

  • kinetic_energy (float)

  • bpm_pattern (str)

  • particle (str)

  • kwargs (Any)

RBARC = False

MAD-X rbarc option used when loading the sequence (rbend length is the straight chord if True).

NOCHARGE = False

Set MAD-NG’s option.nocharge before the beam is created.

seq_dir = 1

-1 runs the loaded sequence backwards.

Type:

MAD-NG sequence.dir

dp2pt(dp)[source]

Convert relative momentum deviation dp/p to MAD-NG pt.

Parameters:

dp (float)

Return type:

float

pt2dp(pt)[source]

Convert MAD-NG pt to relative momentum deviation dp/p.

Parameters:

pt (float)

Return type:

float

abstract property seq_name: str

Return the sequence name for this accelerator.

Returns:

Sequence name to use in MAD

abstract property ac_dipole_name: str

Return the name of the AC-dipole element.

acd_marker_name(side)[source]

Return a stable row name for the AC-dipole marker state.

Parameters:

side (str)

Return type:

str

kicker_marker_name(kicker_name)[source]

Return the measured initial-condition marker name for kicker tracking.

Parameters:

kicker_name (str)

Return type:

str

kicker_cycle_marker_name(kicker_name)[source]

Return the unobserved centre marker used to cycle kicker-mode tracking.

Parameters:

kicker_name (str)

Return type:

str

apply_accelerator_specific_errors(mad_iface)[source]

Apply machine-specific startup errors to a loaded MAD sequence.

Parameters:

mad_iface (Any)

Return type:

None

get_perturbation_families()[source]

Return per-family perturbation metadata keyed by family code d/q/s.

Return type:

dict[str, dict[str, str | float | dict]]

abstract property tune_variables: tuple[str, str]

Return the MAD-X tune knob names (qx, qy).

abstract property tune_integers: tuple[int, int]

Return the integer parts of the tunes (qx, qy).

LHC descriptor

LHC-specific accelerator implementation.

class pymadng_utils.accelerators.lhc.LHC(beam, sequence_file, kinetic_energy=6800.0, bpm_pattern='^BPM.*$', particle='proton', tune_knobs_suffix='_op', seq_dir=None, **kwargs)[source]

Bases: Accelerator

Large Hadron Collider accelerator configuration.

Holds the beam number, sequence direction, BPM pattern, operational tune knobs (dqx_b<beam><suffix>) and the integer tunes (62, 60).

Initialise LHC accelerator for a specific beam.

Parameters:
  • beam (int) – Beam number (1 or 2)

  • sequence_file (Path | str) – Path to sequence file

  • kinetic_energy (float) – Particle kinetic energy in GeV (default 6800 GeV for LHC)

  • bpm_pattern (str) – Pattern for selecting BPMs

  • particle (str) – Type of particle (default “proton”)

  • tune_knobs_suffix (str) – Suffix of the MAD-X tune knobs dqx_b<beam> / dqy_b<beam>

  • seq_dir (int | None) – MAD-NG sequence direction. Required for beam 2: -1 for the MAD-X beam-2 sequence (listed in beam-1 order), 1 for the beam-4 tracking sequence (also named lhcb2). Defaults to 1 for beam 1.

Raises:

ValueError – If an invalid beam number is provided

BPM_PATTERN = '^BPM.*$'
QUAD_ERROR_TABLE: ClassVar[dict[str, float]] = {'MQ.': 0.0018, 'MQM': 0.0012, 'MQW': 0.0015, 'MQX': 0.001, 'MQY': 0.0008}
property seq_name: str

Return the sequence name for this LHC beam.

property tune_variables: tuple[str, str]

Return LHC operational tune knob names.

property tune_integers: tuple[int, int]

Return LHC integer tunes.

property ac_dipole_name: str

Return the LHC AC-dipole element name.

get_perturbation_families()[source]

Return perturbation-family metadata for LHC magnets.

Return type:

dict[str, dict[str, float | str | dict]]

PSB descriptor

PSB-specific accelerator implementation.

class pymadng_utils.accelerators.psb.PSB(sequence_file, ring=None, kinetic_energy=0.16, bpm_pattern=None, particle='proton', **kwargs)[source]

Bases: Accelerator

Proton Synchrotron Booster accelerator configuration.

Parameters:
  • sequence_file (Path | str)

  • ring (int | None)

  • kinetic_energy (float)

  • bpm_pattern (str | None)

  • particle (str)

BPM_PATTERN_TEMPLATE = '^BR{ring}%.BPM.*{ring}$'
SEXTUPOLE_PATTERN = '^BR%d+%.XNO.*'
property seq_name: str

Return the sequence name for the selected PSB ring.

property ac_dipole_name: str

Return the PSB AC-dipole installation element.

property tune_variables: tuple[str, str]

Return PSB tune variable names.

property tune_integers: tuple[int, int]

Return PSB integer tunes.

static infer_monitor_plane(bpm_name)[source]

Return "HV" (both planes) for a PSB monitor name; raise for other names.

Parameters:

bpm_name (str)

Return type:

str

FCC-ee descriptor

FCC-ee accelerator implementation (LCC lattice, single ring).

pymadng_utils.accelerators.fcc.FCC_ENERGY_GEV = {'h': 120.0, 't': 182.5, 'w': 80.0, 'z': 45.6}

Total beam energy per FCC-ee mode, GeV.

pymadng_utils.accelerators.fcc.FCC_Z_TUNE_INTEGERS = (166, 162)

Integer tunes of the LCC_107 Z lattice (166.16, 162.20).

class pymadng_utils.accelerators.fcc.FCC(sequence_file, kinetic_energy=None, bpm_pattern='^BPM_.*$', particle='electron', mode='z', **kwargs)[source]

Bases: Accelerator

FCC-ee (LCC optics) accelerator configuration.

The LCC lattices are a single ring (fccee_p_ring) with lower-case element names: BPMs bpm_<quad>, quadrupoles q*, and paired correctors hcor_<quad> / vcor_<quad> (MAD-X kicker with hkick / vkick). MAD-NG upper-cases element names when loading the madx, so the Lua patterns here are upper case (MAD-X variables stay lower case).

Initialise the FCC-ee accelerator.

Parameters:
  • sequence_file (Path | str) – Path to the MAD-X sequence file (e.g. fccee_z.madx)

  • kinetic_energy (float | None) – Particle kinetic energy in GeV (default: the mode’s beam energy minus the particle mass)

  • bpm_pattern (str) – Pattern for selecting BPMs

  • particle (str) – Type of particle (default “electron”; MAD-NG runs with nocharge as the madx ignores the charge)

  • mode (str) – FCC-ee running mode, one of z, w, h, t

Raises:

ValueError – If an unknown mode is given

SEQUENCE_NAME = 'fccee_p_ring'
BPM_PATTERN = '^BPM_.*$'
CORRECTOR_PATTERN = '^[HV]COR_'
QUAD_REL_STD = 0.005

Relative k1 calibration error used for the FCC-ee LOCO studies.

RBARC = True

The LCC madx is written for MAD-X’s default rbarc=true (rbend l is the chord).

NOCHARGE = True

Ignore the beam charge like MAD-X does (otherwise an electron flips every magnet strength).

property seq_name: str

Return the sequence name of the FCC-ee ring.

property tune_variables: tuple[str, str]

The LCC lattice files define no tune knobs.

property tune_integers: tuple[int, int]

Return the integer tunes (Z lattice).

property ac_dipole_name: str

FCC-ee has no AC dipole.

get_perturbation_families()[source]

Return perturbation-family metadata for FCC-ee magnets.

Return type:

dict[str, dict[str, float | str | dict]]