Skip to content

Commit

Permalink
PySCF(-forge) version update and test
Browse files Browse the repository at this point in the history
Updated MC-DCFT interface required test file edits
  • Loading branch information
MatthewRHermes committed Dec 20, 2024
1 parent 2b98b17 commit 96114aa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pyscf-forge_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
git+https://github.com/pyscf/pyscf-forge.git@9564956cb7443394f0aacb6a51db03b5da2f69f2
git+https://github.com/pyscf/pyscf-forge.git@6c1acbdcb8a1ac272638221b3e99c38d8fc3492f
2 changes: 1 addition & 1 deletion pyscf_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
git+https://github.com/pyscf/pyscf.git@9f8fe3021ec5eeaa66c0a5b14b5e5de32a2a35dc
git+https://github.com/pyscf/pyscf.git@08af6793e69ce899380195e89054cd9e4b918056
39 changes: 25 additions & 14 deletions tests/mcdcft/test_energy_h2_dupe.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,66 @@
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
mc.kernel()
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")
Expand Down

0 comments on commit 96114aa

Please sign in to comment.