Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #165

Open
wants to merge 184 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
64b3a61
change batching stragegy
NicoRenaud Jun 16, 2021
720791e
introduced logspace sampling
NicoRenaud Jun 17, 2021
1347f7f
fix solver bug
NicoRenaud Jun 17, 2021
2e4326d
made mpi4py optional
NicoRenaud Jun 17, 2021
46dae49
fix mpi in Molecule
NicoRenaud Jun 18, 2021
d1da291
Merge pull request #122 from NLESC-JCER/mpi4py_optional
NicoRenaud Jun 21, 2021
d6612bd
test
NicoRenaud Jun 23, 2021
d3f9e30
added h5py
NicoRenaud Jun 23, 2021
3041149
Update build.yml
NicoRenaud Jun 23, 2021
725580f
reverted mpi4py and h5py to conda
NicoRenaud Jun 23, 2021
a632207
Update setup.py
NicoRenaud Jun 23, 2021
56910e0
Merge pull request #124 from NLESC-JCER/TestHvdCI
NicoRenaud Jun 23, 2021
38a1dc3
use fft to compute correlation coefficient
matthijsdewit111 Jun 24, 2021
315f4f1
use numpy instead of torch
matthijsdewit111 Jun 24, 2021
7d8f538
added example, and both methods of calculating autocorrelation
matthijsdewit111 Jun 24, 2021
4833b9e
fix computing correlation coefficient
matthijsdewit111 Jun 24, 2021
0e9ab60
small style changes
matthijsdewit111 Jun 24, 2021
9d6936a
found a way to use scipy after all!
matthijsdewit111 Jun 24, 2021
73fabda
Merge pull request #126 from NLESC-JCER/fft-corr-coef
matthijsdewit111 Jul 2, 2021
158fb98
Merge pull request #120 from NLESC-JCER/batching
NicoRenaud Jul 5, 2021
27cfb3a
removed plams
NicoRenaud Jul 5, 2021
339c8d7
Merge branch 'development' into logspace_sampling
NicoRenaud Jul 5, 2021
b3c6468
Merge pull request #121 from NLESC-JCER/logspace_sampling
NicoRenaud Jul 5, 2021
fa85bc1
replaced dataloader
NicoRenaud Jul 7, 2021
82e11ce
dataset
NicoRenaud Jul 7, 2021
ec817cb
data loader in solver horovod
NicoRenaud Jul 7, 2021
ee06a59
pin memory
NicoRenaud Jul 7, 2021
64e0180
fix resampling call in solver
NicoRenaud Jul 7, 2021
f0515f7
clean files
NicoRenaud Jul 8, 2021
5c33cbd
Merge pull request #128 from NLESC-JCER/data_loader
NicoRenaud Jul 8, 2021
c5dc1c2
install
NicoRenaud Jul 9, 2021
40ae671
started jastrow graph
NicoRenaud Jul 9, 2021
f8fd664
added graph
NicoRenaud Jul 12, 2021
9378f02
added graph jastrow
NicoRenaud Jul 12, 2021
c3af14f
LongTensor node data
NicoRenaud Jul 13, 2021
1cf8308
add mgcn locally to fix embedding
NicoRenaud Jul 13, 2021
d6d3e58
bidirectional graph
NicoRenaud Jul 13, 2021
4a05e00
added slater jastrow graph class
NicoRenaud Jul 13, 2021
5a67abc
refac jast
NicoRenaud Jul 13, 2021
ebb9867
added notebooks
NicoRenaud Jul 14, 2021
f018000
create new slater jastrow clas
NicoRenaud Aug 17, 2021
f66cbfe
refactored tests
NicoRenaud Aug 17, 2021
f6c2666
working the refactoring
NicoRenaud Aug 17, 2021
0509b0a
fix kinetic calcilation
NicoRenaud Aug 17, 2021
43f2aad
compare backflow
NicoRenaud Aug 17, 2021
33e76fb
fix test hvd
NicoRenaud Aug 18, 2021
56f267e
fix sampler test
NicoRenaud Aug 18, 2021
59a4e75
fix scf
NicoRenaud Aug 18, 2021
a1d8f6a
fix test utils
NicoRenaud Aug 18, 2021
ab9a6cb
fix jastrow test
NicoRenaud Aug 18, 2021
388289d
remove test jastrow orbital dependent
NicoRenaud Aug 18, 2021
2bbbdca
init file in test folders
NicoRenaud Aug 18, 2021
60f8e7e
fix jastrow tst
NicoRenaud Aug 18, 2021
0f5d859
bypass hvd test for now
NicoRenaud Aug 19, 2021
ed3a70d
remove tables mendeleev
NicoRenaud Aug 19, 2021
e87be89
init of the elec-elec jastrpw
NicoRenaud Aug 19, 2021
458513c
refactor test solver
NicoRenaud Aug 19, 2021
969eb65
remove ref to orb de jastrow
NicoRenaud Aug 19, 2021
e18491d
fix test wavefunction
NicoRenaud Aug 19, 2021
f25d1a6
remove test values
NicoRenaud Aug 19, 2021
b29a43d
change graph jastrow to take mol as arg
NicoRenaud Aug 19, 2021
c05da7d
remove assert on expected energy in the base class
NicoRenaud Aug 19, 2021
236976d
updated example
NicoRenaud Aug 19, 2021
7cb1574
fix test graph
NicoRenaud Aug 19, 2021
3eb6965
change name of tests
NicoRenaud Aug 19, 2021
e4b0a29
remove unused var
NicoRenaud Oct 5, 2021
d762715
made plot not autoload
NicoRenaud Oct 5, 2021
31fb635
remove plot load from slaterjastrow
NicoRenaud Oct 5, 2021
0ba0d2e
correct path to plot routine
NicoRenaud Oct 5, 2021
01e230a
remove unused import of plot routine
NicoRenaud Oct 5, 2021
148828f
fix import of plot data
NicoRenaud Oct 7, 2021
37e2afd
fixed batch energy
NicoRenaud Oct 11, 2021
14b702c
remove sampler.walkers
NicoRenaud Oct 11, 2021
8a654aa
use only nwalkers even in resampling and increase the numner of points
NicoRenaud Oct 11, 2021
234284c
print number sampking points
NicoRenaud Oct 11, 2021
6477409
fix issue with reweighting sampling points
NicoRenaud Oct 14, 2021
aae8d42
Merge pull request #135 from NLESC-JCER/lean_sampler
NicoRenaud Oct 18, 2021
47acadc
batch single point
NicoRenaud Oct 18, 2021
c739ba2
grey value
NicoRenaud Oct 18, 2021
0ef9ea6
added simple metropolis
NicoRenaud Oct 18, 2021
7705e1a
jastrow cobined term kernels as modulelist
NicoRenaud Oct 19, 2021
9c1859d
added energy plotter bin
NicoRenaud Oct 20, 2021
afa39b0
simplified combining jastrows
NicoRenaud Oct 20, 2021
b7db7e1
added possiblity to have odd number of elec
NicoRenaud Oct 20, 2021
67ad02f
fixed orb conf cas
NicoRenaud Oct 20, 2021
307f857
charge and spin info correct in plamms
NicoRenaud Oct 21, 2021
07f9aba
Merge pull request #136 from NLESC-JCER/spin
NicoRenaud Oct 21, 2021
eca7464
fix dump of tuple of torch tensors
NicoRenaud Oct 21, 2021
4753081
added pints interface to samplers
NicoRenaud Oct 21, 2021
7256d13
added metropolis hasting with assymetric proposal
NicoRenaud Oct 26, 2021
9c2cfc7
added test for pints sampler
NicoRenaud Oct 27, 2021
7224608
added mh with assymetric distribution
NicoRenaud Oct 27, 2021
f59ea34
added pints to setup
NicoRenaud Oct 27, 2021
c1c42b8
added test for mh
NicoRenaud Oct 27, 2021
238c02e
clean up
NicoRenaud Oct 29, 2021
4e35c32
Merge pull request #134 from NLESC-JCER/unify_slaterjastrow
NicoRenaud Mar 11, 2022
91958c1
fix import issue
NicoRenaud Mar 14, 2022
6505080
fix some conflicts
NicoRenaud Nov 24, 2023
39093c8
fix typos
NicoRenaud Nov 24, 2023
64caa35
fix path and module
NicoRenaud Nov 24, 2023
2fd6155
Repalced SolverSalterJastrow by Solver
NicoRenaud Nov 25, 2023
8f41762
fix argument of SJ with orbital dependent Jastrow
NicoRenaud Nov 27, 2023
aa3b495
fix call to jastrow kernel
NicoRenaud Nov 27, 2023
fd5703f
fix arg
NicoRenaud Nov 28, 2023
fef6564
reformat black
NicoRenaud Nov 28, 2023
021b52f
Revert "reformat black"
NicoRenaud Nov 28, 2023
725a51f
black only src
NicoRenaud Nov 28, 2023
7581cf4
removed trash wf
NicoRenaud Nov 28, 2023
d54d958
removed unused import
NicoRenaud Nov 28, 2023
0fe3590
critical error
NicoRenaud Nov 28, 2023
9784ea1
unused import in test
NicoRenaud Nov 28, 2023
9ab7ae8
gradient no backflow
NicoRenaud Nov 28, 2023
218424f
Revert "removed unused import"
NicoRenaud Nov 28, 2023
87ca460
add charge and spin to adf
NicoRenaud Nov 29, 2023
2a0af70
fix test gradients no backflow
NicoRenaud Nov 29, 2023
eca0db0
fix callable jastrow args
NicoRenaud Nov 29, 2023
95fd44e
reverted gradient no backflow
NicoRenaud Nov 29, 2023
86f66d6
pylint unused module in baseimport
NicoRenaud Nov 29, 2023
3424c69
fix coday
NicoRenaud Nov 29, 2023
903c148
black formatting
NicoRenaud Nov 29, 2023
6085953
black formatting
NicoRenaud Nov 29, 2023
4c2a354
fix mcgn test
NicoRenaud Nov 29, 2023
a32e7e2
fix ao callable args
NicoRenaud Nov 29, 2023
d5bc69e
fix metropolis
NicoRenaud Nov 29, 2023
eea0091
remove backlfow from generic jastrow test
NicoRenaud Nov 29, 2023
51798b6
coday fix
NicoRenaud Nov 29, 2023
2905be8
codacy fix
NicoRenaud Nov 29, 2023
69dd17e
codacy fix
NicoRenaud Nov 29, 2023
bfa8894
exception in hdf5,py
NicoRenaud Nov 29, 2023
8039185
black src
NicoRenaud Nov 29, 2023
a799420
black test
NicoRenaud Nov 29, 2023
c8a04ac
Merge pull request #166 from NLESC-JCER/dev_black
NicoRenaud Nov 29, 2023
4ac815b
black badge + example fix
NicoRenaud Nov 29, 2023
7c31752
fix jastrow and backflow tutorials
NicoRenaud Nov 30, 2023
271cd33
add combine jastrow example
NicoRenaud Nov 30, 2023
5a06f7a
add test for orbital dependent jastrow
NicoRenaud Nov 30, 2023
b92f19f
default value for numorb for orbital dependent backflow
NicoRenaud Nov 30, 2023
7bb2a3a
nmo through calc
NicoRenaud Nov 30, 2023
f556604
fix nmo via basis
NicoRenaud Nov 30, 2023
c02b22e
nmo
NicoRenaud Nov 30, 2023
0a08ee0
test jastrow orb dependent skip a few
NicoRenaud Nov 30, 2023
327e07e
removed charge/spin from adf calculator
NicoRenaud Nov 30, 2023
2f4c361
clear up notenooks
NicoRenaud Dec 1, 2023
ece4225
clean notebooks
NicoRenaud Dec 4, 2023
5c0ae26
added doc on gh action
NicoRenaud Dec 4, 2023
4446122
added pandoc install
NicoRenaud Dec 4, 2023
64d48ea
add conda path
NicoRenaud Dec 4, 2023
43bb0f7
try without sphinx-action
NicoRenaud Dec 4, 2023
175c4c7
coverage
NicoRenaud Dec 4, 2023
66f22ab
fix yaml
NicoRenaud Dec 4, 2023
21fa673
revert to sphinx-action
NicoRenaud Dec 4, 2023
37bc31a
execute notebooks
NicoRenaud Dec 5, 2023
4579c48
removed h2 traj
NicoRenaud Dec 5, 2023
9b601d1
chagne nbexecute to never
NicoRenaud Dec 5, 2023
07e1442
added jupyter as dep
NicoRenaud Dec 5, 2023
fab56a9
introduce default jastrow as elec-elec pade jastrow
NicoRenaud Dec 5, 2023
e3900c9
default jastrow
NicoRenaud Dec 5, 2023
13ae24d
fix build file
NicoRenaud Dec 5, 2023
cc397de
updated rst in the doc
NicoRenaud Dec 5, 2023
6ebdd88
fix some docstrings
NicoRenaud Dec 5, 2023
7b9e026
fix foc
NicoRenaud Dec 5, 2023
a378c00
fix factorial2
NicoRenaud Dec 9, 2023
45f57ac
added 3.9 python in CI
NicoRenaud Dec 9, 2023
c85c62b
froze scipy
NicoRenaud Dec 9, 2023
53ff7e6
fix 2
NicoRenaud Dec 9, 2023
5c89bc7
Merge pull request #168 from NLESC-JCER/issue167
NicoRenaud Dec 11, 2023
bc50100
fux default jastrow on gpu
NicoRenaud Dec 11, 2023
46e191b
removed graph jastrow
NicoRenaud Dec 12, 2023
44648fa
removed graph jastrow test
NicoRenaud Dec 12, 2023
926a51e
Revert "removed graph jastrow test"
NicoRenaud Dec 12, 2023
43f466b
Revert "removed graph jastrow"
NicoRenaud Dec 12, 2023
af66f83
fix egnn
NicoRenaud Dec 4, 2024
f3fb795
fix merge conflicts
NicoRenaud Dec 20, 2024
5ab8a08
fix merg conflict
NicoRenaud Dec 20, 2024
dacd24c
fix last conflict
NicoRenaud Dec 20, 2024
1244a30
fx last comflic
NicoRenaud Dec 20, 2024
517dfce
remove graph jastrow
NicoRenaud Dec 20, 2024
860fcdb
remove dgl deps
NicoRenaud Dec 20, 2024
64fbff2
remove graph
NicoRenaud Dec 20, 2024
f85f1f2
fix test
NicoRenaud Dec 20, 2024
6b1149e
restrict to 3.8
NicoRenaud Dec 20, 2024
2c298ac
coday fix
NicoRenaud Dec 20, 2024
6dfa2a8
coday fix
NicoRenaud Dec 20, 2024
6432d04
Merge pull request #174 from NLESC-JCER/dev_update
NicoRenaud Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ['3.8', '3.10']
version: ['3.8']

