gpu4pyscf 0.7.2__tar.gz → 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gpu4pyscf-0.7.2/gpu4pyscf.egg-info → gpu4pyscf-0.7.3}/PKG-INFO +1 -1
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/__init__.py +1 -1
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/grad/uhf.py +5 -2
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/grad/uks.py +13 -10
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/uhf.py +1 -1
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/grad/pcm.py +2 -1
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/grad/smd.py +5 -4
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/hessian/pcm.py +23 -9
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/hessian/smd.py +24 -10
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/pcm.py +4 -7
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/smd.py +2 -2
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3/gpu4pyscf.egg-info}/PKG-INFO +1 -1
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/LICENSE +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/MANIFEST.in +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/README.md +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/__config__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/cderi.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/df.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/df_jk.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/grad/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/grad/rhf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/grad/rks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/hessian/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/hessian/rhf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/hessian/rks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/hessian/uhf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/hessian/uks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/int3c2e.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/df/patch_pyscf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/gen_grid.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/gks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/libxc.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/libxc_structs.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/numint.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/patch_pyscf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/radi.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/rks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/roks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/uks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/xc_alias.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/dft/xc_deriv.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/fci/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/fci/direct_spin1.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/grad/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/grad/dispersion.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/grad/patch_pyscf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/grad/rhf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/grad/rks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/grad/uhf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/grad/uks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/gto/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/gto/mole.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/hessian/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/hessian/dispersion.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/hessian/rhf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/hessian/rks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/hessian/uhf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/hessian/uks.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/cublas.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/cupy_helper.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/cusolver.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/cutensor.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/dftd3.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/dftd4.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/diis.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/logger.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/lib/utils.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/patch_pyscf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/qmmm/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/qmmm/chelpg.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/cphf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/diis.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/dispersion.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/ghf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/hf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/int4c2e.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/patch_pyscf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/rohf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/scf/ucphf.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/_attach_solvent.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/grad/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf/solvent/hessian/__init__.py +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf.egg-info/SOURCES.txt +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf.egg-info/dependency_links.txt +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf.egg-info/requires.txt +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/gpu4pyscf.egg-info/top_level.txt +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/setup.cfg +0 -0
- {gpu4pyscf-0.7.2 → gpu4pyscf-0.7.3}/setup.py +0 -0
|
@@ -254,6 +254,9 @@ def get_jk(mf_grad, mol=None, dm0=None, hermi=0, with_j=True, with_k=True, omega
|
|
|
254
254
|
|
|
255
255
|
class Gradients(uhf_grad.Gradients):
|
|
256
256
|
'''Unrestricted density-fitting Hartree-Fock gradients'''
|
|
257
|
+
|
|
258
|
+
_keys = {'with_df', 'auxbasis_response'}
|
|
259
|
+
|
|
257
260
|
def __init__(self, mf):
|
|
258
261
|
# Whether to include the response of DF auxiliary basis when computing
|
|
259
262
|
# nuclear gradients of J/K matrices
|
|
@@ -262,7 +265,7 @@ class Gradients(uhf_grad.Gradients):
|
|
|
262
265
|
uhf_grad.Gradients.__init__(self, mf)
|
|
263
266
|
|
|
264
267
|
get_jk = get_jk
|
|
265
|
-
|
|
268
|
+
|
|
266
269
|
# TODO: finish these two functions
|
|
267
270
|
def get_j(self, mol=None, dm=None, hermi=0, mo_coeff=None, mo_occ=None, dm2 = None):
|
|
268
271
|
vj, _, vjaux, _ = self.get_jk(mol, dm, with_k=False, mo_coeff=mo_coeff, mo_occ=mo_occ, dm2=dm2)
|
|
@@ -271,7 +274,7 @@ class Gradients(uhf_grad.Gradients):
|
|
|
271
274
|
def get_k(self, mol=None, dm=None, hermi=0, mo_coeff=None, mo_occ=None, dm2 = None):
|
|
272
275
|
_, vk, _, vkaux = self.get_jk(mol, dm, with_j=False, mo_coeff=mo_coeff, mo_occ=mo_occ, dm2=dm2)
|
|
273
276
|
return vk, vkaux
|
|
274
|
-
|
|
277
|
+
|
|
275
278
|
|
|
276
279
|
def get_veff(self, mol=None, dm=None):
|
|
277
280
|
vj0, vk0, vjaux0, vkaux0 = self.get_jk(mol, dm[0], mo_coeff=self.base.mo_coeff[0], mo_occ=self.base.mo_occ[0])
|
|
@@ -100,7 +100,7 @@ def get_veff(ks_grad, mol=None, dm=None):
|
|
|
100
100
|
vxc += vj0 + vj1 + vj0_m1 + vj1_m0
|
|
101
101
|
else:
|
|
102
102
|
omega, alpha, hyb = ni.rsh_and_hybrid_coeff(mf.xc, spin=mol.spin)
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
vj0, vk0, vjaux0, vkaux0 = ks_grad.get_jk(mol, dm[0], mo_coeff=ks_grad.base.mo_coeff[0], mo_occ=ks_grad.base.mo_occ[0])
|
|
105
105
|
vj1, vk1, vjaux1, vkaux1 = ks_grad.get_jk(mol, dm[1], mo_coeff=ks_grad.base.mo_coeff[1], mo_occ=ks_grad.base.mo_occ[1])
|
|
106
106
|
vj0_m1, vjaux0_m1 = ks_grad.get_j(mol, dm[0], mo_coeff=ks_grad.base.mo_coeff[0], mo_occ=ks_grad.base.mo_occ[0], dm2=dm[1])
|
|
@@ -110,29 +110,32 @@ def get_veff(ks_grad, mol=None, dm=None):
|
|
|
110
110
|
if ks_grad.auxbasis_response:
|
|
111
111
|
vj_aux = vjaux0 + vjaux1 + vjaux0_m1 + vjaux1_m0
|
|
112
112
|
vk_aux = (vkaux0+vkaux1) * hyb
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
if omega != 0:
|
|
115
115
|
vk_lr0, vkaux_lr0 = ks_grad.get_k(mol, dm[0], mo_coeff=ks_grad.base.mo_coeff[0], mo_occ=ks_grad.base.mo_occ[0], omega=omega)
|
|
116
|
-
vk_lr1, vkaux_lr1 = ks_grad.get_k(mol, dm[1], mo_coeff=ks_grad.base.mo_coeff[1], mo_occ=ks_grad.base.mo_occ[1], omega=omega)
|
|
116
|
+
vk_lr1, vkaux_lr1 = ks_grad.get_k(mol, dm[1], mo_coeff=ks_grad.base.mo_coeff[1], mo_occ=ks_grad.base.mo_occ[1], omega=omega)
|
|
117
117
|
vk += (vk_lr0 + vk_lr1) * (alpha-hyb)
|
|
118
118
|
if ks_grad.auxbasis_response:
|
|
119
119
|
vk_aux += (vkaux_lr0 + vkaux_lr1) * (alpha-hyb)
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
vxc += vj - vk
|
|
122
122
|
if ks_grad.auxbasis_response:
|
|
123
123
|
e1_aux = vj_aux - vk_aux
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
if ks_grad.auxbasis_response:
|
|
126
126
|
logger.debug1(ks_grad, 'sum(auxbasis response) %s', e1_aux.sum(axis=0))
|
|
127
127
|
else:
|
|
128
|
-
e1_aux = None
|
|
129
|
-
|
|
128
|
+
e1_aux = None
|
|
129
|
+
|
|
130
130
|
vxc = tag_array(vxc, aux=e1_aux)
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
return vxc
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
class Gradients(uks_grad.Gradients):
|
|
136
|
+
|
|
137
|
+
_keys = {'with_df', 'auxbasis_response'}
|
|
138
|
+
|
|
136
139
|
def __init__(self, mf):
|
|
137
140
|
# Whether to include the response of DF auxiliary basis when computing
|
|
138
141
|
# nuclear gradients of J/K matrices
|
|
@@ -140,7 +143,7 @@ class Gradients(uks_grad.Gradients):
|
|
|
140
143
|
uks_grad.Gradients.__init__(self, mf)
|
|
141
144
|
|
|
142
145
|
get_jk = get_jk
|
|
143
|
-
|
|
146
|
+
|
|
144
147
|
def get_j(self, mol=None, dm=None, hermi=0, mo_coeff=None, mo_occ=None, dm2 = None, omega=None):
|
|
145
148
|
vj, _, vjaux, _ = self.get_jk(mol, dm, with_k=False, mo_coeff=mo_coeff, mo_occ=mo_occ, dm2=dm2, omega=omega)
|
|
146
149
|
return vj, vjaux
|
|
@@ -148,7 +151,7 @@ class Gradients(uks_grad.Gradients):
|
|
|
148
151
|
def get_k(self, mol=None, dm=None, hermi=0, mo_coeff=None, mo_occ=None, dm2 = None, omega=None):
|
|
149
152
|
_, vk, _, vkaux = self.get_jk(mol, dm, with_j=False, mo_coeff=mo_coeff, mo_occ=mo_occ, dm2=dm2, omega=omega)
|
|
150
153
|
return vk, vkaux
|
|
151
|
-
|
|
154
|
+
|
|
152
155
|
get_veff = get_veff
|
|
153
156
|
|
|
154
157
|
def extra_force(self, atom_id, envs):
|
|
@@ -113,7 +113,7 @@ def get_fock(mf, h1e=None, s1e=None, vhf=None, dm=None, cycle=-1, diis=None,
|
|
|
113
113
|
class UHF(uhf.UHF):
|
|
114
114
|
from gpu4pyscf.lib.utils import to_cpu, to_gpu, device
|
|
115
115
|
|
|
116
|
-
_keys = {'e_disp', 'screen_tol', 'conv_tol_cpscf'}
|
|
116
|
+
_keys = {'e_disp', 'screen_tol', 'conv_tol_cpscf', 'h1e', 's1e'}
|
|
117
117
|
|
|
118
118
|
screen_tol = 1e-14
|
|
119
119
|
conv_tol_cpscf = 1e-3
|
|
@@ -344,7 +344,8 @@ class WithSolventGrad:
|
|
|
344
344
|
dm = kwargs.pop('dm', None)
|
|
345
345
|
if dm is None:
|
|
346
346
|
dm = self.base.make_rdm1(ao_repr=True)
|
|
347
|
-
|
|
347
|
+
if dm.ndim == 3:
|
|
348
|
+
dm = dm[0] + dm[1]
|
|
348
349
|
self.de_solute = super().kernel(*args, **kwargs)
|
|
349
350
|
self.de_solvent = grad_qv(self.base.with_solvent, dm)
|
|
350
351
|
self.de_solvent+= grad_solver(self.base.with_solvent, dm)
|
|
@@ -255,14 +255,15 @@ class WithSolventGrad:
|
|
|
255
255
|
dm = kwargs.pop('dm', None)
|
|
256
256
|
if dm is None:
|
|
257
257
|
dm = self.base.make_rdm1(ao_repr=True)
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
if dm.ndim == 3:
|
|
259
|
+
dm = dm[0] + dm[1]
|
|
260
|
+
self.de_solute = super().kernel(*args, **kwargs)
|
|
260
261
|
self.de_solvent = pcm_grad.grad_qv(self.base.with_solvent, dm)
|
|
261
262
|
self.de_solvent+= pcm_grad.grad_solver(self.base.with_solvent, dm)
|
|
262
263
|
self.de_solvent+= pcm_grad.grad_nuc(self.base.with_solvent, dm)
|
|
264
|
+
self.de_cds = get_cds(self.base.with_solvent)
|
|
265
|
+
self.de = self.de_solute + self.de_solvent + self.de_cds
|
|
263
266
|
|
|
264
|
-
self.de = self.de_solute + self.de_solvent
|
|
265
|
-
self.de += get_cds(self.base.with_solvent)
|
|
266
267
|
if self.verbose >= logger.NOTE:
|
|
267
268
|
logger.note(self, '--------------- %s (+%s) gradients ---------------',
|
|
268
269
|
self.base.__class__.__name__,
|
|
@@ -21,8 +21,7 @@ Gradient of PCM family solvent model
|
|
|
21
21
|
import numpy
|
|
22
22
|
import cupy
|
|
23
23
|
from cupyx import scipy
|
|
24
|
-
from pyscf import lib
|
|
25
|
-
from pyscf import gto, df
|
|
24
|
+
from pyscf import lib, scf, gto, df
|
|
26
25
|
from pyscf.grad import rhf as rhf_grad
|
|
27
26
|
from gpu4pyscf.solvent.pcm import PI, switch_h
|
|
28
27
|
from gpu4pyscf.solvent.grad.pcm import grad_switch_h, get_dF_dA, get_dD_dS, grad_qv, grad_solver, grad_nuc
|
|
@@ -155,7 +154,7 @@ def hess_elec(pcmobj, dm, verbose=None):
|
|
|
155
154
|
pcmobj.reset(pmol)
|
|
156
155
|
return de
|
|
157
156
|
|
|
158
|
-
def fd_grad_vmat(pcmobj, mo_coeff, mo_occ, atmlst=None, verbose=None):
|
|
157
|
+
def fd_grad_vmat(pcmobj, dm, mo_coeff, mo_occ, atmlst=None, verbose=None):
|
|
159
158
|
'''
|
|
160
159
|
dv_solv / da
|
|
161
160
|
slow version with finite difference
|
|
@@ -169,7 +168,6 @@ def fd_grad_vmat(pcmobj, mo_coeff, mo_occ, atmlst=None, verbose=None):
|
|
|
169
168
|
nao, nmo = mo_coeff.shape
|
|
170
169
|
mocc = mo_coeff[:,mo_occ>0]
|
|
171
170
|
nocc = mocc.shape[1]
|
|
172
|
-
dm = cupy.dot(mocc, mocc.T) * 2
|
|
173
171
|
coords = mol.atom_coords(unit='Bohr')
|
|
174
172
|
def pcm_vmat_scanner(mol):
|
|
175
173
|
pcmobj.reset(mol)
|
|
@@ -250,6 +248,8 @@ class WithSolventHess:
|
|
|
250
248
|
dm = kwargs.pop('dm', None)
|
|
251
249
|
if dm is None:
|
|
252
250
|
dm = self.base.make_rdm1(ao_repr=True)
|
|
251
|
+
if dm.ndim == 3:
|
|
252
|
+
dm = dm[0] + dm[1]
|
|
253
253
|
is_equilibrium = self.base.with_solvent.equilibrium_solvation
|
|
254
254
|
self.base.with_solvent.equilibrium_solvation = True
|
|
255
255
|
self.de_solvent = hess_elec(self.base.with_solvent, dm, verbose=self.verbose)
|
|
@@ -263,11 +263,25 @@ class WithSolventHess:
|
|
|
263
263
|
if atmlst is None:
|
|
264
264
|
atmlst = range(self.mol.natm)
|
|
265
265
|
h1ao = super().make_h1(mo_coeff, mo_occ, atmlst=atmlst, verbose=verbose)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
266
|
+
if isinstance(self.base, scf.hf.RHF):
|
|
267
|
+
dm = self.base.make_rdm1(ao_repr=True)
|
|
268
|
+
dv = fd_grad_vmat(self.base.with_solvent, dm, mo_coeff, mo_occ, atmlst=atmlst, verbose=verbose)
|
|
269
|
+
for i0, ia in enumerate(atmlst):
|
|
270
|
+
h1ao[i0] += dv[i0]
|
|
271
|
+
return h1ao
|
|
272
|
+
elif isinstance(self.base, scf.uhf.UHF):
|
|
273
|
+
h1aoa, h1aob = h1ao
|
|
274
|
+
solvent = self.base.with_solvent
|
|
275
|
+
dm = self.base.make_rdm1(ao_repr=True)
|
|
276
|
+
dm = dm[0] + dm[1]
|
|
277
|
+
dva = fd_grad_vmat(solvent, dm, mo_coeff[0], mo_occ[0], atmlst=atmlst, verbose=verbose)
|
|
278
|
+
dvb = fd_grad_vmat(solvent, dm, mo_coeff[1], mo_occ[1], atmlst=atmlst, verbose=verbose)
|
|
279
|
+
for i0, ia in enumerate(atmlst):
|
|
280
|
+
h1aoa[i0] += dva[i0]
|
|
281
|
+
h1aob[i0] += dvb[i0]
|
|
282
|
+
return h1aoa, h1aob
|
|
283
|
+
else:
|
|
284
|
+
raise NotImplementedError('Base object is not supported')
|
|
271
285
|
def _finalize(self):
|
|
272
286
|
# disable _finalize. It is called in grad_method.kernel method
|
|
273
287
|
# where self.de was not yet initialized.
|
|
@@ -20,9 +20,7 @@ Gradient of PCM family solvent model
|
|
|
20
20
|
|
|
21
21
|
import numpy as np
|
|
22
22
|
import cupy
|
|
23
|
-
|
|
24
|
-
from pyscf import lib
|
|
25
|
-
from pyscf import gto, df
|
|
23
|
+
from pyscf import gto, df, scf, lib
|
|
26
24
|
from pyscf.grad import rhf as rhf_grad
|
|
27
25
|
from pyscf.data import radii
|
|
28
26
|
from pyscf.solvent import ddcosmo_grad
|
|
@@ -278,13 +276,15 @@ class WithSolventHess:
|
|
|
278
276
|
dm = kwargs.pop('dm', None)
|
|
279
277
|
if dm is None:
|
|
280
278
|
dm = self.base.make_rdm1(ao_repr=True)
|
|
279
|
+
if dm.ndim == 3:
|
|
280
|
+
dm = dm[0] + dm[1]
|
|
281
281
|
is_equilibrium = self.base.with_solvent.equilibrium_solvation
|
|
282
282
|
self.base.with_solvent.equilibrium_solvation = True
|
|
283
283
|
self.de_solvent = pcm_hess.hess_elec(self.base.with_solvent, dm, verbose=self.verbose)
|
|
284
284
|
#self.de_solvent+= hess_nuc(self.base.with_solvent)
|
|
285
285
|
self.de_solute = super().kernel(*args, **kwargs)
|
|
286
|
-
self.
|
|
287
|
-
self.de
|
|
286
|
+
self.de_cds = get_cds(self.base.with_solvent)
|
|
287
|
+
self.de = self.de_solute + self.de_solvent + self.de_cds
|
|
288
288
|
self.base.with_solvent.equilibrium_solvation = is_equilibrium
|
|
289
289
|
return self.de
|
|
290
290
|
|
|
@@ -292,11 +292,25 @@ class WithSolventHess:
|
|
|
292
292
|
if atmlst is None:
|
|
293
293
|
atmlst = range(self.mol.natm)
|
|
294
294
|
h1ao = super().make_h1(mo_coeff, mo_occ, atmlst=atmlst, verbose=verbose)
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
if isinstance(self.base, scf.hf.RHF):
|
|
296
|
+
dm = self.base.make_rdm1(ao_repr=True)
|
|
297
|
+
dv = pcm_hess.fd_grad_vmat(self.base.with_solvent, dm, mo_coeff, mo_occ, atmlst=atmlst, verbose=verbose)
|
|
298
|
+
for i0, ia in enumerate(atmlst):
|
|
299
|
+
h1ao[i0] += dv[i0]
|
|
300
|
+
return h1ao
|
|
301
|
+
elif isinstance(self.base, scf.uhf.UHF):
|
|
302
|
+
h1aoa, h1aob = h1ao
|
|
303
|
+
solvent = self.base.with_solvent
|
|
304
|
+
dm = self.base.make_rdm1(ao_repr=True)
|
|
305
|
+
dm = dm[0] + dm[1]
|
|
306
|
+
dva = pcm_hess.fd_grad_vmat(solvent, dm, mo_coeff[0], mo_occ[0], atmlst=atmlst, verbose=verbose)
|
|
307
|
+
dvb = pcm_hess.fd_grad_vmat(solvent, dm, mo_coeff[1], mo_occ[1], atmlst=atmlst, verbose=verbose)
|
|
308
|
+
for i0, ia in enumerate(atmlst):
|
|
309
|
+
h1aoa[i0] += dva[i0]
|
|
310
|
+
h1aob[i0] += dvb[i0]
|
|
311
|
+
return h1aoa, h1aob
|
|
312
|
+
else:
|
|
313
|
+
raise NotImplementedError('Base object is not supported')
|
|
300
314
|
def _finalize(self):
|
|
301
315
|
# disable _finalize. It is called in grad_method.kernel method
|
|
302
316
|
# where self.de was not yet initialized.
|
|
@@ -310,7 +310,6 @@ class PCM(ddcosmo.DDCOSMO):
|
|
|
310
310
|
def _get_vind(self, dms):
|
|
311
311
|
if not self._intermediates:
|
|
312
312
|
self.build()
|
|
313
|
-
|
|
314
313
|
nao = dms.shape[-1]
|
|
315
314
|
dms = dms.reshape(-1,nao,nao)
|
|
316
315
|
if dms.shape[0] == 2:
|
|
@@ -335,7 +334,6 @@ class PCM(ddcosmo.DDCOSMO):
|
|
|
335
334
|
self._intermediates['q'] = q[0]
|
|
336
335
|
self._intermediates['q_sym'] = q_sym[0]
|
|
337
336
|
self._intermediates['v_grids'] = v_grids[0]
|
|
338
|
-
|
|
339
337
|
return epcm, vmat[0]
|
|
340
338
|
|
|
341
339
|
def _get_v(self, dms):
|
|
@@ -363,7 +361,7 @@ class PCM(ddcosmo.DDCOSMO):
|
|
|
363
361
|
if self.frozen:
|
|
364
362
|
raise RuntimeError('Frozen solvent model is not supported')
|
|
365
363
|
from gpu4pyscf import scf
|
|
366
|
-
if isinstance(grad_method.base, scf.hf.RHF):
|
|
364
|
+
if isinstance(grad_method.base, (scf.hf.RHF, scf.uhf.UHF)):
|
|
367
365
|
return pcm_grad.make_grad_object(grad_method)
|
|
368
366
|
else:
|
|
369
367
|
raise RuntimeError('Only SCF gradient is supported')
|
|
@@ -373,7 +371,7 @@ class PCM(ddcosmo.DDCOSMO):
|
|
|
373
371
|
if self.frozen:
|
|
374
372
|
raise RuntimeError('Frozen solvent model is not supported')
|
|
375
373
|
from gpu4pyscf import scf
|
|
376
|
-
if isinstance(hess_method.base, scf.hf.RHF):
|
|
374
|
+
if isinstance(hess_method.base, (scf.hf.RHF, scf.uhf.UHF)):
|
|
377
375
|
return pcm_hess.make_hess_object(hess_method)
|
|
378
376
|
else:
|
|
379
377
|
raise RuntimeError('Only SCF gradient is supported')
|
|
@@ -387,7 +385,7 @@ class PCM(ddcosmo.DDCOSMO):
|
|
|
387
385
|
def _B_dot_x(self, dms):
|
|
388
386
|
if not self._intermediates:
|
|
389
387
|
self.build()
|
|
390
|
-
|
|
388
|
+
out_shape = dms.shape
|
|
391
389
|
nao = dms.shape[-1]
|
|
392
390
|
dms = dms.reshape(-1,nao,nao)
|
|
393
391
|
|
|
@@ -403,6 +401,5 @@ class PCM(ddcosmo.DDCOSMO):
|
|
|
403
401
|
q_sym = (q + qt)/2.0
|
|
404
402
|
|
|
405
403
|
vmat = self._get_vmat(q_sym)
|
|
406
|
-
|
|
407
|
-
return vmat
|
|
404
|
+
return vmat.reshape(out_shape)
|
|
408
405
|
|
|
@@ -572,7 +572,7 @@ class SMD(pcm.PCM):
|
|
|
572
572
|
if self.frozen:
|
|
573
573
|
raise RuntimeError('Frozen solvent model is not supported')
|
|
574
574
|
from gpu4pyscf import scf
|
|
575
|
-
if isinstance(grad_method.base, scf.hf.RHF):
|
|
575
|
+
if isinstance(grad_method.base, (scf.hf.RHF, scf.uhf.UHF)):
|
|
576
576
|
return smd_grad.make_grad_object(grad_method)
|
|
577
577
|
else:
|
|
578
578
|
raise RuntimeError('Only SCF gradient is supported')
|
|
@@ -582,7 +582,7 @@ class SMD(pcm.PCM):
|
|
|
582
582
|
if self.frozen:
|
|
583
583
|
raise RuntimeError('Frozen solvent model is not supported')
|
|
584
584
|
from gpu4pyscf import scf
|
|
585
|
-
if isinstance(hess_method.base, scf.hf.RHF):
|
|
585
|
+
if isinstance(hess_method.base, (scf.hf.RHF, scf.uhf.UHF)):
|
|
586
586
|
return smd_hess.make_hess_object(hess_method)
|
|
587
587
|
else:
|
|
588
588
|
raise RuntimeError('Only SCF gradient is supported')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|