Chromaticity Measurement#

This tutorial shows how to measure the chromaticity.

Prerequisites#

The tutorial requires an existing pyAML configuration file which includes configuration of the chromaticity monitor.

The example uses the configuration provided by the pyaml-test-lattice package.

from pyaml.common.constants import Action
from pyaml_test_lattice import configurations

Load the Accelerator#

from pyaml.accelerator import Accelerator
accelerator = Accelerator.load(configurations["pyaml/tango/pyaml-cs-oa/fodo_1gev_6d_pyaml-oa.yaml"])

# Print the string representation of the accelerator
print(accelerator)
Accelerator(facility='Synchrotron SOLEIL', machine='sr', simulators=['design'], controls=['live'])

Control Mode Choice#

  • accelerator.design — runs pyAT locally, no control system needed. Set wait_time = 0.0.

  • accelerator.live — connects to the real machine or virtual twin. Set wait_time to allow readback settling (typically 1.5–2 s).

For live control mode you need a running control system or virtual accelerator. If you want to skip this, run the notebook in design` mode only.

# Use the design mode
SR = accelerator.design

# For live mode
# SR = accelerator.live

wait_time = 0.0 if SR == accelerator.design else 2.0

# Print the string representation of the simulator
print(SR)
Simulator(name='design', lattice='/opt/hostedtoolcache/Python/3.11.16/x64/lib/python3.11/site-packages/pyaml_test_lattice/data/lattice/fodo_1gev_6d.json', mat_key=None, n_elements=193)

Momentum Compaction Factor#

The momentum compaction factor is needed to convert RF frequency deviation to momentum deviation. It is computed from the lattice model (design mode).

accelerator.design.get_lattice().disable_6d()
alphac = accelerator.design.get_lattice().get_mcf()
accelerator.design.get_lattice().enable_6d()
print(f"Momentum compaction factor: αc = {alphac:.6e}")
Momentum compaction factor: αc = 9.187045e-02

Chromaticity Measurement#

The chromaticity monitor is named CHROMATICITY_MONITOR in the configuration. The measurement sweeps the RF frequency and fits the resulting tune shift.

Parameters:

  • alphac — momentum compaction factor (from lattice above)

  • fit_order — polynomial fit order (2 = quadratic)

  • n_step — number of RF frequency steps

  • sleep_between_meas / sleep_between_step — settling times (set to wait_time for live mode)

  • do_plot=True — show the tune vs. δp fit

def chroma_callback(action: int, cb_data: dict):
    if action == Action.MEASURE:
        print(f"Chromaticity: #{cb_data['step']} RF={cb_data['rf']:.2f} Hz, Tune={cb_data['tune']}")
    return True
chroma_monitor = SR.get_chromaticity_monitor("CHROMATICITY_MONITOR")

# Measure the chromaticity
chroma_monitor.measure(
    callback=chroma_callback,
    do_plot=True,
    alphac=alphac,
    fit_order=2,
    n_step=5,
    sleep_between_meas=wait_time,
    sleep_between_step=wait_time,
)

# Get the measured chromaticity
ksi = chroma_monitor.chromaticity.get()
print(f"Measured chromaticity: ξx = {ksi[0]:.3f}, ξy = {ksi[1]:.3f}")
0.0408 (dp/p)$^2$ + -0.0001 dp/p + 0.4399 , 1.1197 (dp/p)$^2$ + -0.0003 dp/p + 0.2848
Chromaticity: #0 RF=351642045.31 Hz, Tune=[0.43995006 0.28491609]
Chromaticity: #0 RF=351642045.31 Hz, Tune=[0.43995006 0.28491609]
Chromaticity: #0 RF=351642045.31 Hz, Tune=[0.43995006 0.28491609]
Chromaticity: #1 RF=351480666.02 Hz, Tune=[0.43994623 0.28482897]
Chromaticity: #1 RF=351480666.02 Hz, Tune=[0.43994623 0.28482897]
Chromaticity: #1 RF=351480666.02 Hz, Tune=[0.43994623 0.28482897]
Chromaticity: #2 RF=351319286.72 Hz, Tune=[0.43994507 0.28480055]
Chromaticity: #2 RF=351319286.72 Hz, Tune=[0.43994507 0.28480055]
Chromaticity: #2 RF=351319286.72 Hz, Tune=[0.43994507 0.28480055]
Chromaticity: #3 RF=351157907.42 Hz, Tune=[0.43994594 0.28482808]
Chromaticity: #3 RF=351157907.42 Hz, Tune=[0.43994594 0.28482808]
Chromaticity: #3 RF=351157907.42 Hz, Tune=[0.43994594 0.28482808]
Chromaticity: #4 RF=350996528.12 Hz, Tune=[0.43994825 0.28490893]
Chromaticity: #4 RF=350996528.12 Hz, Tune=[0.43994825 0.28490893]
Chromaticity: #4 RF=350996528.12 Hz, Tune=[0.43994825 0.28490893]
Measured chromaticity: ξx = -0.000, ξy = -0.000

Gallery generated by Sphinx-Gallery