steps:
- name: Cancel Previous Runs
Expand All @@ -27,23 +27,23 @@ jobs:
- name: Install essential
run: |
sudo apt update
sudo apt install build-essential
sudo apt install build-essential pandoc
- name: Install conda packages
run: |
conda install -c anaconda cmake
conda install mpi4py h5py pytorch==2.0.0 torchvision==0.15.0 cpuonly -c pytorch -c conda-forge
conda install rdkit mpi4py h5py pytorch==2.0.0 torchvision==0.15.0 cpuonly -c pytorch -c conda-forge
conda install -c conda-forge libstdcxx-ng
conda install -c anaconda gxx_linux-64

- name: Install the package
run: python -m pip install .[test,hpc]
run: python -m pip install .[test,hpc,doc]
env:
CONDA_PREFIX: /usr/share/miniconda

- name: Test with multithreading
env:
CONDA_PREFIX: /usr/share/miniconda
run: mpirun -np 2 coverage run -m pytest tests_hvd
# - name: Test with multithreading
# env:
# CONDA_PREFIX: /usr/share/miniconda
# run: mpirun -np 2 coverage run -m pytest tests_hvd

- name: Test with single thread
env:
Expand Down
1 change: 1 addition & 0 deletions .prospector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ pep257:
D212, # Multi-line docstring summary should start at the first line
D213, # Multi-line docstring summary should start at the second line
D404, # First word of the docstring should not be This
R0913, # too many arguments
]
26 changes: 26 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
Change Log
##########


