From 96114aac89ade959155f6b9c995fadb84e920f0a Mon Sep 17 00:00:00 2001 From: Matthew R Hermes Date: Fri, 20 Dec 2024 12:22:29 -0600 Subject: [PATCH] PySCF(-forge) version update and test Updated MC-DCFT interface required test file edits --- pyscf-forge_version.txt | 2 +- pyscf_version.txt | 2 +- tests/mcdcft/test_energy_h2_dupe.py | 39 ++++++++++++++++++----------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/pyscf-forge_version.txt b/pyscf-forge_version.txt index ba572144..cbc0859a 100644 --- a/pyscf-forge_version.txt +++ b/pyscf-forge_version.txt @@ -1 +1 @@ -git+https://github.com/pyscf/pyscf-forge.git@9564956cb7443394f0aacb6a51db03b5da2f69f2 +git+https://github.com/pyscf/pyscf-forge.git@6c1acbdcb8a1ac272638221b3e99c38d8fc3492f diff --git a/pyscf_version.txt b/pyscf_version.txt index 0f6ac641..745db250 100644 --- a/pyscf_version.txt +++ b/pyscf_version.txt @@ -1 +1 @@ -git+https://github.com/pyscf/pyscf.git@9f8fe3021ec5eeaa66c0a5b14b5e5de32a2a35dc +git+https://github.com/pyscf/pyscf.git@08af6793e69ce899380195e89054cd9e4b918056 diff --git a/tests/mcdcft/test_energy_h2_dupe.py b/tests/mcdcft/test_energy_h2_dupe.py index 4dde2f3a..87f2ac45 100644 --- a/tests/mcdcft/test_energy_h2_dupe.py +++ b/tests/mcdcft/test_energy_h2_dupe.py @@ -1,18 +1,17 @@ from pyscf import gto, scf, lib, mcscf -from pyscf.mcdcft import mcdcft +from pyscf.mcdcft import mcdcft, dcfnal #from mrh.my_pyscf.fci import csf_solver import unittest import tempfile import os -def run(r, xc, ot_name, chkfile): +def run(r, xc, chkfile): r /= 2 mol = gto.M(atom=f'H 0 0 {r}; H 0 0 -{r}', basis='cc-pvtz', symmetry=False, verbose=0) mf = scf.RHF(mol) mf.kernel() - mc = mcdcft.CASSCF(mf, xc, 2, 2, ot_name=ot_name, - grids_level=6) + mc = mcdcft.CASSCF(mf, xc, 2, 2, grids_level=6) #mc.fcisolver = csf_solver(mol, smult=1) mc.fix_spin_(ss=0) mc.chkfile = chkfile @@ -20,36 +19,48 @@ def run(r, xc, ot_name, chkfile): mc.dump_mcdcft_chk(chkfile) return mc.e_tot -def restart(xc, ot_name, chkfile): +def restart(xc, chkfile): mol = lib.chkfile.load_mol(chkfile) mol.verbose = 0 mf = scf.RHF(mol) mc = mcdcft.CASSCF(mf, None, 2, 2, grids_level=6) mc.load_mcdcft_chk(chkfile) - mc.recalculate_with_xc(xc, ot_name=ot_name, dump_chk=chkfile) + mc.recalculate_with_xc(xc, dump_chk=chkfile) return mc.e_tot +cPBE_preset = dict(args=dict(f=dcfnal.f_v1, negative_rho=True), xc_code='PBE') +cBLYP_preset = dict(args=dict(f=dcfnal.f_v1, negative_rho=True), xc_code='BLYP') + class KnownValues(unittest.TestCase): + @classmethod + def setUpClass(cls): + dcfnal.register_dcfnal_('cPBE', cPBE_preset) + dcfnal.register_dcfnal_('cBLYP', cBLYP_preset) + + @classmethod + def tearDownClass(cls): + dcfnal.unregister_dcfnal_('cPBE') + dcfnal.unregister_dcfnal_('cBLYP') def test_cPBE(self): with tempfile.NamedTemporaryFile() as chkfile1: chkname1 = chkfile1.name with tempfile.NamedTemporaryFile() as chkfile2: chkname2 = chkfile2.name - self.assertAlmostEqual(run(8.00, 'PBE', 'cPBE', chkname1) - - run(0.78, 'PBE', 'cPBE', chkname2), 0.14898997201251052, 5) - self.assertAlmostEqual(restart('BLYP', 'cBLYP', chkname1) - - restart('BLYP', 'cBLYP', chkname2), 0.15624825293702616, 5) + self.assertAlmostEqual(run(8.00, 'cPBE', chkname1) - + run(0.78, 'cPBE', chkname2), 0.14898997201251052, 5) + self.assertAlmostEqual(restart('cBLYP', chkname1) - + restart('cBLYP', chkname2), 0.15624825293702616, 5) def test_cBLYP(self): with tempfile.NamedTemporaryFile() as chkfile1: chkname1 = chkfile1.name with tempfile.NamedTemporaryFile() as chkfile2: chkname2 = chkfile2.name - self.assertAlmostEqual(run(8.00, 'BLYP', 'cBLYP', chkname1) - - run(0.78, 'BLYP', 'cBLYP', chkname2), 0.15624825293702616, 5) - self.assertAlmostEqual(restart('PBE', 'cPBE', chkname1) - - restart('PBE', 'cPBE', chkname2), 0.14898997201251052, 5) + self.assertAlmostEqual(run(8.00, 'cBLYP', chkname1) - + run(0.78, 'cBLYP', chkname2), 0.15624825293702616, 5) + self.assertAlmostEqual(restart('cPBE', chkname1) - + restart('cPBE', chkname2), 0.14898997201251052, 5) if __name__ == "__main__": print("Full Tests for MC-DCFT energies of H2 molecule")