diff --git a/docs/changelog.md b/docs/changelog.md index d4c2b9d..a465ad4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,7 +19,7 @@ --> -## v0.3.0 / 2024-07-19 +## v0.3.0 / 2024-07-21 #### Breaking Changes diff --git a/qcmanybody/core.py b/qcmanybody/core.py index 6815f6a..f2f892a 100644 --- a/qcmanybody/core.py +++ b/qcmanybody/core.py @@ -103,6 +103,14 @@ def __init__( assert self.mc_levels == set(self.nbodies_per_mc_level.keys()) # remove after some downstream testing self.mc_levels = self.nbodies_per_mc_level.keys() + for mc, nbs in self.nbodies_per_mc_level.items(): + if nbs and ((nbs[-1] - nbs[0]) != len(nbs) - 1): + raise ValueError( + f"QCManyBody: N-Body levels must be contiguous within a model chemistry spec ({mc}: {nbs}). Use an alternate spec name to accomplish this input." + ) + # TODO - test and reenable if appropriate. my guess is that noncontig nb is fine on the core computing side, + # but trouble for computer and nbodies_per_mc_level inverting and indexing. Safer to deflect for now since input tweak allows the calc. + # Supersystem is always at the end if "supersystem" in levels: ss_mc = levels["supersystem"] diff --git a/qcmanybody/tests/test_core_auxiliary.py b/qcmanybody/tests/test_core_auxiliary.py index be9f2ad..2ceee39 100644 --- a/qcmanybody/tests/test_core_auxiliary.py +++ b/qcmanybody/tests/test_core_auxiliary.py @@ -31,6 +31,13 @@ def test_noncontiguous_fragments_evaded(): assert "QCManyBody: non-contiguous fragments could be implemented but aren't at present" in str(e.value) +def test_noncontiguous_nbody_levels_same_mc(he_tetramer): + with pytest.raises(ValueError) as e: + ManyBodyCalculator(he_tetramer, ["cp"], {2: "mp2", 1: "mp2", 4: "mp2", 3: "ccsd"}, True, False, None) + + assert "QCManyBody: N-Body levels must be contiguous within a model chemistry spec" in str(e.value) + + @pytest.mark.parametrize("mbe_keywords,ref_count,ref_text", [ pytest.param( {"bsse_type": ["nocp", "cp", "vmfc"]},