Skip to content

Commit

Permalink
Bugfix v0.6.9 (#63)
Browse files Browse the repository at this point in the history
* save

* implement SMD solvent model

* updated readme

* fixed issues after v0.6.9

* format examples

* output = /dev/null in test_smd.py
  • Loading branch information
wxj6000 authored Dec 12, 2023
1 parent c818905 commit 94c26ff
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 30 deletions.
8 changes: 4 additions & 4 deletions examples/00-h2o.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
from gpu4pyscf.dft import rks
lib.num_threads(8)

atom ='''
atom = '''
O 0.0000000000 -0.0000000000 0.1174000000
H -0.7570000000 -0.0000000000 -0.4696000000
H 0.7570000000 0.0000000000 -0.4696000000
'''

xc='B3LYP'
bas='def2-tzvpp'
auxbasis='def2-tzvpp-jkfit'
xc = 'B3LYP'
bas = 'def2-tzvpp'
auxbasis = 'def2-tzvpp-jkfit'
scf_tol = 1e-10
max_scf_cycles = 50
screen_tol = 1e-14
Expand Down
6 changes: 3 additions & 3 deletions examples/01-h2o_dftd3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
H 0.7570000000 0.0000000000 -0.4696000000
'''

xc='B3LYP'
bas='def2-tzvpp'
auxbasis='def2-tzvpp-jkfit'
xc = 'B3LYP'
bas = 'def2-tzvpp'
auxbasis = 'def2-tzvpp-jkfit'
scf_tol = 1e-10
max_scf_cycles = 50
screen_tol = 1e-14
Expand Down
10 changes: 5 additions & 5 deletions examples/02-h2o_geomopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import time
import pyscf
from pyscf import lib
from pyscf.geomopt.geometric_solver import optimize
from gpu4pyscf.dft import rks

lib.num_threads(8)

atom ='''
atom = '''
O 0.0000000000 -0.0000000000 0.1174000000
H -0.7570000000 -0.0000000000 -0.4696000000
H 0.7570000000 0.0000000000 -0.4696000000
'''

xc='B3LYP'
bas='def2-tzvpp'
auxbasis='def2-tzvpp-jkfit'
xc = 'B3LYP'
bas = 'def2-tzvpp'
auxbasis = 'def2-tzvpp-jkfit'
scf_tol = 1e-10
max_scf_cycles = 50
screen_tol = 1e-14
Expand All @@ -46,7 +47,6 @@
def callback(envs):
gradients.append(envs['gradients'])

import time
start_time = time.time()
mol_eq = optimize(mf_GPU, maxsteps=20, callback=callback)
print("Optimized coordinate:")
Expand Down
4 changes: 2 additions & 2 deletions examples/03-h2o_dzvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
H 0.7570000000 0.0000000000 -0.4696000000
'''

xc='B3LYP'
bas='dzvp'
xc = 'B3LYP'
bas = 'dzvp'
scf_tol = 1e-10
max_scf_cycles = 50
screen_tol = 1e-1
Expand Down
10 changes: 7 additions & 3 deletions examples/05-h2o_multipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import pyscf
from gpu4pyscf.dft import rks

atom ='''
atom ='''
O 0.0000000000 -0.0000000000 0.1174000000
H -0.7570000000 -0.0000000000 -0.4696000000
H 0.7570000000 0.0000000000 -0.4696000000
Expand All @@ -26,8 +26,12 @@
mol.verbose = 1
mf = rks.RKS(mol, xc='B3LYP').density_fit(auxbasis='def2-tzvpp-jkfit')
mf.kernel()
dm = mf.make_rdm1()

dip = mf.dip_moment(unit='DEBYE')
dip = mf.dip_moment(unit='DEBYE', dm=dm.get())
print('dipole moment:')
print(dip)
quad = mf.quad_moment(unit='DEBYE-ANG')

quad = mf.quad_moment(unit='DEBYE-ANG', dm=dm.get())
print('quadrupole moment:')
print(quad)
6 changes: 3 additions & 3 deletions examples/07-transition_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
H 1.06461 2.50818 -0.45885'''


xc='B3LYP'
bas='def2-tzvpp'
auxbasis='def2-tzvpp-jkfit'
xc = 'B3LYP'
bas = 'def2-tzvpp'
auxbasis = 'def2-tzvpp-jkfit'
scf_tol = 1e-10
max_scf_cycles = 50
screen_tol = 1e-14
Expand Down
6 changes: 3 additions & 3 deletions examples/09-mbis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
H 0.7570000000 0.0000000000 -0.4696000000
'''

xc='B3LYP'
bas='def2-tzvpp'
auxbasis='def2-tzvpp-jkfit'
xc = 'B3LYP'
bas = 'def2-tzvpp'
auxbasis = 'def2-tzvpp-jkfit'
scf_tol = 1e-10
max_scf_cycles = 50
screen_tol = 1e-14
Expand Down
5 changes: 2 additions & 3 deletions examples/10-ecp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
from gpu4pyscf.dft import rks

atom = '''
I 0 0 0
I 0 0 0
I 1 0 0
'''
bas='def2-qzvpp'
bas = 'def2-qzvpp'
grids_level = 6

mol = pyscf.M(atom=atom, basis=bas, ecp=bas)
mol.verbose = 1

mf = rks.RKS(mol, xc='b3lyp')
mf.grids.level = grids_level
mf.device = 'gpu'
e_dft = mf.kernel()
2 changes: 1 addition & 1 deletion examples/11-nlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from gpu4pyscf.dft import rks
lib.num_threads(8)

atom ='''
atom ='''
O 0.0000000000 -0.0000000000 0.1174000000
H -0.7570000000 -0.0000000000 -0.4696000000
H 0.7570000000 0.0000000000 -0.4696000000
Expand Down
1 change: 1 addition & 0 deletions examples/15-chelpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
mf.grids.level = 5
mf.kernel()
q = chelpg.eval_chelpg_layer_gpu(mf)
print('partial charge with CHELPG')
print(q) # [ 0.04402311 0.11333945 -0.25767919 0.10031663]
2 changes: 1 addition & 1 deletion examples/16-smd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
mf.with_solvent.method = 'SMD'
mf.with_solvent.solvent = 'water'
e_tot = mf.kernel()
print(e_tot)
print('total energy with SMD:', e_tot)
57 changes: 57 additions & 0 deletions examples/17-to_gpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2023 The GPU4PySCF Authors. All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import pyscf
from pyscf import lib
from pyscf.dft import rks
lib.num_threads(8)

atom = '''
O 0.0000000000 -0.0000000000 0.1174000000
H -0.7570000000 -0.0000000000 -0.4696000000
H 0.7570000000 0.0000000000 -0.4696000000
'''

xc = 'B3LYP'
bas = 'sto3g'
scf_tol = 1e-10
max_scf_cycles = 50
screen_tol = 1e-14
grids_level = 3

mol = pyscf.M(atom=atom, basis=bas, max_memory=32000, output='./pyscf.log')

mol.verbose = 4
mf = rks.RKS(mol, xc=xc).density_fit()
mf_GPU = mf.to_gpu()
mf_GPU.grids.level = grids_level
mf_GPU.conv_tol = scf_tol
mf_GPU.max_cycle = max_scf_cycles
mf_GPU.screen_tol = screen_tol

# Compute Energy
e_dft = mf_GPU.kernel()
print(f"total energy = {e_dft}")

# Compute Gradient
g = mf_GPU.nuc_grad_method()
g.max_memory = 20000
g.auxbasis_response = True
g_dft = g.kernel()

# Compute Hessian
h = mf_GPU.Hessian()
h.auxbasis_response = 2
h_dft = h.kernel()
2 changes: 2 additions & 0 deletions gpu4pyscf/df/df_jk.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class _DFHF(df_jk._DFHF):

from gpu4pyscf.lib.utils import to_cpu, to_gpu, device

_keys = {'rhoj', 'rhok', 'disp', 'screen_tol'}

def __init__(self, mf, dfobj, only_dfj):
self.__dict__.update(mf.__dict__)
self._eri = None
Expand Down
2 changes: 1 addition & 1 deletion gpu4pyscf/df/int3c2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ def sort_mol(mol0, cart=True):
# Sort basis according to angular momentum and contraction patterns so
# as to group the basis functions to blocks in GPU kernel.
'''
mol = copy.copy(mol0)
mol = mol0.copy(deep=True)
l_ctrs = mol._bas[:,[gto.ANG_OF, gto.NPRIM_OF]]

uniq_l_ctr, _, inv_idx, l_ctr_counts = np.unique(
Expand Down
2 changes: 1 addition & 1 deletion gpu4pyscf/solvent/tests/test_smd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUpModule():
H 0.7570000000 0.0000000000 -0.4696000000
'''
mol.basis = 'def2-tzvpp'
#mol.output = '/dev/null'
mol.output = '/dev/null'
mol.build()
lebedev_order = 29

Expand Down

0 comments on commit 94c26ff

Please sign in to comment.