From e077a1521381b8f3f288e3babe0920441bdae71f Mon Sep 17 00:00:00 2001 From: Qiming Sun Date: Fri, 12 Jun 2026 12:42:28 -0700 Subject: [PATCH 1/3] Add HF1e --- gpu4pyscf/scf/__init__.py | 10 ++++++++-- gpu4pyscf/scf/rohf.py | 18 ++++++++++++++++++ gpu4pyscf/scf/tests/test_rhf.py | 5 +++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/gpu4pyscf/scf/__init__.py b/gpu4pyscf/scf/__init__.py index bad2076d0..d763e2d15 100644 --- a/gpu4pyscf/scf/__init__.py +++ b/gpu4pyscf/scf/__init__.py @@ -20,13 +20,19 @@ from . import dispersion def HF(mol, *args): - if mol.nelectron == 1 or mol.spin == 0: - return RHF(mol, *args) + if mol.spin == 0: + return hf.RHF(mol, *args) + elif mol.nelectron == 1: + from .rohf import HF1e + return HF1e(mol, *args) else: return UHF(mol, *args) def RHF(mol, *args): if mol.spin == 0: return hf.RHF(mol, *args) + elif mol.nelectron == 1: + from .rohf import HF1e + return HF1e(mol, *args) else: return ROHF(mol, *args) diff --git a/gpu4pyscf/scf/rohf.py b/gpu4pyscf/scf/rohf.py index 1c03da0dc..8c5f1bc60 100644 --- a/gpu4pyscf/scf/rohf.py +++ b/gpu4pyscf/scf/rohf.py @@ -18,6 +18,7 @@ from pyscf.scf import rohf as rohf_cpu from gpu4pyscf.scf import hf, uhf from gpu4pyscf.lib.cupy_helper import tag_array, contract +from gpu4pyscf.lib import logger def get_roothaan_fock(focka_fockb, dma_dmb, s): @@ -215,3 +216,20 @@ def get_grad(self, mo_coeff, mo_occ, fock): def newton(self): from gpu4pyscf.scf.soscf import newton return newton(self) + + +class HF1e(ROHF): + def kernel(self, *args): + logger.info(self, '\n') + logger.info(self, '******** 1 electron system ********') + h = self.get_hcore() + s = self.get_ovlp() + self.mo_energy, self.mo_coeff = self.eig(h, s) + self.mo_occ = self.get_occ(self.mo_energy, self.mo_coeff) + self.e_tot = self.mo_energy[0].real.get() + self.mol.energy_nuc() + if self.chkfile: + self.dump_chk(self.chkfile) + self.converged = True + self._finalize() + return self.e_tot + scf = kernel diff --git a/gpu4pyscf/scf/tests/test_rhf.py b/gpu4pyscf/scf/tests/test_rhf.py index 629f89dcd..3e74822f2 100644 --- a/gpu4pyscf/scf/tests/test_rhf.py +++ b/gpu4pyscf/scf/tests/test_rhf.py @@ -349,6 +349,11 @@ def test_initial_guess_tag(self): assert hasattr(dm, 'mo_coeff') and dm.mo_coeff.ndim == 2 assert abs(cupy.einsum('ij,ji->', dm, s).get() - 24) < 1e-6 + def test_1e(self): + mol = pyscf.M(atom='H', basis='ccpvdz', spin=1) + mf = mol.RHF().to_gpu().run() + self.assertAlmostEqual(mf, -0.499278403419583, 9) + # TODO: #test analyze #test mulliken_pop From dc4fc295637ac25a6d7a966ddbc7f18778eb1090 Mon Sep 17 00:00:00 2001 From: Qiming Sun Date: Sat, 13 Jun 2026 08:13:01 -0700 Subject: [PATCH 2/3] Fix dump_chk --- gpu4pyscf/scf/rohf.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gpu4pyscf/scf/rohf.py b/gpu4pyscf/scf/rohf.py index 8c5f1bc60..e821033cf 100644 --- a/gpu4pyscf/scf/rohf.py +++ b/gpu4pyscf/scf/rohf.py @@ -228,7 +228,12 @@ def kernel(self, *args): self.mo_occ = self.get_occ(self.mo_energy, self.mo_coeff) self.e_tot = self.mo_energy[0].real.get() + self.mol.energy_nuc() if self.chkfile: - self.dump_chk(self.chkfile) + self.dump_chk({ + 'e_tot': self.e_tot, + 'mo_energy': self.mo_energy, + 'mo_coeff': self.mo_coeff, + 'mo_occ': self.mo_occ + }) self.converged = True self._finalize() return self.e_tot From 78274988d885bb2e1a2e23656ca20a76e69dcc53 Mon Sep 17 00:00:00 2001 From: Qiming Sun Date: Sat, 13 Jun 2026 13:00:51 -0700 Subject: [PATCH 3/3] fix --- gpu4pyscf/scf/tests/test_rhf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpu4pyscf/scf/tests/test_rhf.py b/gpu4pyscf/scf/tests/test_rhf.py index 3e74822f2..334512f94 100644 --- a/gpu4pyscf/scf/tests/test_rhf.py +++ b/gpu4pyscf/scf/tests/test_rhf.py @@ -352,7 +352,7 @@ def test_initial_guess_tag(self): def test_1e(self): mol = pyscf.M(atom='H', basis='ccpvdz', spin=1) mf = mol.RHF().to_gpu().run() - self.assertAlmostEqual(mf, -0.499278403419583, 9) + self.assertAlmostEqual(mf.e_tot, -0.499278403419583, 9) # TODO: #test analyze