diff --git a/tests/test_madx.py b/tests/test_madx.py index 6689e6b67f84d329360f38a98d1b74648db606f7..a3859f5bf121055548092eeb5c60c84314eb34f4 100644 --- a/tests/test_madx.py +++ b/tests/test_madx.py @@ -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