API Reference

The reference covers every module of the accelmo package. Measurement and campaign workflows are maintained in separate repositories.

Primary Entry Points

accelmo.machine.accelerators.base.Accelerator

Abstract base class for accelerator definitions.

accelmo.machine.accelerators.lhc.LHC

Large Hadron Collider accelerator configuration.

accelmo.machine.accelerators.psb.PSB

Proton Synchrotron Booster accelerator configuration.

accelmo.machine.accelerators.sps.SPS

Super Proton Synchrotron accelerator configuration.

accelmo.machine.accelerators.fcc.FCC

FCC-ee accelerator configuration: one k1 knob per arch/IR quadrupole.

accelmo.config.OptimiserConfig

Configuration for gradient descent optimiser algorithms.

accelmo.config.WorkerRuntime

How the worker processes run: how many, their log level and BLAS threads.

accelmo.config.TrackingDataConfig

Which tracking data the fit uses and how its turns are batched.

accelmo.config.TrackingParameters

What a tracking fit fits besides the magnet knobs, and every prior width.

accelmo.tracking.fitter.ArcByArcFitter

Fit magnet strengths from arc-by-arc BPM ranges.

accelmo.tracking.fitter.ACDMarkerFitter

Fit magnet strengths from AC-dipole data, tracked from the exciter markers.

accelmo.tracking.fitter.KickerFitter

Fit magnet strengths from kicker-excited turn-by-turn data.

accelmo.tracking.fitter.ACDSinusoidFitter

Fit AC-dipole data tracked forward over many turns through the model AC kickers.

accelmo.tracking.fitter.FitterOptions

Optional inputs shared by every tracking fitter.

accelmo.tracking.fitter.tracking_lm_config

The tracking LM solver: stops after several stalled steps, since early steps can be tiny.

accelmo.tracking.config.models.MeasurementConfig

Maps each measurement file to its MeasurementDetails.

accelmo.fitting.config.SequenceConfig

Configuration for the sequence segment used during optimisation.

accelmo.fitting.config.OutputConfig

Output and logging behaviour for optimisation runs.

accelmo.fitting.results.FitResult

Fitted knobs, their 1-sigma uncertainties (by knob name) and how the fit ended.

accelmo.poco.closed_orbit.ClosedOrbitFitter

Fit magnet knobs to absolute or reference-subtracted closed orbits.

accelmo.poco.closed_orbit.ClosedOrbitSeries

Measurements evaluated in one process at one machine state.

accelmo.poco.calibrated.CalibratedClosedOrbitFitter

ClosedOrbitFitter with (1 + b_bpm)(1 + g_corrector) calibration parameters.

accelmo.poco.closed_orbit.closed_twiss_series

One absolute closed-twiss series per measured momentum pt (key) and optics frame.

accelmo.optimisers.levenberg_marquardt.LevenbergMarquardtConfig

Configuration for a Levenberg-Marquardt Gauss-Newton solve.

Accelerators And Configuration

accelmo.machine

The accelerator and its MAD-NG model: machine definitions and the MAD-NG interfaces.

accelmo.machine.accelerators

Accelerator definitions for the supported machines (LHC, PSB, SPS, FCC).

accelmo.machine.accelerators.base

Base accelerator class defining the interface for all accelerators.

accelmo.machine.accelerators.lhc

LHC-specific accelerator implementation.

accelmo.machine.accelerators.psb

PSB-specific accelerator implementation.

accelmo.machine.accelerators.sps

SPS-specific accelerator implementation with generic optimisation targets.

accelmo.machine.accelerators.fcc

FCC-ee-specific accelerator implementation (LCC optics).

accelmo.machine.accelerators.magnet_grouping

Pure utilities for grouping accelerator magnets and their knob values.

accelmo.machine.accelerators.selection

CLI spelling and helpers for accelerator errors / misalignments selections.

accelmo.machine.patterns

Element-name patterns: the accelerators write Lua patterns, other backends match them as regex.

accelmo.machine.machine_state

The machine state a model is put in: name/value pairs applied to the model's globals.

accelmo.machine.knob_names

Names of settable magnet strengths (MQ.1.dk1l, BR.QFO11.dx), shared by every backend.

accelmo.config

Settings of the gradient-descent optimiser, the worker processes and the tracking fit.

Backends

The engine protocols are specified in Model backends.

accelmo.backend

Model backends: MAD-NG (madng) and xtrack (xtrack).

accelmo.backend.protocol

What the workers and the parent need from a model backend.

accelmo.backend.madng

MAD-NG backend: everything that imports pymadng or pymadng_utils.mad or sends Lua.

accelmo.backend.madng.interface

The MAD-NG session of accelmo: MadInterface.

accelmo.backend.madng.engines

MAD-NG tracking and closed-orbit engines (see accelmo.backend.protocol).

accelmo.backend.madng.accelerator_hooks

MAD-NG side of the accelerator definitions: Lua run around knob creation, per-kind track methods.

accelmo.backend.madng.machine_state

Read and assign machine-state globals (see accelmo.machine.machine_state) in a MAD-NG session.

accelmo.backend.madng.scripts

Helpers for loading or generating MAD-NG tracking scripts.

accelmo.backend.xtrack

xtrack TPSA backend: everything that imports xtrack.

accelmo.backend.xtrack.engines

xtrack TPSA tracking and closed-orbit engines (see accelmo.backend.protocol).

accelmo.backend.xtrack.model

The xsuite line of one accelerator: knobs as line variables, observed BPMs, machine state.

Closed-Orbit Fitting (POCO)

accelmo.poco

POCO: Parametric Optimisation of Closed Orbits.

accelmo.poco.closed_orbit

Closed-orbit fitter: LOCO-style machine-state comparisons and measured closed twiss.

accelmo.poco.calibrated

Closed-orbit fitter that also fits BPM gains and corrector kick calibrations (see accelmo.poco.calibration).

accelmo.poco.fitter

Levenberg-Marquardt base fitter of POCO and the measured-optics observables.

accelmo.poco.calibration

Measure map for BPM gain and corrector kick calibration in closed-orbit fits.

accelmo.poco.workers

MAD-NG worker processes of the closed-orbit and closed-twiss fitters.

accelmo.poco.workers.closed_orbit

Closed-orbit worker: absolute or reference-subtracted orbit series, and absolute closed-twiss series.

accelmo.poco.workers.closed_twiss

Closed-twiss observables and their weighted least-squares blocks.

accelmo.poco.workers.calibrated

Closed-orbit worker with BPM gain and corrector calibration parameters (see accelmo.poco.calibration).

accelmo.momentum_reference

Fit bends and quads to closed orbit + phase, and hand back a closed-orbit reference.

Tracking Fits

accelmo.tracking

Tracking fits: magnet knobs from turn-by-turn BPM data by mini-batch gradient descent.

accelmo.tracking.fitter

Tracking fitters that recover magnet knob strengths from turn-by-turn data.

accelmo.tracking.lm_problem

The tracking Levenberg-Marquardt objective: knobs, BPM gains and optionally the particle starts.

accelmo.tracking.session

The running workers of one tracking fit.

accelmo.tracking.ranges

The BPM ranges a tracking fit tracks between.

accelmo.tracking.data_manager

Measurement data loading and turn batching for the tracking optimisation.

accelmo.tracking.worker

Particle tracking worker for multi-turn beam dynamics simulations.

accelmo.tracking.dispatch

Turning the loaded data into tracking-worker payloads: range setup and turn planning.

accelmo.tracking.dispatch.payloads

Worker payload construction.

accelmo.tracking.dispatch.setup

Worker planning: the config of every worker for a set of BPM ranges and files.

accelmo.tracking.dispatch.turn_planner

Turn-batch planning for tracking workers.

accelmo.tracking.uncertainty

Stopping the training workers and folding their uncertainty parts into (A, B).

accelmo.tracking.ic_iteration

ACD sinusoid fits: single steps (IC or k free) and the joint fit with turn continuation.

accelmo.tracking.sgd

