diff --git a/qcmanybody/manybody.py b/qcmanybody/manybody.py index de70373..9953207 100644 --- a/qcmanybody/manybody.py +++ b/qcmanybody/manybody.py @@ -57,6 +57,13 @@ def __init__( if len(self.bsse_type) == 0: raise ValueError("No BSSE correction specified") + if BsseEnum.vmfc in self.bsse_type and len(set(self.levels.values())) == 1: + # For single-modelchem VMFC, NOCP & sometimes CP are produced for free + if BsseEnum.nocp not in self.bsse_type: + self.bsse_type.append(BsseEnum.nocp) + if BsseEnum.cp not in self.bsse_type and self.max_nbody == self.nfragments: + self.bsse_type.append(BsseEnum.cp) + self.return_bsse_type = self.bsse_type[0] ############################### @@ -276,18 +283,8 @@ def _assemble_nbody_components( # Compute vmfc if BsseEnum.vmfc in bsse_type: for nb in nbodies: - # TODO I think this is correct for all properties... - # for k in range(1, nb + 1): - # vmfc_body_dict[nb] += vmfc_by_level[k] - - # TODO - but below was used for gradient/hessian in psi4? - if property_label == "energy": - for k in range(1, nb + 1): - vmfc_body_dict[nb] += vmfc_by_level[k] - else: - if nb > 1: - vmfc_body_dict[nb] = vmfc_by_level[nb - 1] - vmfc_body_dict[nb] += vmfc_by_level[nb] + for k in range(1, nb + 1): + vmfc_body_dict[nb] += vmfc_by_level[k] # Collect specific and generalized returns results = { @@ -408,8 +405,34 @@ def _analyze( def analyze( self, - component_results: Dict[str, Dict[str, Union[float, np.ndarray]]], # component_results[label][property] = 1.23 + component_results: Dict[str, Dict[str, Union[float, np.ndarray]]], ): + """ + + Parameters + ---------- + component_results + Nested dictionary with results from all individual molecular system + calculations, including all subsystem/basis combinations, all model + chemistries, and all properties (e.g., e/g/h). + + For example, the below is the format for a nocp gradient run on a + helium dimer with 1-body at CCSD and 2-body at MP2. The outer string + key can be generated with the ``qcmanybody.utils.labeler`` function. + The inner string key is any property; QCManyBody presently knows how + to process energy/gradient/Hessian. + + {'["ccsd", [1], [1]]': {'energy': -2.87, 'gradient': array([[0., 0., 0.]])}, + '["ccsd", [2], [2]]': {'energy': -2.87, 'gradient': array([[0., 0., 0.]])}, + '["mp2", [1], [1]]': {'energy': -2.86, 'gradient': array([[0., 0., 0.]])}, + '["mp2", [2], [2]]': {'energy': -2.86, 'gradient': array([[0., 0., 0.]])}, + '["mp2", [1, 2], [1, 2]]': {'energy': -5.73, 'gradient': array([[ 0., 0., 0.0053], [ 0., 0., -0.0053]])}, + } + + Return + ------ + + """ # All properties that were passed to us available_properties = set() diff --git a/qcmanybody/models/manybody_v1.py b/qcmanybody/models/manybody_v1.py index 048302b..e07f17c 100644 --- a/qcmanybody/models/manybody_v1.py +++ b/qcmanybody/models/manybody_v1.py @@ -475,11 +475,17 @@ class Config: )) +class ProtoModelSkipDefaults(ProtoModel): + + class Config(ProtoModel.Config): + serialize_skip_defaults = True + force_skip_defaults = True + + ManyBodyResultProperties = create_model( "ManyBodyResultProperties", - #__config__=ConfigDict(title='abc'), #__doc__=manybodyresultproperties_doc, # needs later pydantic - __base__=ProtoModel, + __base__=ProtoModelSkipDefaults, **mbprop, ) diff --git a/qcmanybody/models/test_mbe_he4_multilevel.py b/qcmanybody/models/test_mbe_he4_multilevel.py index facef5c..6078111 100644 --- a/qcmanybody/models/test_mbe_he4_multilevel.py +++ b/qcmanybody/models/test_mbe_he4_multilevel.py @@ -12,7 +12,8 @@ from qcmanybody.models.qcng_computer import ManyBodyComputerQCNG, qcvars_to_manybodyproperties import qcengine as qcng -from .addons import using +from addons import using +from test_mbe_he4_singlelevel import sumdict def skprop(qcvar): # qcng: return qcng.procedures.manybody.qcvars_to_manybodyproperties[qcvar] @@ -185,6 +186,18 @@ def mbe_data_multilevel_631g(): "CP-CORRECTED 2-BODY CONTRIBUTION TO ENERGY": 0.009589981022, "CP-CORRECTED 3-BODY CONTRIBUTION TO ENERGY": -0.000266034234, "CP-CORRECTED 4-BODY CONTRIBUTION TO ENERGY": 0.000052364064, + + "VMFC-CORRECTED TOTAL ENERGY THROUGH 1-BODY": -11.480648555603, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY": -11.471163557706, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 3-BODY": -11.471402496106, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY": -11.471350132042, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 1-BODY": 0.0, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY": 0.009484997897, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 3-BODY": 0.009246059497, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY": 0.009298423561, + "VMFC-CORRECTED 2-BODY CONTRIBUTION TO ENERGY": 0.009484997897, + "VMFC-CORRECTED 3-BODY CONTRIBUTION TO ENERGY": -0.000238938400, + "VMFC-CORRECTED 4-BODY CONTRIBUTION TO ENERGY": 0.000052364064, }, # 1,2: ccsd; 3,4: mp2, all 6-31G "22": { @@ -211,6 +224,18 @@ def mbe_data_multilevel_631g(): "CP-CORRECTED 2-BODY CONTRIBUTION TO ENERGY": 0.009942616831, "CP-CORRECTED 3-BODY CONTRIBUTION TO ENERGY": -0.000266034234, "CP-CORRECTED 4-BODY CONTRIBUTION TO ENERGY": 0.000058523922, + + "VMFC-CORRECTED TOTAL ENERGY THROUGH 1-BODY": -11.480648555603, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY": -11.470821409457, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 3-BODY": -11.471060347857, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY": -11.471001823935, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 1-BODY": 0.0, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY": 0.009827146147, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 3-BODY": 0.009588207746, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY": 0.009646731668, + "VMFC-CORRECTED 2-BODY CONTRIBUTION TO ENERGY": 0.009827146147, + "VMFC-CORRECTED 3-BODY CONTRIBUTION TO ENERGY": -0.000238938400, + "VMFC-CORRECTED 4-BODY CONTRIBUTION TO ENERGY": 0.000058523922, }, } @@ -253,97 +278,50 @@ def mbe_data_multilevel_631g(): "VMFC-CORRECTED 4-BODY CONTRIBUTION TO ENERGY": 6.299342870974556e-05, } -sumdict = { - "4b_all": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + +sumdict_multi = { + "4b_vmfc_rtd": { "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY", "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", }, - "4b_nocpcp": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "4b_nocp_rtd_sio": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "4b_nocp_sio": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "4b_cp_rtd_sio": { - "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "4b_cp_sio": { - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "4b_nocp_rtd": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "4b_nocp": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "4b_cp_rtd": { - "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "4b_cp": { - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - }, - "3b_nocp_rtd": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 3-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", - }, - "3b_nocp": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 3-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + "4b_vmfc": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY", # TODO remove? + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", }, - "3b_cp_rtd": { - "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 3-BODY", - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + "3b_vmfc_rtd": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 3-BODY", + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", }, - "3b_cp": { - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + "3b_vmfc": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 3-BODY", # TODO remove? + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", }, - "2b_nocp_rtd": { + "2b_vmfc_rtd": { + "121": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY", + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + }, + "22": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY", + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 2-BODY", "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + }, }, - "2b_nocp": { + "2b_vmfc": { + "121": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY", # TODO remove? + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + }, + "22": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY", + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 2-BODY", "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", - }, - "2b_cp_rtd": { - "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 2-BODY", - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", - }, - "2b_cp": { - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", - }, - "1b_nocp_rtd": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 1-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", - }, - "1b_nocp": { - "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 1-BODY", - "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", - }, - "1b_cp_rtd": { - "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 1-BODY", - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", - }, - "1b_cp": { - "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", + }, }, } +sumdict.update(sumdict_multi) @pytest.fixture @@ -412,7 +390,6 @@ def he_tetramer(): # {"121": 5, # "22": 99}, # # id="4b_cp_sio"), -### TODO add vmfc. 3b nmbe=50 pytest.param( {"bsse_type": "nocp", "return_total_data": True}, "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", @@ -441,6 +418,20 @@ def he_tetramer(): {"121": 29, # 14md + 15lo vs. 15 for single-level, "22": 25}, # 10hi + 15lo id="4b_cp"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": True}, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + [k for k in he4_refs_conv if (k.startswith("VMFC-"))], + {"121": 65, # was 93 in p4 # 4hi + 18+28md + 15lo vs. 65 for single-level + "22": 65}, # was 83 in p4 # 4+18hi + 28+15lo + id="4b_vmfc_rtd"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": False}, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + [k for k in he4_refs_conv if (k.startswith("VMFC-"))], + {"121": 65, # could be 61; was 93 in p4 # 18+28md + 15lo =61 + "22": 65}, # could be 61; was 83 in p4 # 18hi + 28+15lo = 61 + id="4b_vmfc"), pytest.param( {"bsse_type": "nocp", "return_total_data": True, "max_nbody": 3}, "NOCP-CORRECTED TOTAL ENERGY THROUGH 3-BODY", @@ -469,6 +460,20 @@ def he_tetramer(): {"121": 14, # 14md vs. 14 for single-level "22": 24}, # 10hi + 14lo id="3b_cp"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": True, "max_nbody": 3}, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 3-BODY", + [k for k in he4_refs_conv if (k.startswith("VMFC-") and ("4-BODY" not in k))], + {"121": 50, # 4hi + 18+28md vs. 14? for single-level + "22": 50}, # was 68 in p4 # 4+18hi + 28lo + id="3b_vmfc_rtd"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": False, "max_nbody": 3}, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + [k for k in he4_refs_conv if (k.startswith("VMFC-") and ("4-BODY" not in k))], + {"121": 50, # could be 46 # 18+28md =46 + "22": 50}, # could be 46; was 68 in p4 # 18hi + 28lo = 46 + id="3b_vmfc"), pytest.param( {"bsse_type": "nocp", "return_total_data": True, "max_nbody": 2}, "NOCP-CORRECTED TOTAL ENERGY THROUGH 2-BODY", @@ -491,12 +496,29 @@ def he_tetramer(): "22": 14}, # 10hi + 4hi(nocp) id="2b_cp_rtd"), pytest.param( - {"bsse_type": "cp", "return_total_data": False, "max_nbody": 2}, + {"bsse_type": "ssfc", "return_total_data": False, "max_nbody": 2}, "CP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", [k for k in he4_refs_conv if (k.startswith("CP-") and ("4-BODY" not in k) and ("3-BODY" not in k) and "TOTAL ENERGY" not in k)], {"121": 10, # 10md vs. 10 for single-level, "22": 10}, # 10hi id="2b_cp"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": True, "max_nbody": 2}, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY", + # "22" at 2-body is effectively single-level so nocp enabled ... + {"121": [k for k in he4_refs_conv if (k.startswith("VMFC-") and ("4-BODY" not in k) and ("3-BODY" not in k))], + "22": [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and ("4-BODY" not in k) and ("3-BODY" not in k))]}, + {"121": 22, # 4hi + 18+28md + 15lo vs. 65 for single-level + "22": 22}, # 4+18hi + 28+15lo + id="2b_vmfc_rtd"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": False, "max_nbody": 2}, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + {"121": [k for k in he4_refs_conv if (k.startswith("VMFC-") and ("4-BODY" not in k) and ("3-BODY" not in k))], + "22": [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and ("4-BODY" not in k) and ("3-BODY" not in k))]}, + {"121": 22, # TODO could be 18 # 0+18hi = 18 + "22": 22}, # TODO could be 18 # 18hi = 18 + id="2b_vmfc"), pytest.param( {"bsse_type": "nocp", "return_total_data": True, "max_nbody": 1}, "NOCP-CORRECTED TOTAL ENERGY THROUGH 1-BODY", @@ -525,6 +547,21 @@ def he_tetramer(): {"121": 0, "22": 0}, id="1b_cp"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": True, "max_nbody": 1}, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 1-BODY", + # max_nbody=1 is effectively single-modelchem so NOCP available for free + [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and ("1-BODY" in k))], + {"121": 4, # 4hi + "22": 4}, + id="1b_vmfc_rtd"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": False, "max_nbody": 1}, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", + [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and ("1-BODY" in k))], + {"121": 4, # TODO could be 0 + "22": 4}, # TODO could be 0 + id="1b_vmfc"), ]) def test_nbody_he4_multi(levels, mbe_keywords, anskey, bodykeys, calcinfo_nmbe, he_tetramer, request, mbe_data_multilevel_631g): _inner = request.node.name.split("[")[1].split("]")[0] @@ -567,11 +604,13 @@ def test_nbody_he4_multi(levels, mbe_keywords, anskey, bodykeys, calcinfo_nmbe, refs = he4_refs_conv_multilevel_631g[pattern] ans = refs[anskey] ref_nmbe = calcinfo_nmbe[pattern] - atol = 2.0e-8 + ref_bodykeys = bodykeys[pattern] if pattern in bodykeys else bodykeys + ref_sumdict = sumdict[kwdsln][pattern] if pattern in sumdict[kwdsln] else sumdict[kwdsln] + atol = 2.5e-8 for qcv, ref in refs.items(): skp = skprop(qcv) - if qcv in bodykeys: + if qcv in ref_bodykeys: assert compare_values(ref, ret.extras["qcvars"]["nbody"][qcv], atol=atol, label=f"[a] qcvars {qcv}") assert compare_values(ref, getattr(ret.properties, skp), atol=atol, label=f"[b] skprop {skp}") else: @@ -580,8 +619,8 @@ def test_nbody_he4_multi(levels, mbe_keywords, anskey, bodykeys, calcinfo_nmbe, for qcv in sumdict["4b_all"]: skp = skprop(qcv) - if qcv in sumdict[kwdsln]: - ref = refs[sumdict[kwdsln][qcv]] + if qcv in ref_sumdict: + ref = refs[ref_sumdict[qcv]] assert compare_values(ref, ret.extras["qcvars"]["nbody"][qcv], atol=atol, label=f"[c] qcvars {qcv}") assert compare_values(ref, getattr(ret.properties, skp), atol=atol, label=f"[d] skprop {skp}") else: diff --git a/qcmanybody/models/test_mbe_he4_singlelevel.py b/qcmanybody/models/test_mbe_he4_singlelevel.py index 848664d..52fc2d5 100644 --- a/qcmanybody/models/test_mbe_he4_singlelevel.py +++ b/qcmanybody/models/test_mbe_he4_singlelevel.py @@ -11,7 +11,7 @@ from qcmanybody.models.qcng_computer import ManyBodyComputerQCNG, qcvars_to_manybodyproperties import qcengine as qcng -from .addons import using +from addons import using def skprop(qcvar): # qcng: return qcng.procedures.manybody.qcvars_to_manybodyproperties[qcvar] @@ -104,10 +104,19 @@ def skprop(qcvar): "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", }, "4b_cpvmfc": { + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY", "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", }, + "4b_nocpcp": { + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + }, "4b_nocp_rtd_sio": { "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", @@ -138,6 +147,22 @@ def skprop(qcvar): "4b_cp": { "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", }, + "4b_vmfc_rtd": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + }, + "4b_vmfc": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY", # TODO remove? + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + "CP-CORRECTED TOTAL ENERGY": "CP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + }, "3b_nocp_rtd": { "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 3-BODY", "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", @@ -153,6 +178,18 @@ def skprop(qcvar): "3b_cp": { "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", }, + "3b_vmfc_rtd": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 3-BODY", + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 3-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + }, + "3b_vmfc": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 3-BODY", # TODO remove? + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 3-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + }, "2b_nocp_rtd": { "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 2-BODY", "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", @@ -168,6 +205,18 @@ def skprop(qcvar): "2b_cp": { "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", }, + "2b_vmfc_rtd": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY", + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 2-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + }, + "2b_vmfc": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY", # TODO remove? + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 2-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + }, "1b_nocp_rtd": { "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 1-BODY", "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", @@ -183,6 +232,18 @@ def skprop(qcvar): "1b_cp": { "CP-CORRECTED INTERACTION ENERGY": "CP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", }, + "1b_vmfc_rtd": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 1-BODY", + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 1-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", + }, + "1b_vmfc": { + "VMFC-CORRECTED TOTAL ENERGY": "VMFC-CORRECTED TOTAL ENERGY THROUGH 1-BODY", # TODO remove? + "VMFC-CORRECTED INTERACTION ENERGY": "VMFC-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", + "NOCP-CORRECTED TOTAL ENERGY": "NOCP-CORRECTED TOTAL ENERGY THROUGH 1-BODY", + "NOCP-CORRECTED INTERACTION ENERGY": "NOCP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", + }, } @@ -209,7 +270,7 @@ def he_tetramer(): pytest.param( {"bsse_type": ["cp", "vmfc"]}, "CP-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", - [k for k in he4_refs_conv if ((k.startswith("CP-") and ("TOTAL" not in k)) or (k.startswith("VMFC-")))], + [k for k in he4_refs_conv], # if ((k.startswith("CP-") and ("TOTAL" not in k)) or (k.startswith("VMFC-")))], # TODO: when vmfc active, nocp always available up to max_nbody. cp available if max_nbody=nfr. activate? 65, id="4b_cpvmfc"), @@ -237,7 +298,6 @@ def he_tetramer(): [k for k in he4_refs_conv if (k.startswith("CP-") and ("THROUGH 4-BODY" in k or "THROUGH 1-BODY" in k) and "TOTAL ENERGY" not in k)], 5, id="4b_cp_sio"), -## TODO add vmfc. 3b nmbe=50 pytest.param( {"bsse_type": "nocp", "return_total_data": True}, "NOCP-CORRECTED TOTAL ENERGY THROUGH 4-BODY", @@ -262,6 +322,18 @@ def he_tetramer(): [k for k in he4_refs_conv if (k.startswith("CP-") and "TOTAL ENERGY" not in k)], 15, id="4b_cp"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": True}, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 4-BODY", + [k for k in he4_refs_conv], # vmfc brings nocp & cp for free + 65, + id="4b_vmfc_rtd"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": False}, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 4-BODY", + [k for k in he4_refs_conv], + 65, # TODO 61 in reach + id="4b_vmfc"), pytest.param( {"bsse_type": "nocp", "return_total_data": True, "max_nbody": 3}, "NOCP-CORRECTED TOTAL ENERGY THROUGH 3-BODY", @@ -286,6 +358,18 @@ def he_tetramer(): [k for k in he4_refs_conv if (k.startswith("CP-") and "4-BODY" not in k and "TOTAL ENERGY" not in k)], 14, id="3b_cp"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": True, "max_nbody": 3}, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 3-BODY", + [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and "4-BODY" not in k)], + 50, + id="3b_vmfc_rtd"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": False, "max_nbody": 3}, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 3-BODY", + [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and "4-BODY" not in k)], # and "TOTAL ENERGY" not in k)], + 50, # TODO 46 in reach, + id="3b_vmfc"), pytest.param( {"bsse_type": "nocp", "return_total_data": True, "max_nbody": 2}, "NOCP-CORRECTED TOTAL ENERGY THROUGH 2-BODY", @@ -310,13 +394,24 @@ def he_tetramer(): [k for k in he4_refs_conv if (k.startswith("CP-") and ("4-BODY" not in k) and ("3-BODY" not in k) and "TOTAL ENERGY" not in k)], 10, id="2b_cp"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": True, "max_nbody": 2}, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 2-BODY", + [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and ("4-BODY" not in k) and ("3-BODY" not in k))], + 22, + id="2b_vmfc_rtd"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": False, "max_nbody": 2}, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 2-BODY", + [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and ("4-BODY" not in k) and ("3-BODY" not in k))], # and "TOTAL ENERGY" not in k)], + 22, # TODO 18 in reach + id="2b_vmfc"), pytest.param( {"bsse_type": "nocp", "return_total_data": True, "max_nbody": 1}, "NOCP-CORRECTED TOTAL ENERGY THROUGH 1-BODY", [k for k in he4_refs_conv if (k.startswith("NOCP-") and ("1-BODY" in k))], 4, id="1b_nocp_rtd"), -# TODO fix 1b for rtd=F pytest.param( {"bsse_type": "nocp", "return_total_data": False, "max_nbody": 1}, "NOCP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", @@ -334,8 +429,19 @@ def he_tetramer(): "CP-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", [k for k in he4_refs_conv if (k.startswith("CP-") and ("1-BODY" in k) and "TOTAL ENERGY" not in k)], 0, -# 4, id="1b_cp"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": True, "max_nbody": 1}, + "VMFC-CORRECTED TOTAL ENERGY THROUGH 1-BODY", + [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and ("1-BODY" in k))], + 4, + id="1b_vmfc_rtd"), + pytest.param( + {"bsse_type": "vmfc", "return_total_data": False, "max_nbody": 1}, + "VMFC-CORRECTED INTERACTION ENERGY THROUGH 1-BODY", + [k for k in he4_refs_conv if ((k.startswith("VMFC-") or k.startswith("NOCP-")) and ("1-BODY" in k))], + 4, # maybe TODO this could be 0 but rtd hasn't be used to winnow vmfc + id="1b_vmfc"), ]) def test_nbody_he4_single(program, basis, keywords, mbe_keywords, anskey, bodykeys, calcinfo_nmbe, he_tetramer, request): #! MP2/aug-cc-pvDZ many body energies of an arbitrary Helium complex, diff --git a/tests/ref_data/h2o_trimer_single_gradient_1.json.zst b/tests/ref_data/h2o_trimer_single_gradient_1.json.zst index 8691b81..61e2c5d 100644 Binary files a/tests/ref_data/h2o_trimer_single_gradient_1.json.zst and b/tests/ref_data/h2o_trimer_single_gradient_1.json.zst differ diff --git a/tests/ref_data/h2o_trimer_single_hessian_1.json.zst b/tests/ref_data/h2o_trimer_single_hessian_1.json.zst index cc490ea..b84cacb 100644 Binary files a/tests/ref_data/h2o_trimer_single_hessian_1.json.zst and b/tests/ref_data/h2o_trimer_single_hessian_1.json.zst differ