From ca7ae945df505eade4eb582fe9ca5a57c2739fb6 Mon Sep 17 00:00:00 2001 From: ximenes Date: Mon, 16 Mar 2026 21:49:22 -0300 Subject: [PATCH 1/4] ENH: (COMMISS.SPIN) include positive feedback tune scan - alternate between BBB set 0 and 1 during tune scans - used to induce instabilities and enhance depolarization - other improvements (initial accum tune errors, curr info buffer reset) --- apsuite/commisslib/measure_spin_depol_scan.py | 70 ++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/apsuite/commisslib/measure_spin_depol_scan.py b/apsuite/commisslib/measure_spin_depol_scan.py index 9f1d0bb3..754bb212 100644 --- a/apsuite/commisslib/measure_spin_depol_scan.py +++ b/apsuite/commisslib/measure_spin_depol_scan.py @@ -305,10 +305,20 @@ def __init__(self): self.tunex_stop = 0.16 self.tuney_start = 0.22 self.tuney_stop = 0.35 + self.change_tunex_error = 0.0 + self.change_tuney_error = 0.0 + self.bbbv_set0_gain = 0.7 + self.bbbv_set0_phase = -120 + self.bbbv_set1_gain = 0.1 + self.bbbv_set1_phase = 60 + self.bbbh_set0_gain = 0.6 + self.bbbh_set0_phase = 150 + self.bbbh_set1_gain = 0.6 + self.bbbh_set1_phase = 150 def __str__(self): """.""" - ftmp = '{0:24s} = {1:9.3f} {2:s}\n'.format + ftmp = '{0:24s} = {1:9.4f} {2:s}\n'.format stg = '' stg += ftmp('wait_time_change_tune', self.wait_time_change_tune, '[s]') @@ -320,6 +330,16 @@ def __str__(self): stg += ftmp('tuney_start', self.tuney_start, '') stg += ftmp('tuney_stop', self.tuney_stop, '') stg += ftmp('tuney_step', self.tuney_step, '(calculated)') + stg += ftmp('change_tunex_error', self.change_tunex_error, '') + stg += ftmp('change_tuney_error', self.change_tuney_error, '') + stg += ftmp('bbbv_set0_gain', self.bbbv_set0_gain, '') + stg += ftmp('bbbv_set0_phase', self.bbbv_set0_phase, '[deg]') + stg += ftmp('bbbv_set1_gain', self.bbbv_set1_gain, '') + stg += ftmp('bbbv_set1_phase', self.bbbv_set1_phase, '[deg]') + stg += ftmp('bbbh_set0_gain', self.bbbh_set0_gain, '') + stg += ftmp('bbbh_set0_phase', self.bbbh_set0_phase, '[deg]') + stg += ftmp('bbbh_set1_gain', self.bbbh_set1_gain, '') + stg += ftmp('bbbh_set1_phase', self.bbbh_set1_phase, '[deg]') stg += f'total scan time (approx.) = {self.total_scan_time:.1f} s\n' return stg @@ -355,7 +375,7 @@ def tuney_grid(self): def total_scan_time(self): """.""" nr_points = 2 * self.nr_steps + 1 - return nr_points * self.wait_time_change_tune + return nr_points * self.wait_time_change_tune * 2 @staticmethod def _calc_grid(start, stop, nr_steps): @@ -384,17 +404,22 @@ def do_measurement(self): bbbh = self.devices['bbbh'] bbbv = self.devices['bbbv'] tune_mon = self.devices['tune'] + currinfo = self.devices['currinfo'] gtunesx = self.params.tunex_grid gtunesy = self.params.tuney_grid # mechanism to compensate for magnet hysteresis. Not ideal, but # should help to keep the tune close to the target value: - errx = erry = 0 + errx = self.params.change_tunex_error + erry = self.params.change_tuney_error for i, (gtx, gty) in enumerate(zip(gtunesx, gtunesy)): # noqa: B905 freqx = gtx * bbbh.info.revolution_freq_nom / 1e3 freqy = gty * bbbv.info.revolution_freq_nom / 1e3 + bbbh.feedback.coeff_set = 1 + bbbv.feedback.coeff_set = 1 + currinfo['BuffRst-Cmd'] = 1 print( f' {i + 1:03d}/{len(gtunesx):03d} -> ' + f'nux, nuy (freqx, freqy): {gtx:6.4f}, {gty:6.4f} ' @@ -406,6 +431,15 @@ def do_measurement(self): dtunex, dtuney = self.change_tune(gtx, gty, errx=errx, erry=erry) + for _ in range(int(self.params.wait_time_change_tune)): + if self._stopevt.is_set(): + break + _time.sleep(1) + + bbbh.feedback.coeff_set = 0 + bbbv.feedback.coeff_set = 0 + currinfo['BuffRst-Cmd'] = 1 + for _ in range(int(self.params.wait_time_change_tune)): if self._stopevt.is_set(): break @@ -416,14 +450,17 @@ def do_measurement(self): # of magnet hysteresis, which can cause the tune to deviate # from the target value, specially when changing the tune in # large steps. - errxn = (gtx - tune_mon.tunex) / dtunex if dtunex != 0 else 0 - erryn = (gty - tune_mon.tuney) / dtuney if dtuney != 0 else 0 - print(f' error: {errxn:.2f}, {erryn:.2f}') - errx += errxn * 0.5 - erry += erryn * 0.5 + exn = (gtx - tune_mon.tunex) / dtunex if dtunex != 0 else 0 + eyn = (gty - tune_mon.tuney) / dtuney if dtuney != 0 else 0 + errx += exn * 0.5 + erry += eyn * 0.5 # limit the error correction factor to avoid overcompensation: errx = min(max(errx, -0.2), 0.2) erry = min(max(erry, -0.2), 0.2) + print( + f' error (now): {errx:.2f}, {erry:.2f} ' + + f'({exn:.2f}, {eyn:.2f})' + ) print('Scan finished! Waiting for acquisition thread to finish.') self._stopevt.set() @@ -469,8 +506,25 @@ def change_tune(self, tunex, tuney, errx=0.0, erry=0.0): bbbh.drive0.frequency = freqx bbbv.drive0.frequency = freqy + bbbh.coeffs.edit_choose_set = 0 + bbbv.coeffs.edit_choose_set = 0 + bbbh.coeffs.edit_freq = tunex * bbbh.feedback.downsample + bbbv.coeffs.edit_freq = tuney * bbbv.feedback.downsample + bbbh.coeffs.edit_gain = self.params.bbbh_set0_gain + bbbh.coeffs.edit_phase = self.params.bbbh_set0_phase + bbbv.coeffs.edit_gain = self.params.bbbv_set0_gain + bbbv.coeffs.edit_phase = self.params.bbbv_set0_phase + bbbh.coeffs.cmd_edit_apply() + bbbv.coeffs.cmd_edit_apply() + + bbbh.coeffs.edit_choose_set = 1 + bbbv.coeffs.edit_choose_set = 1 bbbh.coeffs.edit_freq = tunex * bbbh.feedback.downsample bbbv.coeffs.edit_freq = tuney * bbbv.feedback.downsample + bbbh.coeffs.edit_gain = self.params.bbbh_set1_gain + bbbh.coeffs.edit_phase = self.params.bbbh_set1_phase + bbbv.coeffs.edit_gain = self.params.bbbv_set1_gain + bbbv.coeffs.edit_phase = self.params.bbbv_set1_phase bbbh.coeffs.cmd_edit_apply() bbbv.coeffs.cmd_edit_apply() From 4f42af4e9fe52828d037105bbbb41975d46567ed Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 13 Aug 2026 17:25:16 -0300 Subject: [PATCH 2/4] ENH (SPIN.TUNESCAN) update default params - some params taken from last measurement noteboook - set0 bbb params taken from current operation values (after Dmitry's visit and bbb filters and amps optimization) --- apsuite/commisslib/measure_spin_depol_scan.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apsuite/commisslib/measure_spin_depol_scan.py b/apsuite/commisslib/measure_spin_depol_scan.py index 754bb212..a5e103d5 100644 --- a/apsuite/commisslib/measure_spin_depol_scan.py +++ b/apsuite/commisslib/measure_spin_depol_scan.py @@ -301,20 +301,20 @@ def __init__(self): self.wait_time_change_tune = 40 # [s] self.wait_time_acq_data = 1.0 # [s] self.nr_steps = 20 - self.tunex_start = 0.16 - self.tunex_stop = 0.16 - self.tuney_start = 0.22 - self.tuney_stop = 0.35 + self.tunex_start = 0.14 + self.tunex_stop = 0.14 + self.tuney_start = 0.19 + self.tuney_stop = 0.23 self.change_tunex_error = 0.0 self.change_tuney_error = 0.0 - self.bbbv_set0_gain = 0.7 - self.bbbv_set0_phase = -120 + self.bbbv_set0_gain = 0.9 + self.bbbv_set0_phase = -170 self.bbbv_set1_gain = 0.1 - self.bbbv_set1_phase = 60 - self.bbbh_set0_gain = 0.6 - self.bbbh_set0_phase = 150 - self.bbbh_set1_gain = 0.6 - self.bbbh_set1_phase = 150 + self.bbbv_set1_phase = 10 + self.bbbh_set0_gain = 1.0 + self.bbbh_set0_phase = -50.0 + self.bbbh_set1_gain = 1.0 + self.bbbh_set1_phase = -50.0 def __str__(self): """.""" From ac93698a803b990af15d88a8ffca1cc41fc40754 Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 14 Aug 2026 09:50:26 -0300 Subject: [PATCH 3/4] update version --- apsuite/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apsuite/VERSION b/apsuite/VERSION index 6679a604..995366c6 100644 --- a/apsuite/VERSION +++ b/apsuite/VERSION @@ -1 +1 @@ -2.61.1 +2.62.0 From 77f1ccec0962edbdbcf6b6bbdd823fd887c02d43 Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 14 Aug 2026 16:29:45 -0300 Subject: [PATCH 4/4] BUG (COMMISS.SPINDEPOL) fix tunecorr device --- apsuite/commisslib/measure_spin_depol_scan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apsuite/commisslib/measure_spin_depol_scan.py b/apsuite/commisslib/measure_spin_depol_scan.py index a5e103d5..7cba48d0 100644 --- a/apsuite/commisslib/measure_spin_depol_scan.py +++ b/apsuite/commisslib/measure_spin_depol_scan.py @@ -14,7 +14,7 @@ FamGammaMonitors, RFGen, Tune, - TuneCorr + SITuneCorr ) from ..utils import ParamsBaseClass, ThreadedMeasBaseClass @@ -79,7 +79,7 @@ def create_devices(self): props2init=['GeneralFreq-SP', 'GeneralFreq-RB'] ) self.devices['tune'] = Tune(Tune.DEVICES.SI) - self.devices['tunecorr'] = TuneCorr(TuneCorr.DEVICES.SI) + self.devices['tunecorr'] = SITuneCorr(SITuneCorr.DEVICES.SI) self.devices['gamma_monitors'] = FamGammaMonitors() self.devices['blms'] = FamBLMs() self.devices['cax'] = DVFImgProc(DVFImgProc.DEVICES.CAX_DVF2)