The mini-batch gradient-descent loop of the tracking fit, its schedule and checkpoints.

accelmo.tracking.sgd.loop

The mini-batch gradient-descent loop of the tracking fit.

accelmo.tracking.sgd.scheduler

Learning-rate schedulers used by optimisation fitters.

accelmo.tracking.sgd.checkpointing

Checkpoint persistence and knob-remapping for the optimisation loop.

accelmo.tracking.config

Configuration models and planning helpers for training fitters.

accelmo.tracking.config.helpers

Helper functions for creating fitter configurations.

accelmo.tracking.config.models

Configuration dataclasses for fitter initialization.

accelmo.tracking.config.tracking

Tracking-mode planning for arc-by-arc, kicker- and AC-dipole-excited runs.

Shared Fitting Base

accelmo.fitting

What both fitting engines share: machine setup, worker protocol and pool, run lifecycle, reduction, weights, uncertainties and results.

accelmo.fitting.setup

The model a fit runs on: backend model, BPM ranges and starting knobs.

accelmo.fitting.config

Configuration shared by every fitter: the lattice range and the output settings.

accelmo.fitting.protocol

The parent <-> worker protocol: typed messages and the parent-side channels that carry them.

accelmo.fitting.lm_loop

The Levenberg-Marquardt iteration shared by every closed-orbit / closed-twiss fitter.

accelmo.fitting.priors

Gaussian priors shared by the tracking and closed-orbit LM fits.

accelmo.fitting.worker

Abstract base class for all worker process types.

accelmo.fitting.shared_reference

Reference orbits computed once and shared with every closed-orbit worker through shared memory.

accelmo.fitting.pool

A pool of worker processes and the parent-side state kept for each one.

accelmo.fitting.worker_logging

Worker-process logging: a file per worker, with WARNING and above relayed to the parent.

accelmo.fitting.lifecycle

The run/interrupt/cleanup shape every fitter shares.

accelmo.fitting.reduction

Summing the workers' replies to one evaluation.

accelmo.fitting.weights

Inverse-variance loss weights.

accelmo.fitting.bpm_gains

BPM gains, shared by the closed-orbit (poco) and tracking fits.

accelmo.fitting.uncertainty

Knob uncertainties from the normal matrix A (and noise matrix B) of a fit.

accelmo.fitting.results

What a fit returns.

Optimisers And Numerical Helpers

accelmo.optimisers

Optimisation algorithms used by accelmo.

accelmo.optimisers.base

Abstract optimiser interface and best-point tracking.

accelmo.optimisers.adam

Adam optimiser implementation used by the training loop.

accelmo.optimisers.lbfgs

Limited-memory BFGS optimiser (no line search).

accelmo.optimisers.levenberg_marquardt

Levenberg-Marquardt optimiser for Gauss-Newton systems.

Analysis

accelmo.analysis

Analysis utilities that inspect a fit without changing the optimisation.

accelmo.analysis.degeneracy_checker

Detect degenerate (unconstrained) knob directions before optimising.

Run Logs And Monitor

accelmo.logs

One call to set up logging in the main process of a script.

accelmo.dashboard

A live terminal dashboard for a running fit; it knows nothing about machines or fitters.

accelmo.dashboard.fit

The live terminal dashboard of a gradient-descent fit.

accelmo.dashboard.plot

A log-scale line plot drawn with braille characters.

accelmo.runlog

Run logs: what a fit records while it runs, for live monitoring and later replay.

accelmo.runlog.reader

Reading run logs, including those of fits that are still running.

accelmo.runlog.writer

Writing a run log from inside a fit.

accelmo.monitor

Live monitor for fits: plots from run logs, with optics recomputed from the knobs.

accelmo.monitor.source

What the machine side supplies to the monitor.

accelmo.monitor.view

What a panel gets to draw from.

accelmo.monitor.cache

Computing optics from logged knobs in the background, and keeping the results.

accelmo.monitor.panels

Panels that work for any fit: they need only the run log, not the optics.

accelmo.monitor.app

The monitor web app: pick a stage and a step, see every panel for it.