accelmo.backend.madng.scripts¶
Helpers for loading or generating MAD-NG tracking scripts.
- accelmo.backend.madng.scripts.SET_KNOBS_PLAIN = 'local v = python:recv()\nfor i, name in ipairs(set_names) do loaded_sequence[name] = v[i] end'¶
Set knobs from
set_namesand one received vector;plainassigns numbers, not TPSA constants.
- accelmo.backend.madng.scripts.dump_debug_script(script_name, text, *, debug, mad_logfile=None, worker_id=None)[source]¶
Write a generated MAD script to disk when debug mode is enabled.
- Return type:
Path|None- Parameters:
script_name (str)
text (str)
debug (bool)
mad_logfile (Path | None)
worker_id (int | None)
- accelmo.backend.madng.scripts.build_zero_field_removal_script()[source]¶
Lua that removes thick zero-field magnets; the gaps are tracked as implicit drifts.
Run after machine state and TPSA knobs are installed. An element carrying a knob is never removed (its strength is TPSA), nor is one whose strength is a deferred expression, which a machine-state variable can still change.
- Return type:
str
- accelmo.backend.madng.scripts.build_track_speedup_script(track_methods)[source]¶
Remove zero-field magnets and set per-kind track methods.
- Return type:
str- Parameters:
track_methods (dict[str, int])
- accelmo.backend.madng.scripts.build_tracking_init_script(observables, *, start_on_first_turn=False)[source]¶
Build the tracking initialisation script for the requested observables.
- Return type:
str- Parameters:
observables (tuple[str, ...])
start_on_first_turn (bool)
- accelmo.backend.madng.scripts.build_tracking_script(observables, *, include_start_derivatives=False)[source]¶
Build the tracking script for the requested observables.
include_start_derivativesalso sendsd{o}_dc0; the caller must setsave_start_derivatives = truein MAD first.- Return type:
str- Parameters:
observables (tuple[str, ...])
include_start_derivatives (bool)
- accelmo.backend.madng.scripts.build_tracking_preflight_script()[source]¶
Build the single-particle preflight script.
Tracks one particle through the configured range/turns with a counting
atexitand reports how many BPM points were observed. The worker compares this against the allocated result-vector size (nbpms * n_run_turns) once, before the optimisation loop, so an observe/range misconfiguration fails with a clear message here instead of as an opaquesetiindex-out-of-bounds deep in a tracking run. Observable-independent: only the observation geometry matters.- Return type:
str