Skip to content

Commit

Permalink
Merge branch 'master' into sr-eri-estimator-improved
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Dec 16, 2024
2 parents a519a35 + c589689 commit c18dc14
Show file tree
Hide file tree
Showing 156 changed files with 43,832 additions and 1,449 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci_conda.yml
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
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux/build_pyscf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

cd ./pyscf/lib
curl -L "https://github.com/pyscf/pyscf-build-deps/blob/master/pyscf-2.4a-deps.tar.gz?raw=true" | tar xzf -
curl -L "https://github.com/pyscf/pyscf-build-deps/blob/master/pyscf-2.8a-deps.tar.gz?raw=true" | tar xzf -
mkdir build; cd build
cmake -DBUILD_LIBXC=OFF -DBUILD_XCFUN=ON -DBUILD_LIBCINT=OFF -DXCFUN_MAX_ORDER=4 ..
make -j4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
env:
img: quay.io/pypa/manylinux2014_aarch64:2023-03-12-25fd859
img: quay.io/pypa/manylinux2014_aarch64:latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Python-based Simulations of Chemistry Framework
* [Documentation](http://www.pyscf.org)
* [Installation](#installation)
* [Features](../master/FEATURES)
* [News](https://pyscf.org/news.html): **2nd PySCF Developers Meeting!**


# Installation
Expand Down
23 changes: 13 additions & 10 deletions examples/dft/16-dft_d3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
'''
D3 and D4 Dispersion.
This is a simplified dispersion interface to
d3 (https://github.com/dftd3/simple-dftd3) and
d4 (https://github.com/dftd4/dftd4) libraries.
This interface can automatically configure the necessary settings including
dispersion, xc, and nlc attributes of PySCF mean-field objects. However,
advanced features of d3 and d4 program are not available.
This example shows the functionality of the pyscf-dispersion extension, which
implements a simplified interface to d3 (https://github.com/dftd3/simple-dftd3)
and d4 (https://github.com/dftd4/dftd4) libraries. This interface can
automatically configure the necessary settings including dispersion, xc, and nlc
attributes of PySCF mean-field objects. However, advanced features of d3 and d4
program are not available. To execute the code in this example, you would need
to install the pyscf-dispersion extension:
pip install pyscf-dispersion
If you need to access more features d3 and d4 libraries, such as overwriting the
dispersion parameters, you can use the wrapper provided by the simple-dftd3 and
dftd4 libraries. When using these libraries, please disable the .disp attribute
of the underlying mean-field object, and properly set the .xc and .nlc attributes
following this example.
dftd4 libraries. When accessing dispersion through the APIs of these libraries,
please disable the .disp attribute of the mean-field object, and properly set
the .xc and .nlc attributes as shown in this example.
'''

mol = pyscf.M(
Expand Down Expand Up @@ -134,7 +137,7 @@
mf.disp = 'd4'
mf.kernel() # Crash

# Please note, not every xc functional can be used for D3/D4 corrections.
# Please note, NOT every xc functional can be used for D3/D4 corrections.
# For the valid xc and D3/D4 combinations, please refer to
# https://github.com/dftd3/simple-dftd3/blob/main/assets/parameters.toml
# https://github.com/dftd4/dftd4/blob/main/assets/parameters.toml
Expand Down
36 changes: 36 additions & 0 deletions examples/geomopt/16-apply_soscf.py
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))
2 changes: 1 addition & 1 deletion examples/gto/04-input_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
mol = gto.M(
atom = '''O 0 0 0; H1 0 1 0; H2 0 0 1''',
basis = {'O': gto.parse('''
# Parse NWChem format basis string (see https://bse.pnl.gov/bse/portal).
# Parse NWChem format basis string (see https://www.basissetexchange.org/).
# Comment lines are ignored
#BASIS SET: (6s,3p) -> [2s,1p]
O S
Expand Down
16 changes: 16 additions & 0 deletions examples/gto/31-basis_set_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
a local copy of the Basis Set Exchange.
'''

# PySCF has a native interface to the Basis Set Exchange, which is
# used as a fall-through if the basis set was not found within PySCF
# itself
mol = gto.M(
atom = '''
N 0.6683566134 0.2004327755 0.0000000000
H 0.9668193796 -0.3441960976 0.8071193402
H 0.9668193796 -0.3441960976 -0.8071193402
F -0.7347916126 -0.0467759204 0.0000000000
''',
basis = 'HGBSP1-7',
verbose = 4
)


# One can also use the Basis Set Exchange in a more direct fashion
mol = gto.M(
atom = '''
N 0.6683566134 0.2004327755 0.0000000000
Expand Down
48 changes: 48 additions & 0 deletions examples/pbc/01-input_output_geometry.py
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()
2 changes: 1 addition & 1 deletion examples/pbc/09-band_ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import matplotlib.pyplot as plt

from ase.lattice import bulk
from ase.build import bulk
from ase.dft.kpoints import sc_special_points as special_points, get_bandpath

c = bulk('C', 'diamond', a=3.5668)
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()
11 changes: 10 additions & 1 deletion examples/solvent/05-pcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,13 @@
td.kernel()

mf = mol.RHF().PCM().run()
td = mf.TDA().run()
td = mf.TDA().run()

# infinite epsilon with any PCM computations
cm = pcm.PCM(mol)
cm.eps = float('inf') # ideal conductor
mf = dft.RKS(mol, xc='b3lyp')
mf = mf.PCM(cm)
mf.kernel()


Loading

0 comments on commit c18dc14

Please sign in to comment.