Skip to content

Commit 5cdaeae

Browse files
committed
Merge branch 'master' into dsrg-mrpt
2 parents 53f5954 + 9f8fe30 commit 5cdaeae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+42373
-625
lines changed

.github/workflows/ci_conda.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI_conda
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-conda-linux:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup conda
14+
uses: s-weigand/setup-conda@v1
15+
with:
16+
update-conda: true
17+
conda-channels: conda-forge
18+
- run: conda --version
19+
- run: which python
20+
- name: Build conda package
21+
run: |
22+
export CMAKE_BUILD_PARALLEL_LEVEL=4
23+
conda install -y conda-build
24+
conda config --set anaconda_upload False
25+
conda build --output-folder . conda

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
env:
42-
img: quay.io/pypa/manylinux2014_aarch64:2023-03-12-25fd859
42+
img: quay.io/pypa/manylinux2014_aarch64:latest
4343
steps:
4444
- name: Checkout
4545
uses: actions/checkout@v4

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Python-based Simulations of Chemistry Framework
1414
* [Documentation](http://www.pyscf.org)
1515
* [Installation](#installation)
1616
* [Features](../master/FEATURES)
17+
* [News](https://pyscf.org/news.html): **2nd PySCF Developers Meeting!**
1718

1819

1920
# Installation

examples/gto/04-input_basis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
mol = gto.M(
6666
atom = '''O 0 0 0; H1 0 1 0; H2 0 0 1''',
6767
basis = {'O': gto.parse('''
68-
# Parse NWChem format basis string (see https://bse.pnl.gov/bse/portal).
68+
# Parse NWChem format basis string (see https://www.basissetexchange.org/).
6969
# Comment lines are ignored
7070
#BASIS SET: (6s,3p) -> [2s,1p]
7171
O S

examples/gto/31-basis_set_exchange.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414
a local copy of the Basis Set Exchange.
1515
'''
1616

17+
# PySCF has a native interface to the Basis Set Exchange, which is
18+
# used as a fall-through if the basis set was not found within PySCF
19+
# itself
20+
mol = gto.M(
21+
atom = '''
22+
N 0.6683566134 0.2004327755 0.0000000000
23+
H 0.9668193796 -0.3441960976 0.8071193402
24+
H 0.9668193796 -0.3441960976 -0.8071193402
25+
F -0.7347916126 -0.0467759204 0.0000000000
26+
''',
27+
basis = 'HGBSP1-7',
28+
verbose = 4
29+
)
30+
31+
32+
# One can also use the Basis Set Exchange in a more direct fashion
1733
mol = gto.M(
1834
atom = '''
1935
N 0.6683566134 0.2004327755 0.0000000000
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python
2+
3+
'''
4+
This example demonstrates some ways to input the Cell geometry, including
5+
lattice vectors, and to write the Cell geometry to file.
6+
7+
Example solid is wurtzite BN.
8+
'''
9+
10+
from pyscf.pbc import gto
11+
12+
# Input Cartesian coordinates for the lattice vectors a and the atomic
13+
# positions. Coordinates are in Angstrom by default
14+
15+
cell = gto.Cell()
16+
cell.a = [[ 2.5539395809, 0.0000000000, 0.0000000000],
17+
[ -1.2769697905, 2.2117765568, 0.0000000000],
18+
[ 0.0000000000, 0.0000000000, 4.2268548012]]
19+
cell.atom = '''
20+
B 1.276969829 0.737258874 4.225688066
21+
N 1.276969829 0.737258874 2.642950986
22+
B 0.000000000 1.474517748 2.112260792
23+
N 0.000000000 1.474517748 0.529523459
24+
'''
25+
cell.pseudo = 'gth-pade'
26+
cell.basis = 'gth-szv'
27+
cell.build()
28+
29+
# Write cell geometry to file
30+
# - Format is guessed from filename
31+
# - These can be read by VESTA, Avogadro, etc.
32+
# - XYZ is Extended XYZ file format, which includes lattice vectors in the
33+
# comment line
34+
cell.tofile('bn.vasp')
35+
cell.tofile('POSCAR')
36+
cell.tofile('bn.xyz')
37+
38+
# Read a and atom from file
39+
from pyscf.pbc.gto.cell import fromfile
40+
a, atom = fromfile('bn.vasp')
41+
a, atom = fromfile('bn.xyz')
42+
43+
# Read a and atom from file directly into Cell
44+
cell = gto.Cell()
45+
cell.fromfile('bn.vasp')
46+
cell.pseudo = 'gth-pade'
47+
cell.basis = 'gth-szv'
48+
cell.build()

examples/pbc/09-band_ase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import matplotlib.pyplot as plt
66

7-
from ase.lattice import bulk
7+
from ase.build import bulk
88
from ase.dft.kpoints import sc_special_points as special_points, get_bandpath
99

1010
c = bulk('C', 'diamond', a=3.5668)

examples/solvent/05-pcm.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,13 @@
6363
td.kernel()
6464

6565
mf = mol.RHF().PCM().run()
66-
td = mf.TDA().run()
66+
td = mf.TDA().run()
67+
68+
# infinite epsilon with any PCM computations
69+
cm = pcm.PCM(mol)
70+
cm.eps = float('inf') # ideal conductor
71+
mf = dft.RKS(mol, xc='b3lyp')
72+
mf = mf.PCM(cm)
73+
mf.kernel()
74+
75+

examples/solvent/07-cosmors.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env python
2+
'''
3+
An example of using COSMO-RS functionality.
4+
'''
5+
6+
#%% Imports
7+
8+
import io
9+
10+
import numpy as np
11+
import matplotlib.pyplot as plt
12+
13+
from pyscf import gto, dft
14+
from pyscf.solvent import pcm
15+
from pyscf.solvent.cosmors import get_sas_volume
16+
from pyscf.solvent.cosmors import write_cosmo_file
17+
from pyscf.solvent.cosmors import get_cosmors_parameters
18+
19+
20+
#%% Set parameters
21+
22+
# get molecule
23+
coords = '''
24+
C 0.000000 0.000000 -0.542500
25+
O 0.000000 0.000000 0.677500
26+
H 0.000000 0.9353074360871938 -1.082500
27+
H 0.000000 -0.9353074360871938 -1.082500
28+
'''
29+
mol = gto.M(atom=coords, basis='6-31G*', verbose=1)
30+
31+
# configure PCM
32+
cm = pcm.PCM(mol)
33+
cm.eps = float('inf') # f_epsilon = 1 is required for COSMO-RS
34+
cm.method = 'C-PCM' # or COSMO, IEF-PCM, SS(V)PE, see https://manual.q-chem.com/5.4/topic_pcm-em.html
35+
cm.lebedev_order = 29 # lebedev grids on the cavity surface, lebedev_order=29 <--> # of grids = 302
36+
37+
38+
#%% COSMO-files
39+
40+
# run DFT SCF (any level of theory is OK, though DFT is optimal)
41+
mf = dft.RKS(mol, xc='b3lyp')
42+
mf = mf.PCM(cm)
43+
mf.kernel()
44+
45+
# generate COSMO-file
46+
with io.StringIO() as outp: # with open('formaldehyde.cosmo', 'w') as outf:
47+
write_cosmo_file(outp, mf)
48+
print(outp.getvalue())
49+
50+
51+
# if PCM DFT were computed with fepsilon < 1 <=> eps != inf the ValueError will be raised
52+
# use ignore_low_feps=True to overrule it, but please be sure you know what you're doing
53+
54+
# run DFT SCF
55+
cm = pcm.PCM(mol)
56+
cm.eps = 32.613 # methanol
57+
mf = dft.RKS(mol, xc='b3lyp')
58+
mf = mf.PCM(cm)
59+
mf.kernel()
60+
61+
# try to get COSMO-file
62+
with io.StringIO() as outp:
63+
try:
64+
write_cosmo_file(outp, mf)
65+
print(outp.getvalue())
66+
except ValueError as e:
67+
print(e)
68+
69+
# overruling
70+
with io.StringIO() as outp:
71+
write_cosmo_file(outp, mf, ignore_low_feps=True)
72+
print(outp.getvalue())
73+
74+
75+
# The molecular volume is computed for the solvent-accessible surface generated
76+
# within pcm.PCM object. Please note that r_sol is assumed to be equal to zero,
77+
# so that SAS is a union of vdW spheres.
78+
# Increasing integration step increases accuracy of integration, but for most COSMO-RS
79+
# modelling and ML step=0.2 should be enough:
80+
81+
# compute volumes with different step values
82+
steps = [1.0, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01]
83+
Vs = [get_sas_volume(mf.with_solvent.surface, step) for step in steps]
84+
# plot
85+
ax = plt.gca()
86+
ax.plot(Vs)
87+
ax.set_xticks(range(len(steps)))
88+
_ = ax.set_xticklabels(steps)
89+
plt.show()
90+
91+
92+
#%% Sigma-profiles
93+
94+
# compute SCF PCM
95+
cm = pcm.PCM(mol)
96+
cm.eps = float('inf')
97+
mf = dft.RKS(mol, xc='b3lyp')
98+
mf = mf.PCM(cm)
99+
mf.kernel()
100+
101+
# compute sigma-profile and related parameters
102+
params = get_cosmors_parameters(mf)
103+
print(params)
104+
plt.plot(params['Screening charge, e/A**2'],
105+
params['Screening charge density, A**2'])
106+
plt.show()
107+
108+
# custom sigma grid
109+
sigmas_grid = np.linspace(-0.025, 0.025, 101)
110+
params = get_cosmors_parameters(mf, sigmas_grid)
111+
plt.plot(params['Screening charge, e/A**2'],
112+
params['Screening charge density, A**2'])
113+
plt.show()
114+
115+

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ cppe = ["cppe"]
5757
pyqmc = ["pyqmc"]
5858
bse = ["basis-set-exchange"]
5959
dispersion = ["pyscf-dispersion"]
60+
ccpy = ["coupled-cluster-py"]
6061

61-
all = ["pyscf[forge,geomopt,doci,properties,semiempirical,cppe,pyqmc,bse,dispersion]"]
62+
all = ["pyscf[forge,geomopt,doci,properties,semiempirical,cppe,pyqmc,bse,dispersion,ccpy]"]
6263

6364
# extras which should not be installed by "all" components
6465
cornell_shci = ["pyscf-cornell-shci"]

0 commit comments

Comments
 (0)