Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix in NMR shielding with LDA #256

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Features
- PCM models, SMD model, their analytical gradients, and semi-analytical Hessian matrix;
- Unrestricted Hartree-Fock and Unrestricted DFT, gradient, and Hessian;
- MP2/DF-MP2 and CCSD (experimental);
- Polarizability, IR, and NMR shielding
- QM/MM with PBC
- Polarizability, IR, and NMR shielding (experimental);
- QM/MM with PBC;
- CHELPG, ESP, and RESP atomic charge

Limitations
Expand Down
2 changes: 1 addition & 1 deletion gpu4pyscf/properties/shielding.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def nr_rks(ni, mol, grids, xc_code, dms):
giao = cupy.array(giao)
giao_aux = giao[:,:,index]
for idirect in range(3):
vtmp = contract('pu,p,vp->uv', giao_aux[idirect], wv, ao)
vtmp = contract('pu,vp->uv', giao_aux[idirect], wv*ao)
vtmp = cupy.ascontiguousarray(vtmp)
add_sparse(vmat[idirect], vtmp, index)

Expand Down
21 changes: 19 additions & 2 deletions gpu4pyscf/properties/tests/test_shielding.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ class KnownValues(unittest.TestCase):
Atom H 3 31.39160966 19.36647972

'''
def test_rks_lda(self):
print('-------- RKS LDA -------------')
e_tot, tensor = run_dft_nmr_shielding('LDA,vwn5')
nmr_total = tensor[0].get()+tensor[1].get()
isotropic_pyscf = np.array([nmr_total[0].trace()/3, nmr_total[1].trace()/3, nmr_total[2].trace()/3])
isotropic_qchem = np.array([338.70405899, 31.07348461, 31.07259871])
assert np.allclose(e_tot, -75.90464078)
assert np.allclose(isotropic_pyscf, isotropic_qchem, rtol=1.0E-4)

def test_rks_b3lyp(self):
print('-------- RKS B3LYP -------------')
e_tot, tensor = run_dft_nmr_shielding('B3LYP')
Expand All @@ -123,6 +132,15 @@ def test_rks_b3lyp(self):
assert np.allclose(e_tot, -76.4666494276)
assert np.allclose(isotropic_pyscf, isotropic_qchem, rtol=1.0E-4)

def test_rks_lda_df(self):
print('-------- RKS density fitting LDA -------------')
e_tot, tensor = run_dft_df_nmr_shielding('LDA,vwn5')
nmr_total = tensor[0].get()+tensor[1].get()
isotropic_pyscf = np.array([nmr_total[0].trace()/3, nmr_total[1].trace()/3, nmr_total[2].trace()/3])
isotropic_qchem = np.array([338.71137749, 31.07428641, 31.07339795])
assert np.allclose(e_tot, -75.90467665)
assert np.allclose(isotropic_pyscf, isotropic_qchem, rtol=1.0E-4)

def test_rks_b3lyp_df(self):
print('-------- RKS density fitting B3LYP -------------')
e_tot, tensor = run_dft_df_nmr_shielding('B3LYP')
Expand All @@ -132,7 +150,6 @@ def test_rks_b3lyp_df(self):
assert np.allclose(e_tot, -76.4666819553)
assert np.allclose(isotropic_pyscf, isotropic_qchem, rtol=1.0E-4)


if __name__ == "__main__":
print("Full Tests for nmr shielding constants")
print("Full Tests for NMR Shielding Constants")
unittest.main()
Loading