Skip to content

Commit

Permalink
Add examples for DFT+U
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Sep 9, 2024
1 parent 3dc4547 commit dfcbed2
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 116 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ PySCF 1.7.6 (2021-03-28)
- Auxiliary second-order Green's function perturbation theory (AGF2)
- Smearing for molecules
- Visscher small component correction approximation for DHF
- DFT+U
* Improved
- Threading safety in Mole temporary context
- Basis parser to support arithmetic expressions in basis data
Expand Down
40 changes: 40 additions & 0 deletions examples/pbc/22-dft+u.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python

'''
DFT+U with kpoint sampling
'''

from pyscf.pbc import gto, dft
cell = gto.Cell()
cell.unit = 'A'
cell.atom = 'C 0., 0., 0.; C 0.8917, 0.8917, 0.8917'
cell.a = '''0. 1.7834 1.7834
1.7834 0. 1.7834
1.7834 1.7834 0. '''

cell.basis = 'gth-dzvp'
cell.pseudo = 'gth-pade'
cell.verbose = 4
cell.build()

kmesh = [2, 2, 2]
kpts = cell.make_kpts(kmesh)
# Add U term to the 2p orbital of the second Carbon atom
U_idx = ['1 C 2p']
U_val = [5.0]
mf = dft.KRKSpU(cell, kpts, U_idx=U_idx, U_val=U_val, minao_ref='gth-szv')
print(mf.U_idx)
print(mf.U_val)
mf.run()

# When space group symmetry in k-point samples is enabled, the symmetry adapted
# DFT+U method will be invoked automatically.
kpts = cell.make_kpts(
kmesh, wrap_around=True, space_group_symmetry=True, time_reversal_symmetry=True)
# Add U term to 2s and 2p orbitals
U_idx = ['2p', '2s']
U_val = [5.0, 2.0]
mf = dft.KUKSpU(cell, kpts, U_idx=U_idx, U_val=U_val, minao_ref='gth-szv')
print(mf.U_idx)
print(mf.U_val)
mf.run()
29 changes: 0 additions & 29 deletions pyscf/pbc/dft/krkspu.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,32 +280,3 @@ def __init__(self, cell, kpts=np.zeros((1,3)), xc='LDA,VWN',

def nuc_grad_method(self):
raise NotImplementedError

if __name__ == '__main__':
from pyscf.pbc import gto
np.set_printoptions(3, linewidth=1000, suppress=True)
cell = gto.Cell()
cell.unit = 'A'
cell.atom = 'C 0., 0., 0.; C 0.8917, 0.8917, 0.8917'
cell.a = '''0. 1.7834 1.7834
1.7834 0. 1.7834
1.7834 1.7834 0. '''

cell.basis = 'gth-dzvp'
cell.pseudo = 'gth-pade'
cell.verbose = 7
cell.build()
kmesh = [2, 2, 2]
kpts = cell.make_kpts(kmesh, wrap_around=True)
#U_idx = ["2p", "2s"]
#U_val = [5.0, 2.0]
U_idx = ["1 C 2p"]
U_val = [5.0]

mf = KRKSpU(cell, kpts, U_idx=U_idx, U_val=U_val, C_ao_lo='minao',
minao_ref='gth-szv')
mf.conv_tol = 1e-10
print (mf.U_idx)
print (mf.U_val)
print (mf.C_ao_lo.shape)
print (mf.kernel())
30 changes: 0 additions & 30 deletions pyscf/pbc/dft/krkspu_ksymm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,3 @@ def __init__(self, cell, kpts=libkpts.KPoints(), xc='LDA,VWN',
minao_ref=minao_ref, **kwargs)

KRKSpU = KsymAdaptedKRKSpU

if __name__ == '__main__':
from pyscf.pbc import gto
np.set_printoptions(3, linewidth=1000, suppress=True)
cell = gto.Cell()
cell.unit = 'A'
cell.atom = 'C 0., 0., 0.; C 0.8917, 0.8917, 0.8917'
cell.a = '''0. 1.7834 1.7834
1.7834 0. 1.7834
1.7834 1.7834 0. '''

cell.basis = 'gth-dzvp'
cell.pseudo = 'gth-pade'
cell.verbose = 7
cell.build()
kmesh = [2, 2, 2]
kpts = cell.make_kpts(kmesh, wrap_around=True,
space_group_symmetry=True, time_reversal_symmetry=True)
#U_idx = ["2p", "2s"]
#U_val = [5.0, 2.0]
U_idx = ["1 C 2p"]
U_val = [5.0]

mf = KRKSpU(cell, kpts, U_idx=U_idx, U_val=U_val, C_ao_lo='minao',
minao_ref='gth-szv')
mf.conv_tol = 1e-10
print (mf.U_idx)
print (mf.U_val)
print (mf.C_ao_lo.shape)
print (mf.kernel())
27 changes: 0 additions & 27 deletions pyscf/pbc/dft/kukspu.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,30 +172,3 @@ def __init__(self, cell, kpts=np.zeros((1,3)), xc='LDA,VWN',

def nuc_grad_method(self):
raise NotImplementedError

if __name__ == '__main__':
from pyscf.pbc import gto
cell = gto.Cell()
cell.unit = 'A'
cell.atom = 'C 0., 0., 0.; C 0.8917, 0.8917, 0.8917'
cell.a = '''0. 1.7834 1.7834
1.7834 0. 1.7834
1.7834 1.7834 0. '''

cell.basis = 'gth-dzvp'
cell.pseudo = 'gth-pade'
cell.verbose = 7
cell.build()
kmesh = [2, 2, 2]
kpts = cell.make_kpts(kmesh, wrap_around=True)
#U_idx = ["2p", "2s"]
#U_val = [5.0, 2.0]
U_idx = ["1 C 2p"]
U_val = [5.0]

mf = KUKSpU(cell, kpts, U_idx=U_idx, U_val=U_val, minao_ref='gth-szv')
mf.conv_tol = 1e-10
print (mf.U_idx)
print (mf.U_val)
print (mf.C_ao_lo.shape)
print (mf.kernel())
30 changes: 0 additions & 30 deletions pyscf/pbc/dft/kukspu_ksymm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,3 @@ def __init__(self, cell, kpts=libkpts.KPoints(), xc='LDA,VWN',
minao_ref=minao_ref, **kwargs)

KUKSpU = KsymAdaptedKUKSpU

if __name__ == '__main__':
from pyscf.pbc import gto
np.set_printoptions(3, linewidth=1000, suppress=True)
cell = gto.Cell()
cell.unit = 'A'
cell.atom = 'C 0., 0., 0.; C 0.8917, 0.8917, 0.8917'
cell.a = '''0. 1.7834 1.7834
1.7834 0. 1.7834
1.7834 1.7834 0. '''

cell.basis = 'gth-dzvp'
cell.pseudo = 'gth-pade'
cell.verbose = 7
cell.build()
kmesh = [2, 2, 2]
kpts = cell.make_kpts(kmesh, wrap_around=True,
space_group_symmetry=True, time_reversal_symmetry=True)
#U_idx = ["2p", "2s"]
#U_val = [5.0, 2.0]
U_idx = ["1 C 2p"]
U_val = [5.0]

mf = KUKSpU(cell, kpts, U_idx=U_idx, U_val=U_val, C_ao_lo='minao',
minao_ref='gth-szv')
mf.conv_tol = 1e-10
print (mf.U_idx)
print (mf.U_val)
print (mf.C_ao_lo.shape)
print (mf.kernel())

0 comments on commit dfcbed2

Please sign in to comment.