Skip to content

Commit

Permalink
Engine: ensure that angular momenta are not exceeded more carefully; …
Browse files Browse the repository at this point in the history
…for center-dependent momenta could yield (incorrect) result for angular momenta outside the supported range
  • Loading branch information
evaleev committed Feb 5, 2024
1 parent aa77bd5 commit 26aaad7
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion include/libint2/engine.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,9 @@ __libint2_engine_inline const Engine::target_ptr_vec& Engine::compute2(
tket2.ncontr() == 1) &&
"generally-contracted shells are not yet supported");

// angular momentum limit obeyed?
// angular momentum limit obeyed? can only be fully checked in
// braket-dependent code, here only do a basic test that does not guarantee
// that the shell-set can be computed
assert(tbra1.contr[0].l <= lmax_ && "the angular momentum limit is exceeded");
assert(tbra2.contr[0].l <= lmax_ && "the angular momentum limit is exceeded");
assert(tket1.contr[0].l <= lmax_ && "the angular momentum limit is exceeded");
Expand Down Expand Up @@ -1812,6 +1814,14 @@ __libint2_engine_inline const Engine::target_ptr_vec& Engine::compute2(
size_t buildfnidx;
switch (braket_) {
case BraKet::xx_xx:
assert(bra1.contr[0].l <= hard_lmax_ &&
"the angular momentum limit is exceeded");
assert(bra2.contr[0].l <= hard_lmax_ &&
"the angular momentum limit is exceeded");
assert(ket1.contr[0].l <= hard_lmax_ &&
"the angular momentum limit is exceeded");
assert(ket2.contr[0].l <= hard_lmax_ &&
"the angular momentum limit is exceeded");
buildfnidx =
((bra1.contr[0].l * hard_lmax_ + bra2.contr[0].l) * hard_lmax_ +
ket1.contr[0].l) *
Expand Down Expand Up @@ -1846,6 +1856,12 @@ __libint2_engine_inline const Engine::target_ptr_vec& Engine::compute2(
assert(false && "missing case in switch");
abort();
}
assert(bra1.contr[0].l <= hard_lmax_ &&
"the angular momentum limit is exceeded");
assert(ket1.contr[0].l <= ket_lmax &&
"the angular momentum limit is exceeded");
assert(ket2.contr[0].l <= ket_lmax &&
"the angular momentum limit is exceeded");
buildfnidx = (bra1.contr[0].l * ket_lmax + ket1.contr[0].l) * ket_lmax +
ket2.contr[0].l;
#ifdef ERI3_PURE_SH
Expand All @@ -1857,6 +1873,10 @@ __libint2_engine_inline const Engine::target_ptr_vec& Engine::compute2(
} break;

case BraKet::xs_xs:
assert(bra1.contr[0].l <= hard_lmax_ &&
"the angular momentum limit is exceeded");
assert(ket1.contr[0].l <= hard_lmax_ &&
"the angular momentum limit is exceeded");
buildfnidx = bra1.contr[0].l * hard_lmax_ + ket1.contr[0].l;
#ifdef ERI2_PURE_SH
if (bra1.contr[0].l > 1)
Expand Down

0 comments on commit 26aaad7

Please sign in to comment.