Skip to content
Snippets Groups Projects
Commit 23999a50 authored by Leon van Riesen-Haupt's avatar Leon van Riesen-Haupt
Browse files

added tests for tuning and vertical emit matching

parent c4f3fbcc
No related branches found
No related tags found
No related merge requests found
Pipeline #5858498 failed
......@@ -132,3 +132,36 @@ def test_survey(operation_mode):
fill_value="extrapolate"
)
theta = np.linspace(-np.pi, np.pi, 1001, endpoint=False)
def test_vert_emit(operation_mode):
wiggled_optics = tfs.read(TWISS_DIR/operation_mode/f"twiss_{operation_mode}_b1_vert_emit.tfs", index="NAME")
wiggled_optics=wiggled_optics[wiggled_optics.index.str.contains('^IP\.[1-8]$')] # select all IPs, ensure no other element containing IP fall into that
for ip in wiggled_optics.index:
assert abs(wiggled_optics.loc[ip,'BETX'] - REFERENCE_FILE[operation_mode]['BETASTAR_X']) < 0.005 # Expect some perturbation due to the wigglers
assert abs(wiggled_optics.loc[ip,'BETY'] - REFERENCE_FILE[operation_mode]['BETASTAR_Y']) < BETA_ACCURACY
assert abs(wiggled_optics.loc[ip,'ALFX']) < 0.005
assert abs(wiggled_optics.loc[ip,'ALFY']) < 0.005
assert abs(wiggled_optics.loc[ip,'DX']) < BETA_ACCURACY
assert abs(wiggled_optics.loc[ip,'DY']) < BETA_ACCURACY
assert abs(wiggled_optics.headers['EX'] - REFERENCE_FILE[operation_mode]['EMITTANCE_X'])/REFERENCE_FILE[operation_mode]['EMITTANCE_X'] < 0.03
assert abs(wiggled_optics.headers['EY'] - 0.002*REFERENCE_FILE[operation_mode]['EMITTANCE_X'])/(REFERENCE_FILE[operation_mode]['EMITTANCE_X']*0.002) < 0.03
def test_tuning(operation_mode):
twiss = tfs.read(TWISS_DIR/operation_mode/f"twiss_{operation_mode}_b1_tune_matched.tfs", index="NAME")
assert abs(twiss.headers['Q1']%1 - 0.4) < TUNE_ACCURACY
assert abs(twiss.headers['Q2']%1 - 0.4) < TUNE_ACCURACY
twiss=twiss[twiss.index.str.contains('^IP\.[1-8]$')] # select all IPs, ensure no other element containing IP fall into that
for ip in twiss.index:
assert abs(twiss.loc[ip,'BETX'] - REFERENCE_FILE[operation_mode]['BETASTAR_X']) < BETA_ACCURACY
assert abs(twiss.loc[ip,'BETY'] - REFERENCE_FILE[operation_mode]['BETASTAR_Y']) < BETA_ACCURACY
assert abs(twiss.loc[ip,'ALFX']) < BETA_ACCURACY
assert abs(twiss.loc[ip,'ALFY']) < BETA_ACCURACY
assert abs(twiss.loc[ip,'DX']) < BETA_ACCURACY
assert abs(twiss.loc[ip,'DY']) < BETA_ACCURACY
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment