From d2306afd75ca438606fe2ee15eca2e12baef90e4 Mon Sep 17 00:00:00 2001 From: Qiming Sun Date: Wed, 17 Sep 2025 23:47:29 -0700 Subject: [PATCH] Fix to_gpu interface for solvent modules --- pyscf/solvent/grad/pcm.py | 4 ++-- pyscf/solvent/grad/smd.py | 2 ++ pyscf/solvent/hessian/pcm.py | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyscf/solvent/grad/pcm.py b/pyscf/solvent/grad/pcm.py index 13a3c18db7..3d2338758e 100644 --- a/pyscf/solvent/grad/pcm.py +++ b/pyscf/solvent/grad/pcm.py @@ -423,12 +423,12 @@ def undo_solvent(self): return obj def to_gpu(self): - from gpu4pyscf.solvent.hessian import pcm # type: ignore + from gpu4pyscf.solvent.grad import pcm # type: ignore from pyscf.tdscf.rhf import TDBase # Only PCM and SMD are available on GPU. # FIXME: The SMD class is a child class of PCM now. Additional check for # SMD should be made if SMD is refactored as an independent class - assert isinstance(self.with_solvent, PCM) + assert isinstance(self.base.with_solvent, PCM) if isinstance(self, TDBase): raise NotImplementedError('.to_gpu() for PCM-TDDFT') return self.base.to_gpu().PCM().Gradients() diff --git a/pyscf/solvent/grad/smd.py b/pyscf/solvent/grad/smd.py index 6b21d4d41e..bd2bb0441a 100644 --- a/pyscf/solvent/grad/smd.py +++ b/pyscf/solvent/grad/smd.py @@ -114,3 +114,5 @@ def grad_solver(pcmobj, dm): def get_cds(smdobj): return smd.get_cds_legacy(smdobj)[1] + +make_grad_object = pcm_grad.make_grad_object diff --git a/pyscf/solvent/hessian/pcm.py b/pyscf/solvent/hessian/pcm.py index ec45e0619f..f591f5568e 100644 --- a/pyscf/solvent/hessian/pcm.py +++ b/pyscf/solvent/hessian/pcm.py @@ -1044,8 +1044,7 @@ def to_gpu(self): from pyscf.tdscf.rhf import TDBase if isinstance(self, TDBase): raise NotImplementedError('.to_gpu() for PCM-TDDFT') - # ground state methods - return self.undo_solvent().to_gpu().Hessian() + return self.base.to_gpu().PCM().Hessian() def kernel(self, *args, dm=None, atmlst=None, **kwargs): if dm is None: