Skip to content

Commit 3c1899a

Browse files
committed
Modified chromaticity example for BESSY II.
1 parent 3857a83 commit 3c1899a

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

examples/BESSY2_example/BESSY2Chroma.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ machine: sr
44
energy: 1.7e9
55
simulators:
66
- type: pyaml.lattice.simulator
7-
lattice: bessy2.mat
7+
lattice: bessy2_standard_user.mat
88
name: design
99
controls:
1010
- type: pyaml_cs_oa.controlsystem
11-
prefix: 'pons:'
11+
prefix: 'a3744:'
1212
name: live
1313
data_folder: /data/store
1414
devices:
@@ -26,10 +26,10 @@ devices:
2626
name: KSI
2727
betatron_tune: BETATRON_TUNE
2828
RFfreq: RF
29-
fit_order: 1
29+
fit_order: 2
3030
N_tune_meas: 1
3131
N_step: 5
32-
Sleep_between_meas: 0
32+
Sleep_between_meas: 2
3333
Sleep_between_RFvar: 2
3434
E_delta: 1e-3
3535
Max_E_delta: 1e-3
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "9be4d265",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": []
10+
}
11+
],
12+
"metadata": {
13+
"language_info": {
14+
"name": "python"
15+
}
16+
},
17+
"nbformat": 4,
18+
"nbformat_minor": 5
19+
}

examples/BESSY2_example/bessy2-chroma.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
1+
"""Chromaticity measurement
2+
3+
This example shows how to run chromaticity measurement using the simulator
4+
or the virtual accelerator.
5+
If you want to test the virtual accelerator you need to start the
6+
container before running the script.
7+
8+
"""
9+
110
import numpy as np
211

312
from pyaml.accelerator import Accelerator
413
from pyaml.common.constants import ACTION_MEASURE
514

15+
# ----- Load the configuration -----
16+
# Remember to change the prefix for the live mode to the one matching
17+
# your virtual accelerator before loading.
18+
19+
sr = Accelerator.load("BESSY2Chroma.yaml")
20+
21+
# ----- Define a callback -----
22+
# This callback is used to print output during the chromaticity measurement.
23+
624

725
def chroma_callback(step: int, action: int, rf: float, tune: np.array):
826
if action == ACTION_MEASURE:
927
print(f"Chromaticy measurement: #{step} RF={rf} Tune={tune}")
1028
return True
1129

1230

13-
sr = Accelerator.load("BESSY2Chroma.yaml")
31+
# ----- Get the momentum compaction factor-----
32+
# To get the momentum compaction from the model you need to first turn 6D off.
33+
1434
sr.design.get_lattice().disable_6d()
15-
# Retreive MCF from the model
1635
alphac = sr.design.get_lattice().get_mcf()
36+
sr.design.get_lattice().enable_6d()
1737
print(f"Moment compaction factor: {alphac}")
38+
39+
# ----- Measure the chromaticity-----
40+
# The measurement routing will also show a plot.
41+
1842
chromaticity_monitor = sr.live.get_chromaticity_monitor("KSI")
1943
chromaticity_monitor.measure(do_plot=True, alphac=alphac, callback=chroma_callback)
2044
ksi = chromaticity_monitor.chromaticity.get()

0 commit comments

Comments
 (0)