Skip to content

Commit ece24f4

Browse files
committed
Bug fix on two H test when HOMO LUMO are degenerate
1 parent 1b60629 commit ece24f4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

gpu4pyscf/hessian/rhf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ def solve_mo1(mf, mo_energy, mo_coeff, mo_occ, h1mo,
629629
e_ai = 1 / (e_a[:,None] + level_shift - e_i)
630630
nvir, nocc = e_ai.shape
631631

632+
if any(np.isinf(e_ai)) or any(np.isnan(e_ai)):
633+
raise ValueError(f"e_ai = {e_ai} contains inf or nan, likely because HOMO-LUMO gap is zero.")
634+
632635
mocc = mo_coeff[:,occidx]
633636
nao, nmo = mo_coeff.shape
634637
natm = mol.natm

gpu4pyscf/hessian/tests/test_large_exponent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def test_hessian_large_exp_two_atom_rks(self):
181181
mf = dft.RKS(mol_minimal_two_atom, xc = "wB97X")
182182
mf.grids.atom_grid = (50,194)
183183
mf.conv_tol = 1e-10
184+
mf.level_shift = 0.001
184185

185186
mf.kernel()
186187
assert mf.converged

0 commit comments

Comments
 (0)