forked from pyscf/pyscf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
284 changed files
with
38,202 additions
and
16,630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env python | ||
|
||
''' | ||
Mean field with k-points sampling when Brillouin Zone symmetry is considered | ||
''' | ||
|
||
import numpy | ||
from pyscf.pbc import gto, scf, dft | ||
|
||
cell = gto.M( | ||
a = numpy.asarray([[0.0, 2.6935121974, 2.6935121974], | ||
[2.6935121974, 0.0, 2.6935121974], | ||
[2.6935121974, 2.6935121974, 0.0]]), | ||
atom = '''Si 0.0000000000 0.0000000000 0.0000000000 | ||
Si 1.3467560987 1.3467560987 1.3467560987''', | ||
basis = 'gth-szv', | ||
pseudo = 'gth-pade', | ||
mesh = [24,24,24], | ||
verbose = 5, | ||
) | ||
|
||
nk = [2,2,2] | ||
#The Brillouin Zone symmetry info is contained in the kpts object | ||
#symmorphic: if True, only the symmorphic subgroup is considered | ||
kpts = cell.make_kpts(nk, | ||
space_group_symmetry=True, | ||
time_reversal_symmetry=True, | ||
symmorphic=True) | ||
print(kpts) | ||
|
||
kmf = scf.KRHF(cell, kpts) | ||
kmf.kernel() | ||
|
||
kmf = dft.KRKS(cell, kpts) | ||
kmf.xc = 'camb3lyp' | ||
kmf.kernel() | ||
|
||
# | ||
# The mean-field object with k-point symmetry can be converted back to | ||
# the correponding non-symmetric mean-field object | ||
# | ||
|
||
kmf = kmf.to_khf() | ||
kmf.kernel(kmf.make_rdm1()) | ||
|
||
# | ||
# Second order SCF solver can be used in the PBC SCF code the same way in the | ||
# molecular calculation | ||
# | ||
kmf = scf.KRHF(cell, kpts).newton() | ||
kmf.kernel() | ||
|
||
# | ||
#KUHF | ||
# | ||
kumf = scf.KUHF(cell, kpts) | ||
kumf.kernel() | ||
|
||
# | ||
# The mean-field object with k-point symmetry can be converted back to | ||
# the correponding non-symmetric mean-field object | ||
# | ||
kumf = kumf.to_khf() | ||
kumf.kernel(kumf.make_rdm1()) | ||
|
||
# | ||
#KUHF with smearing | ||
# | ||
cell.spin = 2 * 2**3 #assume S=1 in each cell | ||
kumf = scf.KUHF(cell, kpts) | ||
#fix_spin: | ||
# if True: | ||
# the final solution will have the same spin as input | ||
# if False: | ||
# alpha and beta orbitals are sorted together based on energies, | ||
# and the final solution can have different spin from input | ||
# | ||
#Note: when gap is small, symmetry broken solution is usually the case, | ||
# which should be computed by turning off the symmstry options | ||
kumf = scf.addons.smearing_(kumf, sigma=0.001, method='fermi',fix_spin=True) | ||
kumf.kernel() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
|
||
''' | ||
MP2 with k-points sampling when Brillouin Zone symmetry is considered | ||
''' | ||
|
||
import numpy | ||
from pyscf.pbc import gto, scf, mp | ||
|
||
cell = gto.M( | ||
a = numpy.asarray([[0.0, 2.6935121974, 2.6935121974], | ||
[2.6935121974, 0.0, 2.6935121974], | ||
[2.6935121974, 2.6935121974, 0.0]]), | ||
atom = '''Si 0.0000000000 0.0000000000 0.0000000000 | ||
Si 1.3467560987 1.3467560987 1.3467560987''', | ||
basis = 'gth-szv', | ||
pseudo = 'gth-pade', | ||
mesh = [24,24,24], | ||
verbose = 5, | ||
) | ||
|
||
nk = [2,2,2] | ||
kpts = cell.make_kpts(nk, | ||
space_group_symmetry=True, | ||
time_reversal_symmetry=True) | ||
|
||
kmf = scf.KRHF(cell, kpts) | ||
kmf.kernel() | ||
|
||
kmp2 = mp.KMP2(kmf) | ||
kmp2.kernel() | ||
print("KMP2 energy (per unit cell) =", kmp2.e_tot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#!/usr/bin/env python | ||
|
||
''' | ||
Example code for | ||
k-point spin-restricted periodic MP2 calculation using staggered mesh method | ||
Author: Xin Xing ([email protected]) | ||
Reference: Staggered Mesh Method for Correlation Energy Calculations of Solids: | ||
Second-Order Møller-Plesset Perturbation Theory, J. Chem. Theory | ||
Comput. 2021, 17, 8, 4733-4745 | ||
''' | ||
|
||
|
||
from pyscf.pbc.mp.kmp2_stagger import KMP2_stagger | ||
from pyscf.pbc import df, gto, scf, mp | ||
|
||
|
||
''' | ||
Hydrogen dimer | ||
''' | ||
cell = gto.Cell() | ||
cell.pseudo = 'gth-pade' | ||
cell.basis = 'gth-szv' | ||
cell.ke_cutoff = 100 | ||
cell.atom = ''' | ||
H 3.00 3.00 2.10 | ||
H 3.00 3.00 3.90 | ||
''' | ||
cell.a = ''' | ||
6.0 0.0 0.0 | ||
0.0 6.0 0.0 | ||
0.0 0.0 6.0 | ||
''' | ||
cell.unit = 'B' | ||
cell.verbose = 4 | ||
cell.build() | ||
|
||
|
||
# HF calculation using FFTDF | ||
nks_mf = [2, 2, 2] | ||
kpts = cell.make_kpts(nks_mf, with_gamma_point=True) | ||
kmf = scf.KRHF(cell, kpts, exxdiv='ewald') | ||
ehf = kmf.kernel() | ||
|
||
# staggered mesh KMP2 using two 1*1*1 submeshes in kmf.kpts | ||
kmp = KMP2_stagger(kmf, flag_submesh=True) | ||
emp2 = kmp.kernel() | ||
assert((abs(emp2 - -0.0160902544091997)) < 1e-5) | ||
|
||
# staggered mesh KMP2 using two 2*2*2 submeshes based on non-SCF | ||
kmp = KMP2_stagger(kmf, flag_submesh=False) | ||
emp2 = kmp.kernel() | ||
assert((abs(emp2 - -0.0140289970302513)) < 1e-5) | ||
|
||
# standard KMP2 calculation | ||
kmp = mp.KMP2(kmf) | ||
emp2, _ = kmp.kernel() | ||
assert((abs(emp2 - -0.0143904878990777)) < 1e-5) | ||
|
||
|
||
# HF calculation using GDF | ||
nks_mf = [2, 2, 2] | ||
kpts = cell.make_kpts(nks_mf, with_gamma_point=True) | ||
kmf = scf.KRHF(cell, kpts, exxdiv='ewald') | ||
kmf.with_df = df.GDF(cell, kpts).build() | ||
ehf = kmf.kernel() | ||
|
||
# staggered mesh KMP2 using two 1*1*1 submeshes in kmf.kpts | ||
kmp = KMP2_stagger(kmf, flag_submesh=True) | ||
emp2 = kmp.kernel() | ||
assert((abs(emp2 - -0.0158364523431071)) < 1e-5) | ||
|
||
# staggered mesh KMP2 using two 2*2*2 submeshes based on non-SCF | ||
kmp = KMP2_stagger(kmf, flag_submesh=False) | ||
emp2 = kmp.kernel() | ||
assert((abs(emp2 - -0.0140280303691396)) < 1e-5) | ||
|
||
# standard KMP2 calculation | ||
kmp = mp.KMP2(kmf) | ||
emp2, _ = kmp.kernel() | ||
assert((abs(emp2 - -0.0141829343769316)) < 1e-5) | ||
|
||
|
||
''' | ||
Diamond system | ||
''' | ||
|
||
cell = gto.Cell() | ||
cell.pseudo = 'gth-pade' | ||
cell.basis = 'gth-szv' | ||
cell.ke_cutoff = 100 | ||
cell.atom = ''' | ||
C 0. 0. 0. | ||
C 1.26349729, 0.7294805 , 0.51582061 | ||
''' | ||
cell.a = ''' | ||
2.52699457, 0. , 0. | ||
1.26349729, 2.18844149, 0. | ||
1.26349729, 0.7294805 , 2.06328243 | ||
''' | ||
cell.unit = 'angstrom' | ||
cell.verbose = 4 | ||
cell.build() | ||
|
||
|
||
# HF calculation using FFTDF | ||
nks_mf = [2, 2, 2] | ||
kpts = cell.make_kpts(nks_mf, with_gamma_point=True) | ||
kmf = scf.KRHF(cell, kpts, exxdiv='ewald') | ||
ehf = kmf.kernel() | ||
|
||
# staggered mesh KMP2 using two 1*1*1 submeshes in kmf.kpts | ||
kmp = KMP2_stagger(kmf, flag_submesh=True) | ||
emp2 = kmp.kernel() | ||
assert((abs(emp2 - -0.156289981810986)) < 1e-5) | ||
|
||
# staggered mesh KMP2 using two 2*2*2 submeshes based on non-SCF | ||
kmp = KMP2_stagger(kmf, flag_submesh=False) | ||
emp2 = kmp.kernel() | ||
assert((abs(emp2 - -0.105454107635884)) < 1e-5) | ||
|
||
# standard KMP2 calculation | ||
kmp = mp.KMP2(kmf) | ||
emp2, _ = kmp.kernel() | ||
assert((abs(emp2 - -0.095517731535516)) < 1e-5) | ||
|
||
|
||
# HF calculation using GDF | ||
nks_mf = [2, 2, 2] | ||
kpts = cell.make_kpts(nks_mf, with_gamma_point=True) | ||
kmf = scf.KRHF(cell, kpts, exxdiv='ewald') | ||
kmf.with_df = df.GDF(cell, kpts).build() | ||
ehf = kmf.kernel() | ||
|
||
# staggered mesh KMP2 using two 1*1*1 submeshes in kmf.kpts | ||
kmp = KMP2_stagger(kmf, flag_submesh=True) | ||
emp2 = kmp.kernel() | ||
assert((abs(emp2 - -0.154923152683604)) < 1e-5) | ||
|
||
# staggered mesh KMP2 using two 2*2*2 submeshes based on non-SCF | ||
kmp = KMP2_stagger(kmf, flag_submesh=False) | ||
emp2 = kmp.kernel() | ||
assert((abs(emp2 - -0.105421948003715)) < 1e-5) | ||
|
||
# standard KMP2 calculation | ||
kmp = mp.KMP2(kmf) | ||
emp2, _ = kmp.kernel() | ||
assert((abs(emp2 - -0.0952009565805345)) < 1e-5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.