@@ -1056,33 +1056,40 @@ def run_md_trial(atoms, calc, seed, steps):
10561056 logging .info (f"Stress drift A-B (max): { stress_drift_AB .max ():.2e} " )
10571057 logging .info (f"Stress drift A-C (max): { stress_drift_AC .max ():.2e} " )
10581058
1059- # The drift between A-C should be comparable to the baseline drift A-B
1060- # Allow some tolerance factor (e.g., 10x) for merge_mole overhead
1059+ # The drift between A-C should be comparable to the baseline drift A-B.
1060+ # Allow some tolerance factor (e.g., 10x) for merge_mole overhead.
1061+ # Clamp the baseline to a minimum floor so the threshold doesn't collapse
1062+ # to ~1e-6 when A-B is near-zero (e.g. on highly deterministic CI hardware),
1063+ # which would make the test a de-facto fixed threshold regardless of the
1064+ # 10x multiplier.
10611065 tolerance_factor = 10.0
1066+ abs_floor_energy = 1e-5 # eV
1067+ abs_floor_forces = 5e-6 # eV/Ang
1068+ abs_floor_stress = 1e-6 # eV/Ang^3
10621069
10631070 # For energy: max drift A-C should be within tolerance of max drift A-B
1064- baseline_energy_drift = max (energy_drift_AB .max (), 1e-10 ) # avoid division by zero
1071+ baseline_energy_drift = max (energy_drift_AB .max (), abs_floor_energy )
10651072 npt .assert_array_less (
10661073 energy_drift_AC .max (),
1067- tolerance_factor * baseline_energy_drift + 1e-6 ,
1074+ tolerance_factor * baseline_energy_drift ,
10681075 err_msg = f"Energy drift A-C ({ energy_drift_AC .max ():.2e} ) exceeds "
10691076 f"{ tolerance_factor } x baseline A-B ({ baseline_energy_drift :.2e} )" ,
10701077 )
10711078
10721079 # For forces: max drift A-C should be within tolerance of max drift A-B
1073- baseline_forces_drift = max (forces_drift_AB .max (), 1e-10 )
1080+ baseline_forces_drift = max (forces_drift_AB .max (), abs_floor_forces )
10741081 npt .assert_array_less (
10751082 forces_drift_AC .max (),
1076- tolerance_factor * baseline_forces_drift + 1e-6 ,
1083+ tolerance_factor * baseline_forces_drift ,
10771084 err_msg = f"Forces drift A-C ({ forces_drift_AC .max ():.2e} ) exceeds "
10781085 f"{ tolerance_factor } x baseline A-B ({ baseline_forces_drift :.2e} )" ,
10791086 )
10801087
10811088 # For stress: max drift A-C should be within tolerance of max drift A-B
1082- baseline_stress_drift = max (stress_drift_AB .max (), 1e-10 )
1089+ baseline_stress_drift = max (stress_drift_AB .max (), abs_floor_stress )
10831090 npt .assert_array_less (
10841091 stress_drift_AC .max (),
1085- tolerance_factor * baseline_stress_drift + 1e-6 ,
1092+ tolerance_factor * baseline_stress_drift ,
10861093 err_msg = f"Stress drift A-C ({ stress_drift_AC .max ():.2e} ) exceeds "
10871094 f"{ tolerance_factor } x baseline A-B ({ baseline_stress_drift :.2e} )" ,
10881095 )
0 commit comments