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 sr-eri-estimator-improved
- Loading branch information
Showing
156 changed files
with
43,832 additions
and
1,449 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: CI_conda | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-conda-linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup conda | ||
uses: s-weigand/setup-conda@v1 | ||
with: | ||
update-conda: true | ||
conda-channels: conda-forge | ||
- run: conda --version | ||
- run: which python | ||
- name: Build conda package | ||
run: | | ||
export CMAKE_BUILD_PARALLEL_LEVEL=4 | ||
conda install -y conda-build | ||
conda config --set anaconda_upload False | ||
conda build --output-folder . conda |
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,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
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,48 @@ | ||
#!/usr/bin/env python | ||
|
||
''' | ||
This example demonstrates some ways to input the Cell geometry, including | ||
lattice vectors, and to write the Cell geometry to file. | ||
Example solid is wurtzite BN. | ||
''' | ||
|
||
from pyscf.pbc import gto | ||
|
||
# Input Cartesian coordinates for the lattice vectors a and the atomic | ||
# positions. Coordinates are in Angstrom by default | ||
|
||
cell = gto.Cell() | ||
cell.a = [[ 2.5539395809, 0.0000000000, 0.0000000000], | ||
[ -1.2769697905, 2.2117765568, 0.0000000000], | ||
[ 0.0000000000, 0.0000000000, 4.2268548012]] | ||
cell.atom = ''' | ||
B 1.276969829 0.737258874 4.225688066 | ||
N 1.276969829 0.737258874 2.642950986 | ||
B 0.000000000 1.474517748 2.112260792 | ||
N 0.000000000 1.474517748 0.529523459 | ||
''' | ||
cell.pseudo = 'gth-pade' | ||
cell.basis = 'gth-szv' | ||
cell.build() | ||
|
||
# Write cell geometry to file | ||
# - Format is guessed from filename | ||
# - These can be read by VESTA, Avogadro, etc. | ||
# - XYZ is Extended XYZ file format, which includes lattice vectors in the | ||
# comment line | ||
cell.tofile('bn.vasp') | ||
cell.tofile('POSCAR') | ||
cell.tofile('bn.xyz') | ||
|
||
# Read a and atom from file | ||
from pyscf.pbc.gto.cell import fromfile | ||
a, atom = fromfile('bn.vasp') | ||
a, atom = fromfile('bn.xyz') | ||
|
||
# Read a and atom from file directly into Cell | ||
cell = gto.Cell() | ||
cell.fromfile('bn.vasp') | ||
cell.pseudo = 'gth-pade' | ||
cell.basis = 'gth-szv' | ||
cell.build() |
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,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
Oops, something went wrong.