This is Content
a preprint— thepublished
with
IOP of the CC-BY-4.0 licence (© 2023). Any distribution of this work must maintain attribution to the author(s), title of the work, publisher, and DOI
fromthis final
work version
may be isusedunder theterms

12th Int. Beam Instrum. Conf.
ISBN: 9 7 8 - 3 - 9 5 4 5 0 - 2 3 6 - 3

IBIC2023, Saskatoon, Canada
JACoW Publishing
ISSN: 2 6 7 3 - 5 3 5 0
d o i : 1 0 . 1 8 4 2 9 / J A C o W - I B I C 2 0 2 3 - M O P 0 3 6

A NEW APPROACH FOR CANADIAN LIGHT SOURCE FUTURE
ORBIT CORRECTION SYSTEM DRIVEN BY NEURAL NETWORKS. Saadat∗ and M. J. Boland1 , Canadian Light Source, Saskatoon, Canada
1 also at University of Saskatchewan, Saskatoon, Canada
Abstract
The orbit correction system (OCS) of the Canadian Light
Source (CLS) comprises of 48 sets of BERGOZ beam position monitors (BPM). Each BPM has the ability to measure
the position of the beam in both the 𝑋 and 𝑌 directions andcan record data at a rate of 900 Hz times per second. Inverse
Response Matrix (IRM) is utilized to determine the optimal
strength of the 48 sets of orbit correctors in both the 𝑋 and𝑌 directions, in order to ensure that the beam follows its
desired path. The suggestion in this study is to replace thesingular value decomposition (SVD) function with a neuralnetwork algorithm, which will act as the central processing
unit of the orbit correction system. The training model’s
design includes three hidden layers, and within each layer,
there are 96 nodes. The neural network’s outputs for regular operations in CLS exhibit a mean square error (MSE)of 10−7 . Various difficult scenarios were created to test the
OCS at 8.0 mA, using offsets in different sections of the storage ring. However, the new model was able to produce thenecessary orbit correctors (OC) signals without any trouble.

INTRODUCTION
The CLS synchrotron light source storage ring consistsof twelve sections and operates at a 2.9 GeV energy level.
To maintain the stability of the beam position in the storage
ring, an Orbit Correction System is utilized to correct any
disturbances.
In 2000, the Motorola single-board computer was the initial implementation of a real-time controller [1]. In 2008, theprevious system for correcting the orbit was upgraded andreplaced by the current OCS [2]. In 2009, CLS developed
and tested a new orbit correction system the CLS Matlab
application, known as CLSORB, with a high-speed capability [3]. This system offers an adjustable rate range of 20 Hz
to 100 Hz.
The OCS at CLS comprises a computer that runs Matlab, along with four Versa Module Eurocards (VMEs). Each
VME corresponds to three sections of the storage ring. Additionally, the system also incorporates a Real-Time Executive
for Multiprocessor System (RTEMS). The purpose of thisadvanced system is to ensure that any disturbances caused
by electron perturbations are immediately detected and corrected to maintain beam stability and optimal light quality atthe beamlines. Hardware and software of the orbit control
systems were developed until the RMS deviation of beam
motion was reduced to less than one micrometer in both the
𝑋 and 𝑌 directions. The Accelerator Operations and Development (AOD) team is currently working on upgrading∗ shervin.saadat@lightsource.ca

this system, which suggests that there are new developments
underway to enhance its functionality and capabilities. This
involves improving its efficiency, increasing its accuracy,
or adding new features to meet the evolving needs of users.
With technological advancements being made every day, it
is important to keep upgrading existing systems to stay relevant and efficient in a rapidly changing landscape. The AOD
team has embarked on new research to design a Dynamic
Orbit Correction System (DOCS) based on Neural Network(NN) algorithm for the orbit correction system. The NN
correction system offers advantages over the IRM algorithm,
excelling in dynamic adaptability, flexible programming, andcomputation speed. Unlike the static IRM, the NN system
learns from data, making it accurate in changing conditions.
Its adaptable nature handles misalignments effectively. The
NN’s efficient script allows customization and rapid computations, while IRM’s matrix recalculations slow it down.
The precision and real-time capabilities of this DOCS havebeen reported [4]. The aim of this research is to improve theaccuracy of the neural network model by incorporating deeplearning techniques. To achieve this goal, we will conduct
experiments and analyze the data to determine the effects ofdeep learning methods on accuracy.

NEURAL NETWORK
A neural network is a type of machine-learning model
inspired by the structure and function of the human brain.
It consists of interconnected nodes or neurons that process
information to make predictions or decisions [5]. Also, deeplearning is a subfield of machine learning that uses neuralnetworks with multiple layers to extract and learn featuresfrom data. It is capable of automatically discovering complex
patterns and relationships in large datasets [6].
The following sections will briefly discuss the neural network architecture and parameters utilized in the CLS orbit
correction system model, and also provide a definition ofdeep learning loops.