0.4.0 [Unreleased]
******************

Change
---------

* Change sugnature of Jastrow and Baclflow modules (#174)
* Limit testing to Python 3.8 (#174)


0.3.3 [Released]
******************

Change
-----------

* Fig bug in the AO norm (#172)

0.3.2 [Released]
******************

Change
----------
* Fix a minor OSX bug regarding torch type cast to int

0.3.1 [Released]
*****************

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Pytorch Implementation of Real Space Quantum Monte Carlo Simulations of Molecula
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1c52407422a7428083968833341b5945)](https://app.codacy.com/gh/NLESC-JCER/QMCTorch/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3780094.svg)](https://doi.org/10.5281/zenodo.3780094)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.05472/status.svg)](https://doi.org/10.21105/joss.05472)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

## Installation

Expand Down
55 changes: 55 additions & 0 deletions bin/qmctorch_energy_plotter
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python
import h5py
import matplotlib.pyplot as plt
import argparse


def get_energy(mol):
with h5py.File(mol, 'r') as f5:
data = f5['wf_opt']['energy'][()]
return data


def get_correlation_energy(e, e0, ehf):
return 1 - (e-e0)/(ehf-e0)


def plot_percent_correlation_energy(args):

nepoch = args.num_epoch
energy = []
percent_correlation_energy = []
for mol in args.filename:
e = get_energy(mol)[:nepoch]
print(e[-1])
energy.append(e)
percent_correlation_energy.append(
get_correlation_energy(e, args.exact_energy, args.hf_energy))

plt_fn = plt.plot
if args.semi_logy:
plt_fn = plt.semilogy

for ec in percent_correlation_energy:
plt_fn(ec)
plt.show()


if __name__ == "__main__":

parser = argparse.ArgumentParser()
parser.add_argument('filename', nargs='+',
help='name of the files')
parser.add_argument('-l', '--labels', nargs='+',
help='label of the data')
parser.add_argument('-ne', '--num_epoch', type=int,
default=-1, help='Number of epcoh to plot')
parser.add_argument('-e0', '--exact_energy', type=float,
default=None, help='True exact energy of thre system')
parser.add_argument('-ehf', '--hf_energy', type=float,
default=None, help='Hartree Fock energy of thre system')
parser.add_argument('-log', '--semi_logy', action='store_true',
help='plot on semilog y axis')
args = parser.parse_args()

plot_percent_correlation_energy(args)
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,5 @@

autoclass_content = 'init'
autodoc_member_order = 'bysource'
nbsphinx_allow_errors = True
nbsphinx_allow_errors = True
nbsphinx_execute = 'never'
53 changes: 53 additions & 0 deletions docs/example/autocorrelation/h2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import torch
from torch import optim

from qmctorch.sampler import Metropolis
from qmctorch.scf import Molecule
from qmctorch.solver import Solver
from qmctorch.utils.plot_data import plot_correlation_coefficient, plot_integrated_autocorrelation_time
from qmctorch.wavefunction.slater_jastrow import SlaterJastrow
from qmctorch.wavefunction.jastrows.elec_elec import JastrowFactor, PadeJastrowKernel
torch.manual_seed(0)

# molecule
mol = Molecule(
atom='H 0 0 -0.69; H 0 0 0.69',
unit='bohr',
calculator='pyscf',
basis='sto-3g')


# jastrow
jastrow = JastrowFactor(mol, PadeJastrowKernel)

# wave funtion
wf = SlaterJastrow(mol, kinetic='auto',
jastrow=jastrow,
configs='single(2,2)')

# sampler
sampler = Metropolis(
nwalkers=10,
nstep=1000,
ntherm=0,
ndecor=1,
step_size=0.5,
ndim=wf.ndim,
nelec=wf.nelec,
init=mol.domain('normal'),
move={
'type': 'all-elec',
'proba': 'normal'})

opt = optim.Adam(wf.parameters(), lr=0.01)

solver = Solver(wf=wf, sampler=sampler, optimizer=opt)

pos = solver.sampler(wf.pdf)
obs = solver.sampling_traj(pos)

rho, tau = plot_correlation_coefficient(obs.local_energy)
print(f'fit exp(-x/tau), tau={tau}')
iat = plot_integrated_autocorrelation_time(
obs.local_energy, rho=rho, C=5)
print(f"integrated autocorrelation time: {iat}")
21 changes: 16 additions & 5 deletions docs/example/backflow/backflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
from torch import nn

from qmctorch.scf import Molecule

from qmctorch.wavefunction.orbitals.backflow import BackFlowTransformation
from qmctorch.wavefunction.orbitals.backflow.kernels import BackFlowKernelBase
from qmctorch.wavefunction import SlaterJastrowBackFlow


from qmctorch.wavefunction.slater_jastrow import SlaterJastrow
from qmctorch.wavefunction.jastrows.elec_elec import JastrowFactor, PadeJastrowKernel


class MyBackflow(BackFlowKernelBase):
Expand All @@ -25,11 +30,17 @@ def forward(self, x):
mol = Molecule(atom='Li 0. 0. 0.; H 3.14 0. 0.', unit='angs',
calculator='pyscf', basis='sto-3g', name='LiH')

# jastrow
jastrow = JastrowFactor(mol, PadeJastrowKernel)

# backflow
backflow = BackFlowTransformation(mol, MyBackflow, {'size': 64})

# define the wave function
wf = SlaterJastrowBackFlow(mol, kinetic='jacobi',
backflow_kernel=MyBackflow,
backflow_kernel_kwargs={'size': 64},
configs='single_double(2,2)')
wf = SlaterJastrow(mol, kinetic='jacobi',
jastrow=jastrow,
backflow=backflow,
configs='single_double(2,2)')

pos = torch.rand(10, wf.nelec*3)
print(wf(pos))
6 changes: 6 additions & 0 deletions docs/example/gpu/h2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from torch import optim

from qmctorch.scf import Molecule
from qmctorch.wavefunction.jastrows.elec_elec import JastrowFactor, PadeJastrowKernel
from qmctorch.wavefunction import SlaterJastrow
from qmctorch.solver import Solver
from qmctorch.sampler import Metropolis
Expand All @@ -20,9 +21,14 @@
basis='dzp',
unit='bohr')


# jastrow
jastrow = JastrowFactor(mol, PadeJastrowKernel)

# define the wave function
wf = SlaterJastrow(mol, kinetic='jacobi',
configs='cas(2,2)',
jastrow=jastrow,
cuda=True)

# sampler
Expand Down
4 changes: 2 additions & 2 deletions docs/example/horovod/h2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
set_torch_double_precision()

# define the molecule
mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69',
mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr',
calculator='pyscf', basis='sto-3g',
unit='bohr', rank=hvd.local_rank())
rank=hvd.local_rank(), mpi_size=hvd.local_size())


