Skip to content

Commit b13667b

Browse files
committed
update the comparison threshold for fortran/test-eri
1 parent d3694ca commit b13667b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/lib/libint/tests/fortran/test-eri.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,12 @@ bool test_eri_c_f(int &contrdepth, int &am1, double *c1, double *alpha1, double
480480

481481
TEST_CASE("Fortran ERI", "[eri]") {
482482

483-
const double threshold = std::numeric_limits<double>::epsilon() * 10;
483+
// recipe from eri/test.cc
484+
const double ABSOLUTE_DEVIATION_THRESHOLD = 5.0E-14; // indicate failure if any integral differs in absolute sense by more than this
485+
// loss of precision in HRR likely limits precision for high-L (e.g. (dp|dd), (dd|dd), etc.)
486+
auto absolute_derivation_threshold = [&](int deriv_order) {
487+
return ABSOLUTE_DEVIATION_THRESHOLD * std::pow(3., deriv_order > 2 ? deriv_order-2 : 0);
488+
};
484489

485490
int am1 = std::min(1, LIBINT2_MAX_AM_eri);
486491
int am2 = std::min(0, LIBINT2_MAX_AM_eri);
@@ -516,15 +521,15 @@ TEST_CASE("Fortran ERI", "[eri]") {
516521
am2, c2, alpha2, B,
517522
am3, c3, alpha3, C,
518523
am4, c4, alpha4, D,
519-
deriv_order, threshold));
524+
deriv_order, absolute_derivation_threshold(deriv_order)));
520525

521526
#if INCLUDE_ERI >= 1
522527
deriv_order = 1;
523528
REQUIRE(test_eri_c_f(contrdepth, am1, c1, alpha1, A,
524529
am2, c2, alpha2, B,
525530
am3, c3, alpha3, C,
526531
am4, c4, alpha4, D,
527-
deriv_order, threshold));
532+
deriv_order, absolute_derivation_threshold(deriv_order)));
528533
#endif
529534

530535
#if INCLUDE_ERI >= 2
@@ -533,7 +538,7 @@ TEST_CASE("Fortran ERI", "[eri]") {
533538
am2, c2, alpha2, B,
534539
am3, c3, alpha3, C,
535540
am4, c4, alpha4, D,
536-
deriv_order, threshold));
541+
deriv_order, absolute_derivation_threshold(deriv_order)));
537542
#endif
538543
#endif // INCLUDE_ERI
539544
}

0 commit comments

Comments
 (0)