Network Architecture
Designing a neural network architecture requires a significant amount of information about the real system it will
be applied to, as the architecture is highly dependent on thespecific characteristics and structure of the system. In brief,
the CLS orbit correction system is comprised of 96 Bergoz
Beam Position Monitors (BPMs) that transmit the beam’s
position to the IRM at a frequency of 900 measurements
per second. The IRM serves as the central processing unitof the OCS, responsible for computing the strength of the
Orbit Correctors. Ultimately, the 96 outputs from the IRM

MOP036102

08 Feedback Systems and Beam Stability

IBIC2023, Saskatoon, Canada
JACoW Publishing
ISSN: 2 6 7 3 - 5 3 5 0
d o i : 1 0 . 1 8 4 2 9 / J A C o W - I B I C 2 0 2 3 - M O P 0 3 6

are transmitted to the 96 orbit correctors at a rate of 18 transmissions per second.
In the first step, we designed a neural network algorithm instead of using IRM. For this case, we utilized the TensorFlowKeras library in Python, which is renowned for its speed andis considered one of the fastest AI modules. The neuralnetwork consists of three hidden layers with 96 nodes, andthe best activation function was found to be hyperbolic tangent. After a single learning step with 20 epochs, the model
achieved a MSE of (3.152 × 10−7 ). The Mean Squared Error
is a loss function that measures the average squared difference between the predicted values and the actual target
values in the training dataset.

Deep Learning Loops
The initial model performed well, and its real-time capabilities were tested on actual data, exhibiting negligible
error when the system was in a stable mode. In addition
to the aforementioned scenario, there is another situationthat should be taken into account, when the beam positionchanges significantly. In this case, the neural network model
must be capable of adapting to these changes in order toprovide accurate predictions. Therefore, it is essential toensure that the model is trained using a diverse set of datathat encompasses a wide range of beam positions and conditions. This will enable the model to effectively learn andgeneralize to new and unseen scenarios, including cases
where the beam position changes drastically. In this study,a learning loop was designed to address the issue at hand.
The loop begins by loading the initial model, after which a
new dataset is evaluated using the model. If the error of themodel’s output exceeds the expected value, the model is updated with new epochs and activation functions as necessary.
Finally, Fig. 1 the accuracy of the updated model is checked,
and it replaces the previous model if it performs better.

Figure 1: The BPM and OCV datasets from the real system
are fed into the learning loops. The NN model uses the
BPMs to generate new OCVs, and the error between thepredicted and real OCVs is calculated. If the error exceeds
the expected threshold, the NN model is updated with thecurrent dataset and replaces the old NN model. This loop is
repeated periodically to refine the NN model.

EXPERIMENTS AND RESULTS
The CLS storage ring is comprised of twelve distinct sections, each of which contains four BPMs and four OCs withboth 𝑥 and 𝑦 directions. This configuration yields a totalof 96 inputs and 96 outputs for the orbit correction system.
Figure 2 shows a schematic of BPMs configuration in thestorage ring. Ninety-six inputs, which correspond to BPMs,
are recorded at a rate of 900 Hz, while the system generates
ninety-six outputs, which correspond to OCs, at a rate of
18 Hz.
There are two scenarios that we have assumed for thesystem. In the first scenario, the system operates in a stablemode, and the learning loop attempts to improve its model
accuracy. In the second scenario, the stable mode changes tovarying positions, and the learning loop modifies the model
to prepare for the future. In this research, we investigatedthe deep learning capabilities of the DOCS platform. Due tothe lack of available real-time data, we collected data fromthe EPICS at the CLS using a sampling frequency of 900 Hz
for BPMs and 18 Hz for OCs. The collected data was saved

Figure 2: schematic of the CLS (Canadian Light Source)
storage ring that comprises twelve sections and 48 BPMs.
in large JSON files, which were then split into smaller files
for use in our deep-learning model.
In the first scenario, when the system is functioning normally, we conducted the learning loop four times. During
the first phase, we developed the model, while the second to
fourth phases involved updating the model. In addition, we
introduced a metric called Accumulated Error (AE), which
represents the sum of errors across all OCs. The calculation of AE involves taking the absolute difference between
the real value of the orbit corrector and the predicted OC,
divided by the real data.

MOP03608 Feedback Systems and Beam Stability

103

from
this final
work version
may be isusedunder thetermsThis is Content
a preprint— thepublished
with
IOP of the CC-BY-4.0 licence (© 2023). Any distribution of this work must maintain attribution to the author(s), title of the work, publisher, and DOI

12th Int. Beam Instrum. Conf.
ISBN: 9 7 8 - 3 - 9 5 4 5 0 - 2 3 6 - 3

