From c20933fbff5adda7bea5a697067dbbd4770af418 Mon Sep 17 00:00:00 2001
From: Gamelin Alexis <alexis.gamelin@synchrotron-soleil.fr>
Date: Mon, 7 Mar 2022 10:01:26 +0100
Subject: [PATCH] Add more saved parameters to CavityMonitor

---
 tracking/monitors/monitors.py | 27 ++++++++++++++++++++++++---
 tracking/rf.py                |  5 +++++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/tracking/monitors/monitors.py b/tracking/monitors/monitors.py
index e562d76..f13ed42 100644
--- a/tracking/monitors/monitors.py
+++ b/tracking/monitors/monitors.py
@@ -1368,13 +1368,34 @@ class CavityMonitor(Monitor):
         group_name = cavity_name
         dict_buffer = {"cavity_phasor_record":(ring.h, buffer_size,),
                        "beam_phasor_record":(ring.h, buffer_size,),
-                       "detune":(buffer_size,)}
+                       "detune":(buffer_size,),
+                       "psi":(buffer_size,),
+                       "Vg":(buffer_size,),
+                       "theta_g":(buffer_size,),
+                       "Pg":(buffer_size,),
+                       "Rs":(buffer_size,),
+                       "Q":(buffer_size,),
+                       "QL":(buffer_size,)}
         dict_file = {"cavity_phasor_record":(ring.h, total_size,),
                      "beam_phasor_record":(ring.h, total_size,),
-                      "detune":(total_size,)}
+                     "detune":(total_size,),
+                     "psi":(total_size,),
+                     "Vg":(total_size,),
+                     "theta_g":(total_size,),
+                     "Pg":(total_size,),
+                     "Rs":(total_size,),
+                     "Q":(total_size,),
+                     "QL":(total_size,)}
         dict_dtype = {"cavity_phasor_record":complex,
                       "beam_phasor_record":complex,
-                      "detune":float}
+                      "detune":float,
+                      "psi":float,
+                      "Vg":float,
+                      "theta_g":float,
+                      "Pg":float,
+                      "Rs":float,
+                      "Q":float,
+                      "QL":float}
         
         self.monitor_init(group_name, save_every, buffer_size, total_size,
                           dict_buffer, dict_file, file_name, mpi_mode, 
diff --git a/tracking/rf.py b/tracking/rf.py
index 39603ba..08d52c6 100644
--- a/tracking/rf.py
+++ b/tracking/rf.py
@@ -192,6 +192,11 @@ class CavityResonator():
         self.beam_phasor = np.zeros(1, dtype=np.complex)
         self.beam_phasor_record = np.zeros((self.ring.h), dtype=np.complex)
         self.tracking = False
+        self.Vg = 0
+        self.theta_g = 0
+        self.Vgr = 0
+        self.theta_gr = 0
+        self.Pg = 0
         
     def init_tracking(self, beam):
         """
-- 
GitLab