accelmo.poco.workers.closed_orbit

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

class accelmo.poco.workers.closed_orbit.ClosedOrbitMeasurementData(observables, pt=0.0, reference_pt=0.0)[source]

Bases: object

Internal prepared measurement and the model states it compares.

Parameters:
  • observables (list[Observable])

  • pt (float)

  • reference_pt (float)

observables: list[Observable]
pt: float = 0.0
reference_pt: float = 0.0
class accelmo.poco.workers.closed_orbit.ClosedOrbitSeriesData(bpm_names, measurements, machine_state=dict(), reference_state=dict(), absolute_planes=(), calibration=None, shared_reference=False, reference_only=False)[source]

Bases: object

Internal worker payload for measurements sharing a machine state.

Parameters:
  • bpm_names (list[str])

  • measurements (list[ClosedOrbitMeasurementData])

  • machine_state (dict[str, float])

  • reference_state (dict[str, float])

  • absolute_planes (tuple[str, ...])

  • calibration (CalibrationSpec | None)

  • shared_reference (bool)

  • reference_only (bool)

bpm_names: list[str]
measurements: list[ClosedOrbitMeasurementData]
machine_state: dict[str, float]

Model globals (quadrupole strengths, corrector kicks, …) this series is measured at.

reference_state: dict[str, float]

The state the reference orbit is solved at; a relative plane is the change from it to machine_state.

absolute_planes: tuple[str, ...] = ()
calibration: CalibrationSpec | None = None

Gain layout for CalibratedClosedOrbitWorker.

shared_reference: bool = False

Take the reference orbit from the reference worker (see accelmo.fitting.shared_reference) instead of solving it here. The worker then expects one reference message per iteration.

reference_only: bool = False

This worker only solves and publishes the reference orbits, once per iteration, for every series.

property needs_reference: bool

Whether any orbit plane of this series is fitted relative to a reference state.

class accelmo.poco.workers.closed_orbit.SeriesState(index, data, observables, measured_index, subtract, twiss_bpm_order=None, alignment=None)[source]

Bases: object

What a worker keeps for one of its series: the prepared data and its alignment to the model BPMs.

Parameters:
  • index (int)

  • data (ClosedOrbitSeriesData)

  • observables (list[Observable])

  • measured_index (dict[str, int])

  • subtract (numpy.ndarray)

  • twiss_bpm_order (list[str] | None)

  • alignment (list[tuple[list[Observable], Any, Any]] | None)

index: int

Position of the series in its worker; part of the closed-orbit warm-start key.

data: ClosedOrbitSeriesData
observables: list[Observable]

Observables of every measurement of the series, in the order the rows are evaluated.

measured_index: dict[str, int]
subtract: ndarray

1 for an orbit plane fitted relative to the reference state, 0 for an absolute one.

twiss_bpm_order: list[str] | None = None

Model BPM order the alignments below were made for.

alignment: list[tuple[list[Observable], Any, Any]] | None = None

(observables, targets, weights) in model BPM order.

Type:

Per measurement

aligned()[source]

The model BPM order and per-measurement (observables, targets, weights).

Return type:

tuple[list[str], list[tuple[list[Observable], Any, Any]]]

align(twiss_names, worker_id)[source]

Align every measurement’s targets and weights to the model BPM order.

Return type:

None

Parameters:
  • twiss_names (list[str])

  • worker_id (int)

accelmo.poco.workers.closed_orbit.validate_series(data)[source]

Check a series’ measurements, observables and planes.

Return type:

None

Parameters:

data (ClosedOrbitSeriesData)

class accelmo.poco.workers.closed_orbit.ClosedOrbitWorker(conn, worker_id, data, config, runtime)[source]

Bases: AbstractWorker[list[ClosedOrbitSeriesData], WorkerConfig]

Fit one or more closed-orbit series in one engine.

Each series is a ClosedOrbitSeriesData: its machine state and all its measurements. Every measurement keeps its own target, signal momentum and reference momentum. The losses, gradients and Hessians of the series are summed, so the fit is the one a process per series would give. Repeated model states are cached within one series evaluation only.

Parameters:
  • conn (Connection)

  • worker_id (int)

  • data (WorkerDataType)

  • config (ConfigType)

  • runtime (WorkerRuntime)

PT_STEP = 1e-06

Step of the forward difference giving the orbit’s pt derivative when pt is fitted.

on_start(knobs)[source]

Build the engine and note whether pt is a fitted knob (always the last one).

Return type:

None

Parameters:

knobs (dict[str, float])

prepare_data(data)[source]

Store the measured series of this worker.

Return type:

None

Parameters:

data (list[ClosedOrbitSeriesData])

close()[source]

Close the engine.

Return type:

None

evaluate(message)[source]

Sum the loss, gradient and Hessians of every series at message.knobs.

Return type:

GradReply

Parameters:

message (Evaluate)