From 39d1ff273cf486356b04064ffb02a87f985d9a92 Mon Sep 17 00:00:00 2001 From: Qiming Sun Date: Mon, 17 Jun 2024 23:45:09 -0700 Subject: [PATCH] Degeneracy issue in KGKS tests --- pyscf/pbc/dft/kgks.py | 3 +++ pyscf/pbc/dft/test/test_kgks.py | 2 +- pyscf/pbc/scf/ghf.py | 1 + pyscf/pbc/scf/kghf.py | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pyscf/pbc/dft/kgks.py b/pyscf/pbc/dft/kgks.py index d1187a8b33..e968a73af7 100644 --- a/pyscf/pbc/dft/kgks.py +++ b/pyscf/pbc/dft/kgks.py @@ -35,6 +35,7 @@ from pyscf.pbc.dft import rks from pyscf.pbc.dft import multigrid from pyscf.pbc.dft.numint2c import KNumInt2C +from pyscf.dft import gks as mol_ks from pyscf import __config__ def get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, @@ -117,6 +118,8 @@ class KGKS(rks.KohnShamDFT, kghf.KGHF): '''GKS class adapted for PBCs with k-point sampling. ''' + collinear = mol_ks.GKS.collinear + spin_samples = mol_ks.GKS.spin_samples get_veff = get_veff energy_elec = krks.energy_elec get_rho = krks.get_rho diff --git a/pyscf/pbc/dft/test/test_kgks.py b/pyscf/pbc/dft/test/test_kgks.py index 6ebd1165ea..5d780b9f40 100644 --- a/pyscf/pbc/dft/test/test_kgks.py +++ b/pyscf/pbc/dft/test/test_kgks.py @@ -137,7 +137,7 @@ def test_collinear_kgks_gga(self): mf.xc = 'pbe' mf.collinear = 'col' mf.run() - self.assertAlmostEqual(mf.e_tot, -1.5775787238220018, 7) + self.assertAlmostEqual(mf.e_tot, -1.6373456924395708, 7) @unittest.skipIf(mcfun is None, "mcfun library not found.") def test_mcol_kgks_gga(self): diff --git a/pyscf/pbc/scf/ghf.py b/pyscf/pbc/scf/ghf.py index e5f12dc901..fc5830006e 100644 --- a/pyscf/pbc/scf/ghf.py +++ b/pyscf/pbc/scf/ghf.py @@ -100,6 +100,7 @@ def get_jk(mf, cell=None, dm=None, hermi=0, kpt=None, kpts_band=None, class GHF(pbchf.SCF): '''GHF class for PBCs. ''' + _keys = {'with_soc'} def __init__(self, cell, kpt=np.zeros(3), exxdiv=getattr(__config__, 'pbc_scf_SCF_exxdiv', 'ewald')): diff --git a/pyscf/pbc/scf/kghf.py b/pyscf/pbc/scf/kghf.py index 2ce492067c..89259e4ea8 100644 --- a/pyscf/pbc/scf/kghf.py +++ b/pyscf/pbc/scf/kghf.py @@ -186,6 +186,8 @@ def fn_init_guess(mf, cell=None, kpts=None): class KGHF(khf.KSCF): '''GHF class for PBCs. ''' + _keys = {'with_soc'} + def __init__(self, cell, kpts=np.zeros((1,3)), exxdiv=getattr(__config__, 'pbc_scf_SCF_exxdiv', 'ewald')): khf.KSCF.__init__(self, cell, kpts, exxdiv)