accelmo.backend.xtrack.model¶
The xsuite line of one accelerator: knobs as line variables, observed BPMs, machine state.
Element names are upper case on the accelmo side (as in MAD-NG) and lower case in xsuite.
Knobs keep the MAD-NG names (<ELEMENT>.dk1l, .dk0l, .kick) and the integrated
convention: dk1l adds dk1l / L to the quadrupole k1.
- accelmo.backend.xtrack.model.madx_element_kinds(sequence_file)[source]¶
Base MAD-X kind of every element declared in a sequence file (upper-case names).
- Return type:
dict[str,str]- Parameters:
sequence_file (Path)
- class accelmo.backend.xtrack.model.XtrackModel(accelerator, *, magnet_range='$start/$end', bpm_range=None, bad_bpms=None, machine_state=None, initial_model_values=None)[source]¶
Bases:
objectOne xsuite line with knobs;
lineis rebuilt bycycle_to_start().- Parameters:
accelerator (Accelerator)
magnet_range (str)
bpm_range (str | None)
bad_bpms (Sequence[str] | None)
machine_state (MachineState | None)
initial_model_values (Mapping[str, float] | None)
- set_knob_values(values)[source]¶
Set knob variables of the environment by name.
- Return type:
None- Parameters:
values (Mapping[str, float])
- apply_initial_model_values(values)[source]¶
Knob values;
ptis not a model value here.- Return type:
None- Parameters:
values (Mapping[str, float])
- get_vars(names)[source]¶
Current values of variables or
<element>.<attribute>names.- Return type:
dict[str,float]- Parameters:
names (Sequence[str])
- set_vars(state)[source]¶
Set variables or
<element>.<attribute>names (a machine state).- Return type:
None- Parameters:
state (Mapping[str, float])
- recount_bpms()[source]¶
Observed BPMs (pattern, not bad) in line order: all, and inside
bpm_range.- Return type:
None
- cycle_to_start(marker)[source]¶
Start the line at
marker; a thick element becomes drift, marker, drift (as MAD-NG).- Return type:
None- Parameters:
marker (str)
- remove_zero_field_magnets()[source]¶
Replace thick zero-field magnets by exact drifts and merge neighbouring drifts; returns how many removed.
As the MAD-NG
build_zero_field_removal_script: call it once machine state and knobs are installed: a magnet whose strength comes from a variable later changed (not a knob) would stay a drift. A magnet carrying a knob, or misaligned, is kept.- Return type:
int