Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Aug 27, 2024
1 parent 5941338 commit ad53183
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyscf/pbc/tdscf/krhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def init_guess(self, mf, kshift, nstates=None):

nov = e_ia.size
nstates = min(nstates, nov)
e_threshold = numpy.sort(e_ia)[nstates-1]
e_threshold = numpy.partition(e_ia, nstates-1)[nstates-1]
e_threshold += self.deg_eia_thresh

idx = numpy.where(e_ia <= e_threshold)[0]
Expand Down
8 changes: 5 additions & 3 deletions pyscf/pbc/tdscf/test/test_krhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ def test_tda_triplet(self):
self.kernel(tdscf.KTDA, ref, np.arange(2), singlet=False)

def test_tdhf_singlet(self):
ref = [[10.60761946, 10.76654619]]
td = self.kernel(tdscf.KTDHF, ref, [0], conv_tol=1e-7)
# The first state can be obtained by solving nstates=9
#ref = [[10.60761946, 10.76654619, 10.76654619]]
ref = [[10.76654619, 10.76654619]]
td = self.kernel(tdscf.KTDHF, ref, [0])
a0, b0 = td.get_ab(kshift=0)
eref0 = diagonalize(a0, b0)
self.assertAlmostEqual(abs(td.e[0][:2] - eref0[:2]).max(), 0, 5)
self.assertAlmostEqual(abs(td.e[0][:2] - eref0[1:3]).max(), 0, 5)

nk, no, nv = a0.shape[:3]
nkov = nk * no * nv
Expand Down
2 changes: 1 addition & 1 deletion pyscf/pbc/tdscf/test/test_krks.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_tda_triplet(self):
self.kernel('TDA', ref, singlet=False)

def test_tdhf_singlet(self):
ref = [[9.2519208050, 9.3208025447]]
ref = [[9.25192096, 9.32080304]]
td = self.kernel('TDDFT', ref)
a, b = td.get_ab(kshift=0)
eref = diagonalize(a, b)
Expand Down
2 changes: 1 addition & 1 deletion pyscf/pbc/tdscf/test/test_kuhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_tda(self):
def test_tdhf(self):
# same as lowest roots in Diamond->test_tdhf_singlet/triplet in test_krhf.py
ref = [[5.9794378466, 5.9794378466]]
self.kernel(tdscf.KTDHF, ref, [0], conv_tol=1e-7)
self.kernel(tdscf.KTDHF, ref, [0])


class WaterBigBox(unittest.TestCase):
Expand Down

0 comments on commit ad53183

Please sign in to comment.