Config files
pySC examples are configured with YAML files passed to generate_SC. A good
configuration starts with the error_table and the lattice: the
error_table defines the error model used to turn an ideal machine into a
simulated commissioning case, while the lattice defines the ideal machine
itself. After that, add the hardware families that pySC should expose as
controls.
Build the file in this order.
2. Select the lattice
latticeSelects the simulator and lattice file. For Accelerator Toolbox lattices, set
simulator: atand, when needed, the MATLAB variable name withuse.
For example:
lattice:
lattice_file: ../tests/machine_data/hmba32.mat
simulator: at
use: RING
If the same element family name appears more than once in the lattice, leave
naming unset so pySC uses index-based names. If the lattice has unique
device names in an element attribute, set naming to that attribute; for
example, use naming: Device when AT elements carry unique device names in a
Device field.
A hypothetical Xsuite lattice uses the same section but switches the simulator and points to an Xsuite line JSON file:
lattice:
lattice_file: my_machine_line.json
simulator: xsuite
Supported lattice options are:
lattice_filePath to the lattice input file.
simulatorLattice backend. Supported values are
atandxsuite.useAT-only option selecting the variable to load from a MATLAB lattice file. Defaults to
RINGwhen omitted.namingAT-only option selecting the element attribute used as the pySC element name. Omit it when names are not unique.
no_6dBoolean flag controlling whether pySC disables 6D tracking when loading the lattice. The default is
false.
3. Declare magnet controls
magnetsGroups lattice elements by regex or mapping and declares which components are controlled, such as
B2for quadrupoles,B3for sextupoles,B1for horizontal correctors, andA1for vertical correctors.
Each magnet group needs a selector and a list of controlled components. The
selector is usually a regular expression matched against lattice element names.
Each component points to an entry in error_table.
magnets:
quadrupoles:
regex: ^Q
components:
- B2: magnet_calibration
sextupoles:
regex: ^S[DF]
components:
- B3: magnet_calibration
- B1: magnet_calibration
- A1: magnet_calibration
Use separate groups when the same physical element type has different roles in commissioning. For example, sextupoles can provide sextupole strength controls and embedded corrector controls.
Supported magnet-family options are:
regexormappingSelects lattice elements for the family.
regexmatches lattice element names;mappingpoints to an explicit name-to-index mapping file.componentsList of controlled multipole components. Each component maps to an
error_tableentry ornull.invertList of declared components whose sign should be inverted.
limitsOptional control limits. Each listed component references a value from the top-level
parameterstable.dx,dy,dz,roll,yaw,pitchOptional element misalignment entries. Each value must reference an
error_tableentry.
Components without an L suffix are interpreted as non-integrated strengths.
Append L to use integrated strengths instead:
magnets:
quadrupoles:
regex: ^Q
components:
- B2L: magnet_calibration
Use invert when a control-system convention has the opposite sign from the
simulation convention. Every inverted component must also be listed under
components:
magnets:
sextupoles:
regex: ^S[DF]
components:
- B1: magnet_calibration
- A1: magnet_calibration
invert:
- B1
4. Declare BPMs
bpmsSelects BPM elements and defines calibration and noise settings.
For BPMs, select the monitor elements and reference the relevant error-table
entries. The double bpms: bpms: nesting is intentional: the first key is
the top-level BPM configuration section, and the second key is the name of one
BPM family. This is useful when a machine has multiple BPM families with
different error models.
bpms:
bpms:
regex: ^BPM
calibration_error: bpm_calibration
orbit_noise: orbit_noise
tbt_noise: tbt_noise
Supported BPM-family options are:
regexormappingSelects the BPM elements.
regexmatches lattice element names;mappingpoints to an explicit name-to-index mapping file.calibration_errorError-table entry used for BPM calibration errors in both planes.
orbit_noiseError-table entry used for closed-orbit BPM noise.
tbt_noiseError-table entry used for turn-by-turn BPM noise.
dx,dy,rollOptional BPM misalignment entries. Each value must reference an
error_tableentry. For thin BPM elements these are the physically useful alignment terms: transverse offsets and roll. Longitudinal shifts and pitch or yaw are support-system fields in pySC, but they are usually not meaningful for BPMs modeled as thin monitors.
For example, two BPM families can be configured as:
bpms:
arc_bpms:
regex: ^BPM
calibration_error: bpm_calibration
orbit_noise: orbit_noise
tbt_noise: tbt_noise
id_bpms:
regex: ^IDBPM
calibration_error: bpm_calibration
orbit_noise: orbit_noise
tbt_noise: tbt_noise
5. Declare support systems
supportsDefines alignment errors for support structures such as girders. Supports are configured as a list because a machine can have several support levels or families.
Each support entry defines a level, a pair of endpoint selectors, and the
alignment errors to apply. The error values reference entries in
error_table.
supports:
- level: 1
start_endpoints:
regex: GS
end_endpoints:
regex: GE
name: Girder
dx: girder_offsets
dy: girder_offsets
roll: girder_rolls
alignment: absolute
Supported support options are:
levelSupport hierarchy level. For example,
level: 1creates anL1support family.start_endpointsandend_endpointsSelect the start and end elements for each support. They use the same selector style as magnets and BPMs, usually
regexormapping.nameOptional family name used instead of the default level name.
dxanddyHorizontal and vertical support endpoint offsets. Each value must reference an
error_tableentry.rollSupport roll error. The value must reference an
error_tableentry.alignmentEither
absoluteorrelative. Withabsolutealignment, start and end offsets are drawn independently from the configured distribution. Withrelativealignment, pySC scales the endpoint offset sigma by \(1/\sqrt{2}\) so the relative offset between endpoints has the requested sigma.
6. Declare RF systems
rfSelects RF cavities, groups them into RF systems, and references RF error entries from
error_table.
For RF, select the cavity elements. The group name, such as main, becomes
the RF system name in pySC. Phase and frequency errors are optional fields in
the schema, but should be listed explicitly in commissioning configurations so
the RF error model is visible in the YAML file:
rf:
main:
regex: ^RFC$
frequency: rf_frequency
phase: rf_phase
The referenced rf_frequency and rf_phase entries are defined in
error_table. Set them to zero for an ideal RF model.
Supported RF-system options are:
regexormappingSelects RF cavities.
regexmatches lattice element names;mappingpoints to an explicit name-to-index mapping file.voltageError-table entry for cavity voltage errors.
phaseError-table entry for cavity phase errors.
frequencyError-table entry for cavity frequency errors.
7. Define injection settings
injectionDefines the injected beam coordinates, beam parameters, and injection jitter used by tracking-based workflows.
When from_design is true, pySC initializes the injection coordinates and
Twiss parameters from the design lattice at the start of the ring. Individual
values can still be overridden explicitly.
Injection errors are configured differently from the other commissioning
errors. Magnet, BPM, RF, and support errors reference values from
error_table; injection errors must be written directly in the injection
section with fields such as x_error_syst or x_error_stat.
injection:
from_design: true
emit_x: 1e-9
emit_y: 1e-11
bunch_length: 3e-3
energy_spread: 1e-3
n_particles: 1000
x_error_syst: 1e-4
px_error_stat: 2e-5
Supported injection options are:
from_designBoolean flag. When true, initialize coordinates and Twiss parameters from the design lattice. Defaults to true.
x,px,y,py,tau,deltaExplicit injected beam coordinates.
betx,alfx,bety,alfyExplicit injected beam Twiss parameters.
emit_xandemit_yHorizontal and vertical geometric emittances.
bunch_lengthandenergy_spreadLongitudinal beam size parameters.
n_particlesNumber of particles used when generating injected bunches.
x_error_syst,px_error_syst,y_error_syst,py_error_syst,tau_error_syst,delta_error_systSystematic injection errors.x_error_stat,px_error_stat,y_error_stat,py_error_stat,tau_error_stat,delta_error_statShot-to-shot injection jitter.
8. Define tuning families
tuningTells pySC which declared magnet controls should be used by correction and tuning algorithms.
The tuning section does not create new controls. It selects from controls
already declared under magnets. The keys on the left, such as
sextupoles and quadrupoles, must match groups declared under
magnets. The values, such as B1L and B2, must match components
declared in those groups.
tuning:
HCORR:
- sextupoles: B1
- correctors: B1
VCORR:
- sextupoles: A1
- correctors: A1
model_RM_folder: ./model_RM
multipoles:
- sextupoles: B3
- octupoles: B4
bba_magnets:
- quadrupoles: B2
tune:
controls_1:
regex: ^QD2
component: B2
controls_2:
regex: ^QF1
component: B2
c_minus:
controls:
- sextupoles: A2
HCORRandVCORRHorizontal and vertical corrector families. These are lists because a machine may use several magnet families as correctors. The selected controls are sorted by lattice position.
model_RM_folderFolder used when loading or saving model response matrices.
multipolesMagnet controls used as nonlinear multipoles, for example sextupole
B3and octupoleB4components.bba_magnetsMagnet controls used for beam-based alignment workflows. These are usually quadrupole
B2controls, and can be split across multiple quadrupole families.tuneDefines two quadrupole control families for tune correction. Each family uses a
regexormappingselector plus acomponent. The resulting controls must already exist from themagnetssection.c_minusDefines skew-quadrupole-like controls used for coupling correction. As with the other tuning families, the listed magnet groups and components must have been declared under
magnets.
The HMBA example configuration is a compact template:
error_table:
magnet_calibration: 0
bpm_calibration: 0
orbit_noise: 0
tbt_noise: 0
rf_frequency: 0
rf_phase: 0
lattice:
lattice_file: ../tests/machine_data/hmba32.mat
simulator: at
use: RING
magnets:
quadrupoles:
regex: ^Q
components:
- B2: magnet_calibration
sextupoles:
regex: ^S[DF]
components:
- B3: magnet_calibration
- A2: magnet_calibration
- B1: magnet_calibration
- A1: magnet_calibration
correctors:
regex: ^SH
components:
- B1: magnet_calibration
- A1: magnet_calibration
octupoles:
regex: ^O
components:
- B4: magnet_calibration
bpms:
bpms:
regex: ^BPM
calibration_error: bpm_calibration
orbit_noise: orbit_noise
tbt_noise: tbt_noise
rf:
main:
regex: ^RFC$
frequency: rf_frequency
phase: rf_phase
tuning:
HCORR:
- sextupoles: B1
- correctors: B1
VCORR:
- sextupoles: A1
- correctors: A1
model_RM_folder: ./model_RM
multipoles:
- sextupoles: B3
- octupoles: B4
bba_magnets:
- quadrupoles: B2
tune:
controls_1:
regex: ^QD2
component: B2
controls_2:
regex: ^QF1
component: B2
c_minus:
controls:
- sextupoles: A2