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

+25
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

+1-1
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

+1
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

+1-1
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

+16
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
+48
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

+1-1
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

+10-1
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

+115
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

+2-1
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"]

pyscf/ao2mo/__init__.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import tempfile
3232
import numpy
3333
import h5py
34+
from pyscf import gto
3435
from pyscf.ao2mo import incore
3536
from pyscf.ao2mo import outcore
3637
from pyscf.ao2mo import r_outcore
@@ -143,7 +144,7 @@ def full(eri_or_mol, mo_coeff, erifile=None, dataname='eri_mo', intor='int2e',
143144
'''
144145
if isinstance(eri_or_mol, numpy.ndarray):
145146
return incore.full(eri_or_mol, mo_coeff, *args, **kwargs)
146-
else:
147+
elif isinstance(eri_or_mol, gto.MoleBase):
147148
if '_spinor' in intor:
148149
mod = r_outcore
149150
else:
@@ -157,6 +158,11 @@ def full(eri_or_mol, mo_coeff, erifile=None, dataname='eri_mo', intor='int2e',
157158
*args, **kwargs)
158159
else:
159160
return mod.full_iofree(eri_or_mol, mo_coeff, intor, *args, **kwargs)
161+
else:
162+
raise RuntimeError('ERI is not available. If this is generated by mf._eri, '
163+
'the integral tensor is too big to store in memory. '
164+
'You should either increase mol.max_memory, or set '
165+
'mol.incore_anyway. See issue #2473.')
160166

161167
def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e',
162168
*args, **kwargs):
@@ -293,7 +299,7 @@ def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e
293299
'''
294300
if isinstance(eri_or_mol, numpy.ndarray):
295301
return incore.general(eri_or_mol, mo_coeffs, *args, **kwargs)
296-
else:
302+
elif isinstance(eri_or_mol, gto.MoleBase):
297303
if '_spinor' in intor:
298304
mod = r_outcore
299305
else:
@@ -307,6 +313,11 @@ def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e
307313
*args, **kwargs)
308314
else:
309315
return mod.general_iofree(eri_or_mol, mo_coeffs, intor, *args, **kwargs)
316+
else:
317+
raise RuntimeError('ERI is not available. If this is generated by mf._eri, '
318+
'the integral tensor is too big to store in memory. '
319+
'You should either increase mol.max_memory, or set '
320+
'mol.incore_anyway. See issue #2473.')
310321

311322
def kernel(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e',
312323
*args, **kwargs):

pyscf/ao2mo/_ao2mo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def nr_e1fill(intor, sh_range, atm, bas, env,
7373
natm = ctypes.c_int(c_atm.shape[0])
7474
nbas = ctypes.c_int(c_bas.shape[0])
7575
ao_loc = make_loc(bas, intor)
76-
nao = ao_loc[-1]
76+
nao = int(ao_loc[-1])
7777

7878
klsh0, klsh1, nkl = sh_range
7979

pyscf/ao2mo/nrr_outcore.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,9 @@ def _count_naopair(mol, nao):
380380
ao_loc = mol.ao_loc_2c()
381381
nao_pair = 0
382382
for i in range(mol.nbas):
383-
di = ao_loc[i+1] - ao_loc[i]
383+
di = int(ao_loc[i+1] - ao_loc[i])
384384
for j in range(i+1):
385-
dj = ao_loc[j+1] - ao_loc[j]
385+
dj = int(ao_loc[j+1] - ao_loc[j])
386386
nao_pair += di * dj
387387
return nao_pair
388388

pyscf/ao2mo/outcore.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,8 @@ def guess_shell_ranges(mol, aosym, max_iobuf, max_aobuf=None, ao_loc=None,
710710
compress_diag=True):
711711
if ao_loc is None: ao_loc = mol.ao_loc_nr()
712712
max_iobuf = max(1, max_iobuf)
713-
714-
dims = ao_loc[1:] - ao_loc[:-1]
713+
ao_loc_long = ao_loc.astype(numpy.int64)
714+
dims = ao_loc_long[1:] - ao_loc_long[:-1]
715715
dijs = (dims.reshape(-1,1) * dims)
716716
nbas = dijs.shape[0]
717717

@@ -773,7 +773,7 @@ def balance_partition(ao_loc, blksize, start_id=0, stop_id=None):
773773
displs = [i+start_id for i in displs]
774774
tasks = []
775775
for i0, i1 in zip(displs[:-1],displs[1:]):
776-
tasks.append((i0, i1, ao_loc[i1]-ao_loc[i0]))
776+
tasks.append((i0, i1, int(ao_loc[i1]-ao_loc[i0])))
777777
return tasks
778778

779779
del (MAX_MEMORY)

pyscf/ao2mo/r_outcore.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ def _count_naopair(mol, nao):
302302
ao_loc = mol.ao_loc_2c()
303303
nao_pair = 0
304304
for i in range(mol.nbas):
305-
di = ao_loc[i+1] - ao_loc[i]
305+
di = int(ao_loc[i+1] - ao_loc[i])
306306
for j in range(i+1):
307-
dj = ao_loc[j+1] - ao_loc[j]
307+
dj = int(ao_loc[j+1] - ao_loc[j])
308308
nao_pair += di * dj
309309
return nao_pair
310310

0 commit comments

Comments
 (0)