def test_9_mpwlyp1w(h2o): qcdb.set_options({ "basis": "cc-pvdz", "nwchem_dft__xc": "mpw91 vwn_5 0.12 lyp 0.88" }) val = qcdb.energy("nwc-mpwlyp1w", molecule=h2o) check_mpwlyp1w(val)
def test_sp_uhf_scf(): """cfour/sp-uhf-scf/input.dat UHF-SCF energy calculation #global testing """ nh2 = qcdb.set_molecule(""" 0 2 N H 1 R H 1 R 2 A R=1.008 A=105.0 """) qcdb.set_options({ #'cfour_CALC_level': 'HF', 'cfour_BASIS': 'qz2p', 'cfour_REFerence': 'UHF', 'cfour_occupation': [[3, 1, 1, 0], [3, 0, 1, 0]], 'cfour_SCF_CONV': 12 }) qcdb.energy('c4-hf') ans = -55.5893469688 tnm = sys._getframe().f_code.co_name assert compare_values(ans, qcdb.get_variable('scf total energy'), 6, tnm + 'SCF') #TEST assert compare_values(ans, qcdb.get_variable('current energy'), 6, tnm + 'Current') #TEST assert compare_values(ans, qcdb.get_variable('current reference energy'), 6, tnm + 'Current ref') #TEST
def test_1_eomccsd(): h2o = qcdb.set_molecule( """ O 0.000000000000 0.000000000000 -0.123909374404 H 0.000000000000 1.429936611037 0.983265845431 H 0.000000000000 -1.429936611037 0.983265845431 """ ) qcdb.set_options( { "basis": "6-31g*", "memory": "1500 mb", "scf__e_convergence": 1.0e-10, #'nwchem_memory' : '1500 mb', #'nwchem_memory' : '[total, 1500, stack, 400, heap, 400, global, 700, mb]', #The way nwchem speak for memory may need to change #'nwchem_stack_memory' : '400 mb', #'nwchem_heap_memory' : '400 mb', #'nwchem_global_memory' : '700 mb', "nwchem_scf__thresh": 1.0e-10, "nwchem_scf__tol2e": 1.0e-10, "nwchem_scf__rhf": True, "qc_module": "tce", "nwchem_tce__ccsd": True, "nwchem_tce__nroots": 12, } ) print("Testing EOM-CCSD...") val = qcdb.energy("nwc-eom-ccsd") check_eomccsd(val)
def test_tu1_rhf_b(): """tu1-h2o-energy/input.dat local testing """ # memory 600 mb h2o = qcdb.Molecule(""" O H 1 1.8 H 1 1.8 2 104.5 units au """) qcdb.set_options({ 'scf_type': 'pk', }) E, jrec = qcdb.energy('p4-hf/cc-pVDZ', molecule=h2o, return_wfn=True) print(qcdb.print_variables(jrec['qcvars'])) assert compare_values(_ref_h2o_pk_rhf, jrec['qcvars']['HF TOTAL ENERGY'].data, 6, sys._getframe().f_code.co_name)
def test_sp_rhf_ccsd_ao(h2o): """cfour/sp-rhf-ccsd-ao/input.dat #! single point CCSD/qz2p on water """ h2o = qcdb.set_molecule(h2o) qcdb.set_options({ #'cfour_CALC_level': 'CCSD', "cfour_BASIS": "qz2p", "cfour_abcdtype": "aobasis", "cfour_SCF_CONV": 12, "cfour_CC_CONV": 12, }) e, jrec = qcdb.energy("c4-ccsd", return_wfn=True, molecule=h2o) scftot = -76.062748460117 mp2tot = -76.332940127333 ccsdcorl = -0.275705491773 ccsdtot = -76.338453951890 assert compare_values(scftot, qcdb.variable("scf total energy"), 6, tnm() + "SCF") assert compare_values(mp2tot, qcdb.variable("mp2 total energy"), 6, tnm() + "MP2") assert compare_values(ccsdcorl, qcdb.variable("ccsd correlation energy"), 6, tnm() + "CCSD corl") assert compare_values(ccsdtot, qcdb.variable("ccsd total energy"), 6, tnm() + "CCSD")
def test_1_ccsd_t_(): h2o = qcdb.set_molecule( """ O 0.000000000000 0.000000000000 -0.065638538099 H 0.000000000000 -0.757480611647 0.520865616174 H 0.000000000000 0.757480611647 0.520865616174 """ ) qcdb.set_options( { "basis": "cc-pvdz", "nwchem_scf__rhf": True, "nwchem_scf__thresh": 1.0e-12, "nwchem_tce__dft": False, #'nwchem_tce__ccsd': True, "nwchem_tce__ccsd(t)": True, "qc_module": "tce", "nwchem_tce__thresh": 1.0e-12, #'nwchem_task_tce': 'energy' } ) print(" Testing ccsd...") val = qcdb.energy("nwc-ccsd(t)") check_ccsd_t_(val)
def test_2_conv_mp2(h2o): qcdb.set_molecule(h2o) qcdb.set_options({'basis': 'cc-pvdz', 'psi4_mp2_type': 'conv'}) print(' Testing mp2 (conv) ...') val = qcdb.energy('mp2') check_mp2(val, is_df=False)
def test_4_bp91(h2o): qcdb.set_options({ "basis": "cc-pvdz", "nwchem_dft__xc": "becke88 perdew91" }) val = qcdb.energy("nwc-bp91", molecule=h2o) check_bp91(val)
def test_grad(): h2o = qcdb.set_molecule( """ O 0.00000000 0.00000000 0.00000000 H 0.00000000 1.93042809 -1.10715266 H 0.00000000 -1.93042809 -1.10715266 units au""" ) qcdb.set_options( { "basis": "sto-3g", "scf__e_convergence": 1e-6, #'nwchem_driver__tight': True } ) val = qcdb.gradient("nwc-scf") scf = -74.888142460799 grads = np.array( [[0.000000, 0.000000, 0.058550], [0.000000, 0.140065, -0.029275], [0.000000, -0.140065, -0.029275]] ) assert compare_values(scf, qcdb.variable("HF TOTAL ENERGY"), 5, "scf") assert compare_arrays(grads, qcdb.variable("CURRENT GRADIENT"), 5, "scf grad")
def test_15_b97_1(h2o): qcdb.set_options({ "basis": "cc-pvdz", "nwchem_dft__xc": "becke97gga1 hfexch" }) val = qcdb.energy("nwc-b97-1", molecule=h2o) check_b97_1(val)
def test_1_pw91(h2o): qcdb.set_options({ "basis": "cc-pvdz", "nwchem_dft__xc": "xperdew91 perdew91" }) val = qcdb.energy("nwc-pw91", molecule=h2o) check_pw91(val)
def test_12_b2plyp(h2o): qcdb.set_options({ "basis": "cc-pvdz", "nwchem_dft__xc": "hfexch 0.53 becke88 0.47 lyp 0.73" }) val = qcdb.energy("nwc-b2plyp", molecule=h2o) check_b2plyp(val)
def test_11_b1pw91(h2o): qcdb.set_options({ "basis": "cc-pvdz", "nwchem_dft__xc": "hfexch 0.25 becke88 0.75 perdew91" }) val = qcdb.energy("nwc-b1pw91", molecule=h2o) check_b1pw91(val)
def test_10_b1lyp(h2o): qcdb.set_options({ "basis": "cc-pvdz", "nwchem_dft__xc": "hfexch 0.25 becke88 0.75 lyp", }) val = qcdb.energy("nwc-b1lyp", molecule=h2o) check_b1lyp(val)
def test_sp_ccsd_uhf_fc(method, keywords, nh2): """cfour/sp-uhf-ccsd/input.dat #! single-point CCSD/qz2p on NH2 """ nh2 = qcdb.set_molecule(nh2) qcdb.set_options(keywords) e = qcdb.energy(method, molecule=nh2) scf_tot = -55.5893469688 mp2_tot = -55.760531091893 ccsd_tot = -55.777664191533 mp2_corl = mp2_tot - scf_tot ccsd_corl = ccsd_tot - scf_tot atol = 1.e-6 # cc terms assert compare_values(ccsd_tot, e, tnm() + ' Returned', atol=atol) assert compare_values(ccsd_tot, qcdb.variable('current energy'), tnm() + ' Current', atol=atol) assert compare_values(ccsd_tot, qcdb.variable('ccsd total energy'), tnm() + ' CCSD', atol=atol) assert compare_values(ccsd_corl, qcdb.variable('current correlation energy'), tnm() + ' CCSD', atol=atol) assert compare_values(ccsd_corl, qcdb.variable('ccsd correlation energy'), tnm() + ' CCSD', atol=atol) # mp2 terms (not printed for nwc tce) if not (method.startswith('nwc') and keywords.get('qc_module', 'nein').lower() == 'tce'): assert compare_values(mp2_tot, qcdb.variable('mp2 total energy'), tnm() + ' MP2', atol=atol) assert compare_values(mp2_corl, qcdb.variable('mp2 correlation energy'), tnm() + ' MP2', atol=atol) # hf terms assert compare_values(scf_tot, qcdb.variable('hf total energy'), tnm() + ' SCF', atol=atol) assert compare_values(scf_tot, qcdb.variable('scf total energy'), tnm() + ' SCF', atol=atol)
def test_sp_uhf_ccsd(nh2): """cfour/sp-uhf-ccsd/input.dat #! single-point CCSD/qz2p on NH2 """ nh2 = qcdb.set_molecule(nh2) qcdb.set_options({ #'cfour_CALC_level': 'CCSD', 'cfour_BASIS': 'qz2p', 'cfour_REFerence': 'UHF', 'cfour_occupation': [[3, 1, 1, 0], [3, 0, 1, 0]], 'cfour_SCF_CONV': 12, 'cfour_CC_CONV': 12, }) qcdb.energy('c4-ccsd', molecule=nh2) scftot = -55.5893469688 mp2tot = -55.784877360093 ccsdcorl = -0.213298055172 tnm = sys._getframe().f_code.co_name assert compare_values(scftot, qcdb.get_variable('scf total energy'), 6, tnm + 'SCF') assert compare_values(mp2tot, qcdb.get_variable('mp2 total energy'), 6, tnm + 'MP2') assert compare_values(ccsdcorl, qcdb.get_variable('ccsd correlation energy'), 6, tnm + 'CCSD')
def test_simple_ghost(qcp): dimer = qcdb.set_molecule( f""" He -- Ne 1 R """ ) dimer.R = 2.5 monomer = dimer.extract_fragments(1, 2) qcdb.set_options( { "basis": "aug-cc-pVDZ", "freeze_core": True, "scf_type": "conv", # longstanding "pk" "d_convergence": 8, } ) ene, wfn = qcdb.energy(qcp + "hf", return_wfn=True, molecule=monomer) pprint.pprint(wfn, width=200) atol = 1.0e-6 assert compare_values(0.0, qcdb.variable("nuclear repulsion energy"), atol=atol, label="nre") assert compare_values(0.0, wfn["properties"]["nuclear_repulsion_energy"], atol=atol, label="nre") assert compare(32, wfn["properties"]["calcinfo_nbasis"], label="nbas") assert compare(32, wfn["properties"]["calcinfo_nmo"], label="nmo") assert compare_values(-2.8557143339397539, ene, atol=atol, label="ene")
def test_sp_rhf_ccsd_ao(h2o): """cfour/sp-rhf-ccsd-ao/input.dat #! single point CCSD/qz2p on water """ h2o = qcdb.set_molecule(h2o) qcdb.set_options({ #'cfour_CALC_level': 'CCSD', 'cfour_BASIS': 'qz2p', 'cfour_abcdtype': 'aobasis', 'cfour_SCF_CONV': 12, 'cfour_CC_CONV': 12 }) e, jrec = qcdb.energy('c4-ccsd', return_wfn=True, molecule=h2o) scftot = -76.062748460117 mp2tot = -76.332940127333 ccsdcorl = -0.275705491773 ccsdtot = -76.338453951890 tnm = sys._getframe().f_code.co_name assert compare_values(scftot, qcdb.get_variable('scf total energy'), 6, tnm + 'SCF') assert compare_values(mp2tot, qcdb.get_variable('mp2 total energy'), 6, tnm + 'MP2') assert compare_values(ccsdcorl, qcdb.get_variable('ccsd correlation energy'), 6, tnm + 'CCSD corl') assert compare_values(ccsdtot, qcdb.get_variable('ccsd total energy'), 6, tnm + 'CCSD')
def test_1_df_mp2(h2o): qcdb.set_molecule(h2o) qcdb.set_options({'basis': 'cc-pvdz'}) print(' Testing mp2 (df) ...') val = qcdb.energy('mp2') check_mp2(val, is_df=True)
def test_sp_rhf_mp2(h2o): """cfour/sp-rhf-mp2/input.dat #! single-point MP2/qz2p on water """ h2o = qcdb.set_molecule(h2o) qcdb.set_options({"cfour_BASIS": "qz2p", "d_convergence": 12}) e, jrec = qcdb.energy("c4-mp2", return_wfn=True, molecule=h2o) scftot = -76.0627484601 mp2corl = -0.270191667216 mp2tot = -76.332940127333 assert compare_values(scftot, qcdb.variable("scf total energy"), 6, tnm() + " SCF") assert compare_values(mp2corl, qcdb.variable("mp2 correlation energy"), 6, tnm() + " MP2 corl") assert compare_values(mp2tot, qcdb.variable("mp2 total energy"), 6, tnm() + " MP2") assert compare_values(scftot, jrec["qcvars"]["HF TOTAL ENERGY"].data, 6, tnm()) assert compare_values(mp2corl, jrec["qcvars"]["MP2 CORRELATION ENERGY"].data, 6, tnm()) assert compare_values(mp2tot, jrec["qcvars"]["CURRENT ENERGY"].data, 6, tnm())
def test_tu1_rhf_a(): """tu1-h2o-energy/input.dat global testing """ h2o = qcdb.set_molecule(""" O H 1 1.8 H 1 1.8 2 104.5 units au """) print(h2o) print(qcdb.get_active_options().print_changed()) qcdb.set_options({ 'basis': 'cc-pVDZ', 'scf_type': 'pk', 'memory': '600 mb' }) qcdb.energy('p4-hf') print(qcdb.print_variables()) assert compare_values(_ref_h2o_pk_rhf, qcdb.get_variable('HF TOTAL ENERGY'), 6, sys._getframe().f_code.co_name)
def test_sp_uhf_mp2(nh2): nh2 = qcdb.set_molecule(nh2) qcdb.set_options({ #'cfour_CALC_level': 'MP2', "cfour_BASIS": "qz2p", "cfour_REFerence": "UHF", "cfour_occupation": [[3, 1, 1, 0], [3, 0, 1, 0]], "cfour_SCF_CONV": 12, }) qcdb.energy("c4-mp2", molecule=nh2) assert compare_values(-55.5893469688, qcdb.variable("scf total energy"), 6, tnm() + " SCF") assert compare_values(-55.784877360093, qcdb.variable("mp2 total energy"), 6, tnm() + " MP2") assert compare_values(-0.195530391306, qcdb.variable("mp2 correlation energy"), 6, tnm() + " MP2 corl") assert compare_values(-0.195530391306, qcdb.variable("mp2 doubles energy"), 6, tnm() + " MP2 corl") assert compare_values(0.0, qcdb.variable("mp2 singles energy"), 6, tnm() + " MP2 corl") assert compare_values(-0.0416164, qcdb.variable("mp2 same-spin correlation energy"), 6, tnm() + " MP2 SS corl") assert compare_values( -0.1539141, qcdb.variable("mp2 opposite-spin correlation energy"), 6, tnm() + " MP2 OS corl")
def test_tu2_uhf(): """tu2-ch2-energy/input.dat #! Sample UHF/6-31G** CH2 computation """ ch2 = qcdb.set_molecule(""" 0 3 C H 1 R H 1 R 2 A R = 2.05 A = 133.93 units au """) qcdb.set_options({ 'basis': '6-31G**', 'reference': ' uhf', 'puream': 'cart', #'psi_scf_type': 'pk'}) 'scf_type': 'pk' }) E, jrec = qcdb.energy('p4-hf', return_wfn=True) print(qcdb.print_variables()) assert compare_values(_ref_ch2_pk_uhf, qcdb.get_variable('hf total energy'), 6, sys._getframe().f_code.co_name)
def test_sp_rohf_mp2_sc(nh2): nh2 = qcdb.set_molecule(nh2) qcdb.set_options({ # cfour_CALC_level=MP2 "cfour_BASIS": "qz2p", "cfour_REFerence": "ROHF", "cfour_OCCUPATION": [[3, 1, 1, 0], [3, 0, 1, 0]], "cfour_SCF_CONV": 12, "cfour_CC_CONV": 12, }) qcdb.energy("c4-mp2", molecule=nh2) scftot = -55.5847372601 scorl = -0.002983751786 oscorl = -0.155770420921 sscorl = -0.041785354569 mp2corl = -0.200539527276 mp2tot = -55.785276787341 assert compare_values(scftot, qcdb.variable("scf total energy"), 6, tnm() + " SCF") assert compare_values(scorl, qcdb.variable("mp2 singles energy"), 6, tnm() + " MP2 singles") # non printed assert compare_values(oscorl, qcdb.variable('mp2 opposite-spin correlation energy'), 6, tnm() + ' MP2 OS corl') # not printed assert compare_values(sscorl, qcdb.variable('mp2 same-spin correlation energy'), 6, tnm() + ' MP2 SS corl') assert compare_values(mp2corl, qcdb.variable("mp2 correlation energy"), 6, tnm() + " MP2 corl") assert compare_values(mp2corl - scorl, qcdb.variable("mp2 doubles energy"), 6, tnm() + " MP2 corl") assert compare_values(mp2tot, qcdb.variable("mp2 total energy"), 6, tnm() + " MP2")
def test_sp_uhf_ccsd(nh2): """cfour/sp-uhf-ccsd/input.dat #! single-point CCSD/qz2p on NH2 """ nh2 = qcdb.set_molecule(nh2) qcdb.set_options({ #'cfour_CALC_level': 'CCSD', "cfour_BASIS": "qz2p", "cfour_REFerence": "UHF", "cfour_occupation": [[3, 1, 1, 0], [3, 0, 1, 0]], "cfour_SCF_CONV": 12, "cfour_CC_CONV": 12, }) qcdb.energy("c4-ccsd", molecule=nh2) scftot = -55.5893469688 mp2tot = -55.784877360093 ccsdcorl = -0.213298055172 assert compare_values(scftot, qcdb.variable("scf total energy"), 6, tnm() + "SCF") assert compare_values(mp2tot, qcdb.variable("mp2 total energy"), 6, tnm() + "MP2") assert compare_values(ccsdcorl, qcdb.variable("ccsd correlation energy"), 6, tnm() + "CCSD")
def test_1_df_mp2(h2o): qcdb.set_molecule(h2o) qcdb.set_options({"basis": "cc-pvdz"}) print(" Testing mp2 (df) ...") val = qcdb.energy("mp2") check_mp2(val, is_df=True)
def test_sp_rhf_scf_b(): """cfour/sp-rhf-scf/input.dat #! single-point HF/qz2p on water """ h2o = qcdb.set_molecule(""" O H 1 R H 1 R 2 A R=0.958 A=104.5 """) qcdb.set_options({ 'cfour_calc_level': 'hf', 'cfour_basis': 'qz2p', 'cfour_scf_conv': 12 }) e, jrec = qcdb.energy('c4-cfour', return_wfn=True) ans = -76.0627484601 tnm = sys._getframe().f_code.co_name assert compare_values(ans, qcdb.get_variable('scf total energy'), 6, tnm + ' SCF') assert compare_values(ans, qcdb.get_variable('current energy'), 6, tnm + ' SCF') assert compare_values(ans, jrec['qcvars']['SCF TOTAL ENERGY'].data, 6, tnm) assert compare_values(ans, jrec['qcvars']['CURRENT ENERGY'].data, 6, tnm)
def test_2_conv_mp2(h2o): qcdb.set_molecule(h2o) qcdb.set_options({"basis": "cc-pvdz", "psi4_mp2_type": "conv"}) print(" Testing mp2 (conv) ...") val = qcdb.energy("mp2") check_mp2(val, is_df=False)
def test_tu2_rohf(): """tu2-ch2-energy/input.dat #! Sample ROHF/6-31G** CH2 computation """ ch2 = qcdb.set_molecule(""" 0 3 C H 1 R H 1 R 2 A R = 2.05 A = 133.93 units au """) qcdb.set_options({ 'basis': '6-31G**', 'reference': ' rohf', 'puream': 'cart', #'psi_scf_type': 'pk'}) 'scf_type': 'pk' }) E, jrec = qcdb.energy('nwc-hf', return_wfn=True) print(qcdb.print_variables()) assert compare_values(_ref_ch2_pk_rohf, qcdb.variable('hf total energy'), 6, tnm()) assert compare_values(_ref_ch2_pk_rohf, qcdb.variable('current energy'), 6, tnm()) assert compare_values(_ref_ch2_pk_rohf, E, 6, tnm())
def test_8_mpwlyp1m(h2o): qcdb.set_options({ "basis": "cc-pvdz", "nwchem_dft__xc": "mpw91 0.95 hfexch 0.05 lyp" }) val = qcdb.energy("nwc-mpwlyp1m", molecule=h2o) check_mpwlyp1m(val)