-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into ml
- Loading branch information
Showing
203 changed files
with
35,351 additions
and
1,672 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
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 |
---|---|---|
@@ -1,15 +1,4 @@ | ||
#!/usr/bin/env bash | ||
export OMP_NUM_THREADS=1 | ||
export PYTHONPATH=$(pwd):$(pwd)/pyscf:$PYTHONPATH | ||
# preload MKL | ||
#if [[ -n "${MKLROOT}" ]]; then | ||
# export LD_PRELOAD=$MKLROOT/lib/intel64/libmkl_avx2.so:$MKLROOT/lib/intel64/libmkl_sequential.so:$MKLROOT/lib/intel64/libmkl_core.so | ||
#fi | ||
echo "pyscfad = True" >> $HOME/.pyscf_conf.py | ||
echo "pyscf_numpy_backend = 'jax'" >> $HOME/.pyscf_conf.py | ||
echo "pyscf_scipy_linalg_backend = 'pyscfad'" >> $HOME/.pyscf_conf.py | ||
echo "pyscf_scipy_backend = 'jax'" >> $HOME/.pyscf_conf.py | ||
#echo "pyscfad_scf_implicit_diff = True" >> $HOME/.pyscf_conf.py | ||
#echo "pyscfad_ccsd_implicit_diff = True" >> $HOME/.pyscf_conf.py | ||
|
||
pytest ./pyscfad --cov-report xml --cov=. --verbosity=1 --durations=10 |
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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
include MANIFEST.in | ||
include README.md setup.py LICENSE | ||
|
||
recursive-include pyscfadlib/thirdparty *.so *.dylib | ||
include pyscfadlib/*.so pyscfadlib/*.dylib pyscfadlib/config.h.in | ||
|
||
# source code | ||
recursive-include pyscfadlib *.c *.h CMakeLists.txt | ||
include pyscfad/geomopt/log.ini | ||
|
||
global-exclude *.py[cod] | ||
prune pyscfadlib/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 was deleted.
Oops, something went wrong.
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,68 @@ | ||
''' | ||
Geometry optimization using RPA gradients calculated with PySCFAD and PyBerny | ||
as a molecular geometry optimizer | ||
''' | ||
import jax | ||
from pyscf import df as pyscf_df | ||
from pyscfad import gto, dft, df | ||
from pyscfad.gw import rpa | ||
from pyscf.geomopt.berny_solver import optimize, to_berny_geom | ||
from berny import Berny, geomlib | ||
import warnings | ||
warnings.simplefilter("ignore") | ||
|
||
def energy_(mol, with_df): | ||
mf = dft.RKS(mol) | ||
mf.xc = 'pbe' | ||
mf.kernel(dm0=None) | ||
|
||
mymp = rpa.RPA(mf) | ||
mymp.with_df = with_df | ||
mymp.kernel() | ||
return mymp.e_tot | ||
|
||
def solver(geom, val_and_grad): | ||
mol = gto.Mole() | ||
mol.verbose = 0 | ||
mol.atom = geom | ||
mol.basis = 'ccpvdz' | ||
mol.build(trace_exp=False, trace_ctr_coeff=False) | ||
|
||
auxbasis = pyscf_df.addons.make_auxbasis(mol, mp2fit=True) | ||
auxmol = df.addons.make_auxmol(mol, auxbasis) | ||
with_df = df.DF(mol, auxmol=auxmol) | ||
|
||
e_tot, jac = val_and_grad(mol, with_df) | ||
|
||
return e_tot, jac[0].coords + jac[1].mol.coords + jac[1].auxmol.coords | ||
|
||
|
||
# fictitious molecule to initialize PyBerny optimizer | ||
mol_ = gto.Mole() | ||
mol_.build(atom = 'H 0 0 0; H 0 0 1.', basis = 'sto-3g') | ||
geom = to_berny_geom(mol_) | ||
optimizer = Berny(geom) # initialize geometry optimizer | ||
|
||
val_and_grad = jax.value_and_grad(energy_, (0,1)) | ||
|
||
for iter_, geom in enumerate(optimizer): | ||
energy, gradients = solver(list(geom), val_and_grad) | ||
optimizer.send((energy, gradients)) | ||
print(f'iter={iter_+1} energy={energy:.10f}') | ||
|
||
print('\nOptimized geometry:') | ||
print(geom.coords) | ||
|
||
''' | ||
iter=1 energy=-1.1691629669 | ||
iter=2 energy=-1.1857669916 | ||
iter=3 energy=-1.1780975967 | ||
iter=4 energy=-1.1915441270 | ||
iter=5 energy=-1.1919771635 | ||
iter=6 energy=-1.1920713876 | ||
iter=7 energy=-1.1920721970 | ||
Optimized geometry: | ||
[[0. 0. 0.11749648] | ||
[0. 0. 0.88250352]] | ||
''' |
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
Oops, something went wrong.