forked from pyscf/pyscf
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tdhf-diagonalization
- Loading branch information
Showing
84 changed files
with
2,014 additions
and
828 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
''' | ||
Automatically apply SOSCF for unconverged SCF calculations in geometry optimization. | ||
''' | ||
|
||
import pyscf | ||
from pyscf.geomopt import geometric_solver, as_pyscf_method | ||
|
||
# Force SCF to stop early at an unconverged state | ||
pyscf.scf.hf.RHF.max_cycle = 5 | ||
|
||
mol = pyscf.M( | ||
atom=''' | ||
O 0 0 0 | ||
H 0 .7 .8 | ||
H 0 -.7 .8 | ||
''') | ||
mf = mol.RHF() | ||
try: | ||
mol_eq = geometric_solver.optimize(mf) | ||
except RuntimeError: | ||
print('geometry optimization should stop for unconverged calculation') | ||
|
||
# Apply SOSCF when SCF is not converged | ||
mf_scanner = mf.as_scanner() | ||
def apply_soscf_as_needed(mol): | ||
mf_scanner(mol) | ||
if not mf_scanner.converged: | ||
mf_soscf = mf_scanner.newton().run() | ||
for key in ['converged', 'mo_energy', 'mo_coeff', 'mo_occ', 'e_tot', 'scf_summary']: | ||
setattr(mf_scanner, key, getattr(mf_soscf, key)) | ||
grad = mf_scanner.Gradients().kernel() | ||
return mf_scanner.e_tot, grad | ||
|
||
mol_eq = geometric_solver.optimize(as_pyscf_method(mol, apply_soscf_as_needed)) |
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,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() |
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
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
Empty file.
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.