This is Content
a preprint— thepublished
with
IOP of the CC-BY-4.0 licence (© 2023). Any distribution of this work must maintain attribution to the author(s), title of the work, publisher, and DOI
fromthis final
work version
may be isusedunder theterms

12th Int. Beam Instrum. Conf.
ISBN: 9 7 8 - 3 - 9 5 4 5 0 - 2 3 6 - 3

IBIC2023, Saskatoon, Canada
JACoW Publishing
ISSN: 2 6 7 3 - 5 3 5 0
d o i : 1 0 . 1 8 4 2 9 / J A C o W - I B I C 2 0 2 3 - M O P 0 3 6
Table 1: Some of the adjustments made to the reference oroffset (µm) were shown to demonstrate the change in BPM
values across different sections of the SR. ’H’ and ’V’ referto the horizontal and vertical detectors, respectively.

(a)

(c)

(b)

Experiment No. Section

Our developed model demonstrates excellent performance, with an AE of 109.72 %. When applied to the
96 OCs, the error rate per OC is estimated to be approximately 1.1 %. Figure 3(a) suggests that the model is robust
and reliable in predicting values for the given dataset. We
implemented the deep learning loops step by step, beginning with an upgrade without any changes in the epochs
and architecture. Remarkably, the AE decreased to 73.06 %,indicating a significant improvement in performance. This
corresponds to an error rate of approximately 0.76 % perorbit corrector, which is substantially lower than the previous error rate. Figure 3(b) demonstrates the efficacy of the
deep learning approach in improving the accuracy of themodel. Continuing with the upgrade, we observed in theFig. 3(c) a further improvement in the model’s performance.
The AE decreased to 50.59 %, which equals an error rate of
approximately 0.53 % per OC. 4th upgrade, we observed in
the Fig. 3(d) again more improvement in the performance.
The AE decreased to 40.48 %, or 0.42 % per OC.
In the following scenario, the beam position is expected toundergo a sudden change, presenting a challenging situation
for the OCS. We aim to investigate whether this loop can
update a model with memorized coefficients, furthermore,
we will calculate the error that arises during this process. The
objective of this experiment is to evaluate the effectivenessof the updates to the NN model, and to assess whether they
result in a decreasing or increasing trend in performance.
At the CLS, a total of four BPMs and four OCs are installed in each section of the storage ring. Each BPM isequipped with both Horizontal (H) and Vertical (V) detectors. Specifically, BPM01–04 are located in section one, andBPM05–08 are installed in section two, and similarly, theBPMs configuration is repeated throughout the remaining
sections as shown in Fig. 2.

Offset (µm)

1

1

BPM 01 (H)BPM 01 (V)

+1000
-1000

2

1

BPM 01 (H)BPM 01 (V)

+500
+500

19

BPM 01-08 (H)BPM 01-08 (V)BPM 09-16 (H)BPM 09-16 (V)BPM 17-24 (H)BPM 17-24 (V)ALL
BPM 25-32 (H)BPM 25-32 (V)BPM 33-40 (H)BPM 33-40 V)
BPM 41-48 (H)BPM 41-48 (V)

+500
+500
-1000
-1000
+500
+500
-1000
-1000
-1000
-1000
-1000
-1000

20

ALL

BPM 01-48 (H)BPM 01-48 (V)

Rand.
Rand.

(d)

Figure 3: The blue line represents the actual data for 96 OCs
obtained through the SVD algorithm. The orange line represents the predicted values for the same OCs obtained throughNN models. The green line shows the difference between theactual and predicted values. The green value corresponds
to the total error (AE) calculated across all 96 OCs. The
horizontal axis shows the 96 orbit correctors. (a) The firstmodel, (b) the first upgrade, (c) the 2nd modification, (d)t6he 3rd upgrade.

BPMs

In this experiment, the BPM’s values in different sectionsof the SR were changed by adjusting the reference (offset)
to create a desired beam position situation (+1 and –1 mm)
for the OC system. The system was tested at a beam currentof 8.0 mA. Table 1 displays the alterations to the reference(offset) and how they reveal variations in BPM values acrossdistinct SR sections.
The OCS’s performance was recorded in the aforementioned scenarios for both BPMs and OCs. This data wassubsequently utilized to learn, train, test, and develop DOCS.
In this research, we tested several assumptions and foundthat the results of all of them were the same. Here, we
present one of these results. In the first scenario, the beam
is in the position that corresponds to test 1 in the Table 1.
The NN model was developed (with 80 epochs and the samearchitecture) for this situation, and we consider it to be ourinitial model which has 1.184 % error per OC as shown in
Fig. 4(a). The learning loop attempts one upgrade and generates an NN-upgraded model with an error rate of 0.515 %per OC as shown in Fig. 4(b). Following that, a disturbanceoccurs, and the system transitions into the mode detailed in
test 20 of Table 1. The NN model was updated twice during
this period, as depicted in Figs. 4(c) and 4(d). The turbulence is controlled, and the perturbation sequence returns tomode 1, the NN model has upgraded twice again shown in
Figs. 4(e) and 4(f). Finally, the system experiences a period
of instability, during which the perturbation sequence exhibits unpredictable behavior. As a result, the learning loop
generates two new updates for the NN model, as shown in
Figs. 4(g) and 4(h).