# define the wave function
Expand Down
47 changes: 28 additions & 19 deletions docs/example/optimization/h2.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@

import torch
import numpy as np
from torch import optim

from qmctorch.scf import Molecule
from qmctorch.wavefunction import SlaterJastrow

from qmctorch.solver import Solver
from qmctorch.sampler import Metropolis
from qmctorch.sampler import Metropolis, Hamiltonian
from qmctorch.utils import set_torch_double_precision
from qmctorch.utils import (plot_energy, plot_data)

from qmctorch.wavefunction.jastrows.elec_elec.kernels import PadeJastrowKernel
from qmctorch.utils.plot_data import (plot_energy, plot_data)
from qmctorch.wavefunction.slater_jastrow import SlaterJastrow
from qmctorch.wavefunction.jastrows.elec_elec import JastrowFactor, PadeJastrowKernel

# bond distance : 0.74 A -> 1.38 a
# optimal H positions +0.69 and -0.69
# ground state energy : -31.688 eV -> -1.16 hartree
# bond dissociation energy 4.478 eV -> 0.16 hartree

set_torch_double_precision()
torch.random.manual_seed(0)
np.random.seed(0)

# define the molecule
mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69',
calculator='pyscf',
basis='sto-3g',
unit='bohr')

# jastrow
jastrow = JastrowFactor(mol, PadeJastrowKernel)

