Skip to content

Commit

Permalink
first pass at cavity tests done
Browse files Browse the repository at this point in the history
  • Loading branch information
lisazacarias committed Apr 15, 2024
1 parent fd11d95 commit 72a44b5
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 60 deletions.
47 changes: 19 additions & 28 deletions lcls_tools/superconducting/sc_linac.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,11 +805,15 @@ def __init__(
self.frequency = 3.9e9
self.loaded_q_lower_limit = utils.LOADED_Q_LOWER_LIMIT_HL
self.loaded_q_upper_limit = utils.LOADED_Q_UPPER_LIMIT_HL
self.scale_factor_lower_limit = utils.CAVITY_SCALE_LOWER_LIMIT_HL
self.scale_factor_upper_limit = utils.CAVITY_SCALE_UPPER_LIMIT_HL
else:
self.length = 1.038
self.frequency = 1.3e9
self.loaded_q_lower_limit = utils.LOADED_Q_LOWER_LIMIT
self.loaded_q_upper_limit = utils.LOADED_Q_UPPER_LIMIT
self.scale_factor_lower_limit = utils.CAVITY_SCALE_LOWER_LIMIT
self.scale_factor_upper_limit = utils.CAVITY_SCALE_UPPER_LIMIT

self._pv_prefix = "ACCL:{LINAC}:{CRYOMODULE}{CAVITY}0:".format(
LINAC=self.linac.name, CRYOMODULE=self.cryomodule.name, CAVITY=self.number
Expand Down Expand Up @@ -1075,18 +1079,11 @@ def measured_scale_factor(self) -> float:

@property
def measured_scale_factor_in_tolerance(self) -> bool:
if self.cryomodule.is_harmonic_linearizer:
return (
utils.CAVITY_SCALE_LOWER_LIMIT_HL
< self.measured_scale_factor
< utils.CAVITY_SCALE_UPPER_LIMIT_HL
)
else:
return (
utils.CAVITY_SCALE_LOWER_LIMIT
< self.measured_scale_factor
< utils.CAVITY_SCALE_UPPER_LIMIT
)
return (
self.scale_factor_lower_limit
< self.measured_scale_factor
< self.scale_factor_upper_limit
)

def push_scale_factor(self):
if not self._push_scale_factor_pv_obj:
Expand Down Expand Up @@ -1279,6 +1276,12 @@ def rf_state(self):
def is_on(self):
return self.rf_state == 1

def delta_piezo(self):
delta_volts = self.piezo.voltage - utils.PIEZO_CENTER_VOLTAGE
delta_hz = delta_volts * utils.PIEZO_HZ_PER_VOLT
print(f"{self} piezo detune: {delta_hz}")
return delta_hz if not self.cryomodule.is_harmonic_linearizer else -delta_hz

def move_to_resonance(self, reset_signed_steps=False, use_sela=False):
def delta_detune():
return self.detune
Expand All @@ -1292,20 +1295,9 @@ def delta_detune():
)

if use_sela:

def delta_piezo():
delta_volts = self.piezo.voltage - utils.PIEZO_CENTER_VOLTAGE
delta_hz = delta_volts * utils.PIEZO_HZ_PER_VOLT
print(f"{self} piezo detune: {delta_hz}")
return (
delta_hz
if not self.cryomodule.is_harmonic_linearizer
else -delta_hz
)

print(f"Centering {self} piezo")
self._auto_tune(
delta_hz_func=delta_piezo,
delta_hz_func=self.delta_piezo,
tolerance=100,
reset_signed_steps=False,
)
Expand Down Expand Up @@ -1430,6 +1422,7 @@ def push_go_button(self):
"""
self._pulse_go_pv_obj.put(1)
while self.pulse_status < 2:
self.check_abort()
print("waiting for pulse state", datetime.now())
sleep(1)
if self.pulse_status > 2:
Expand Down Expand Up @@ -1621,15 +1614,13 @@ def characterize(self):

if self.characterization_status == utils.CALIBRATION_COMPLETE_VALUE:
if (datetime.now() - self.characterization_timestamp).total_seconds() > 300:
raise utils.CavityQLoadedCalibrationError(
raise utils.CavityCharacterizationError(
f"No valid {self} characterization within the last 5 min"
)
self.finish_characterization()

if self.characterization_crashed:
raise utils.CavityQLoadedCalibrationError(
f"{self} characterization crashed"
)
raise utils.CavityCharacterizationError(f"{self} characterization crashed")

def finish_characterization(self):
print(f"pushing {self} characterization results")
Expand Down
8 changes: 8 additions & 0 deletions lcls_tools/superconducting/sc_linac_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ class CavityQLoadedCalibrationError(Exception):
pass


class CavityCharacterizationError(Exception):
"""
Exception thrown during cavity characterization
"""

pass


class CavityScaleFactorCalibrationError(Exception):
"""
Exception thrown during cavity scale factor calibration
Expand Down
Loading

0 comments on commit 72a44b5

Please sign in to comment.