MOP036104

08 Feedback Systems and Beam Stability12th Int. Beam Instrum. Conf.
ISBN: 9 7 8 - 3 - 9 5 4 5 0 - 2 3 6 - 3

(a)

(b)

(c)

(d)

(e)

(f)

(g)

(h)

Figure 4: The blue line represents the actual data for 96 OCs
obtained through the SVD algorithm. The orange line represents the predicted values for the same OCs obtained throughNN models. The green line shows the difference between theactual and predicted values. The green value corresponds
to the mean error for each OC. The horizontal axis shows
the 96 orbit correctors. (a) The first model, (b) 1st upgrade,(c) 2nd upgrade , (d) 3rd upgrade, (e) 4th upgrade, (f) 5th
upgrade, (g) 6th upgrade, (h) 7th upgrade.
The scenario described, demonstrates that updates to the
NN model’s weight parameters are effective, resulting in astatistically significant decrease in error rates over time.

CONCLUSION
Two conditions of the NN model’s effectiveness were investigated, a stable mode and a complex mode. The results
for the stable mode demonstrate that error rates decrease overtime, from 1.1 % per OC in the first experiment to 0.42 %per OC after four steps. While this result was expected, it
provides further confirmation of the effective operation of
the deep learning loops in the NN model, which successfully
reduce error rates over time in the stable mode condition.
The results of the second scenario are less definitive thanthose of the stable mode upgrade, as shown in Fig. 5. However, they do display a decreasing trend in error rates despitesome fluctuations.
Figure 5 shows a decreasing trend in prediction errors fora specific data set (upgrades 1 and 2), but the deep learning model is unable to generalize its performance to new

Figure 5: Errors (percentage per OC) are displayed in eight
upgraded steps. The blue dots represent the mean errors ineach step, the red line shows the trend of the errors.
data sets (upgrade 3) without further training. However,next step training result in reduced errors on new data sets
(upgrades 4 and 5). This cycle continues, and the errors
decrease smoothly over time. The results demonstrate that
the NN model is highly effective, and the Deep Learning
loop successfully increasing the model’s precision. While
the results show promise and suggest that the NN model
could be a valuable technology for various applications, it isimportant to acknowledge the limitations of our study andthe need for further research to thoroughly explore its capabilities and potential applications. The current findings,
while encouraging, should be viewed with a degree of restraint, and additional studies are warranted to establish thefull extent of the NN model’s benefits and limitations.

ACKNOWLEDGEMENTS
The authors would like to thank Tonia Batten, Johannes
Vogt, Ward Wurtz, Cameron Baribeau, Hamed Shaker, Drew
Bertwistle, Mike Bree, and Fredric Le Pimpec, as well as
all other AOD members of the CLS operation group.

REFERENCES[1] L. Dallin, I. Blomqvist, M. de Jong, D. Lowe, and M. Silzer,“The Canadian Light Source”, in Proc. PAC’03, Portland, OR,
USA, May 2003, paper TOPA001.
[2] D. Chabot, “SR1 Orbit Control Design Note”, CLS Document,
2008.
[3] C.G. Payne and D. Chabot, “Fast Orbit Correction at the Canadian Light Source”, in Proc. PCaPAC’10, Saskatoon, Canada,
Oct. 2010, paper WECOMA02, pp. 9–11.
[4] S. Saadat and M. Boland, “Model of a dynamic orbit correction
system based on neural network in CLS”, in Proc. IPAC’23,
Venice, Italy, May 2023, pp. 2862-2865.
doi:10.18429/JACoW-IPAC2023-WEPA094[5] M.T. Hagan, H.B. Demuth, M.H. Beale, and O. De Jesus,
Neural Network Design, 2002.
https://hagan.okstate.edu/NNDesign.pdf[6] I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning,
MIT Press, 2016.

MOP03608 Feedback Systems and Beam Stability

105

from
this final
work version
may be isusedunder thetermsThis is Content
a preprint— thepublished
with
IOP of the CC-BY-4.0 licence (© 2023). Any distribution of this work must maintain attribution to the author(s), title of the work, publisher, and DOI

IBIC2023, Saskatoon, Canada
JACoW Publishing
ISSN: 2 6 7 3 - 5 3 5 0
d o i : 1 0 . 1 8 4 2 9 / J A C o W - I B I C 2 0 2 3 - M O P 0 3 6