# define the wave function
wf = SlaterJastrow(mol, kinetic='jacobi',
configs='single_double(2,2)',
jastrow_kernel=PadeJastrowKernel).gto2sto()
jastrow=jastrow)

# sampler
sampler = Metropolis(nwalkers=5000,
nstep=200, step_size=0.2,
ntherm=-1, ndecor=100,
nelec=wf.nelec, init=mol.domain('atomic'),
move={'type': 'all-elec', 'proba': 'normal'})
# sampler = Hamiltonian(nwalkers=100, nstep=100, nelec=wf.nelec,
# step_size=0.1, L=30,
# ntherm=-1, ndecor=10,
# init=mol.domain('atomic'))

sampler = Metropolis(nwalkers=10, nstep=200, nelec=wf.nelec, ntherm=100, ndecor=10,
step_size=0.05, init=mol.domain('atomic'))

# optimizer
lr_dict = [{'params': wf.jastrow.parameters(), 'lr': 1E-2},
Expand All @@ -46,23 +54,24 @@
scheduler = optim.lr_scheduler.StepLR(opt, step_size=10, gamma=0.90)

# QMC solver
solver = Solver(wf=wf, sampler=sampler,
optimizer=opt, scheduler=None)
solver = Solver(wf=wf, sampler=sampler, optimizer=opt, scheduler=None)

# perform a single point calculation
obs = solver.single_point()
# obs = solver.single_point()

# configure the solver
solver.configure(track=['local_energy', 'parameters'], freeze=['ao'],
loss='energy', grad='manual',
ortho_mo=False, clip_loss=False,
resampling={'mode': 'update',
'resample_every': 1,
'nstep_update': 25})
'nstep_update': 150,
'ntherm_update': 50}
)

# optimize the wave function
obs = solver.run(50)
obs = solver.run(5) # , batchsize=10)

# plot
plot_energy(obs.local_energy, e0=-1.1645, show_variance=True)
plot_data(solver.observable, obsname='jastrow.jastrow_kernel.weight')
# plot_energy(obs.local_energy, e0=-1.1645, show_variance=True)
# plot_data(solver.observable, obsname='jastrow.weight')
9 changes: 5 additions & 4 deletions docs/example/scf/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# Select the SCF calculator
calc = ['pyscf', # pyscf
'adf', # adf 2019
'adf2019' # adf 2020+
][0]
'adf', # adf 2020+
'adf2019' # adf 2019
][1]

# select an appropriate basis
basis = {
Expand All @@ -17,7 +17,8 @@
mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69',
calculator=calc,
basis=basis,
unit='bohr')
unit='bohr',
redo_scf=True)



Loading
Loading