Skip to content

Commit

Permalink
fix walker init on atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoRenaud committed Apr 29, 2020
1 parent d1a18ff commit a483ece
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Pytorch Implementation of Real Space Quantum Monte Carlo Simulations of Molecula
## Documentation
https://qmctorch.readthedocs.io/en/latest/intro.html


<!--
## Introduction
QMCTorch allows to leverage deep learning to optimize QMC wave functions. The package offers solutions to optimize particle-in-a-box model as well as molecular systems. It uses `pytorch` as a deep learning framework and `pyscf` or `adf` to obtain the basis set information and the first guess of the molecular orbitals.
Expand Down Expand Up @@ -128,4 +130,4 @@ Note that comfiguring the solver to perform a geometry optimization is done in o
<p align="center">
<img src="./pics/h2o.gif" title="Wave function Ooptimization of a H2 molecule">
</p>
</p> -->
4 changes: 2 additions & 2 deletions qmctorch/sampler/walkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _init_center(self):
Returns:
torch.tensor: positions of the walkers
"""
eps = 1E-6
eps = 1E-3
pos = -eps + 2 * eps * \
torch.rand(self.nwalkers, self.nelec * self.ndim)
return pos.type(
Expand Down Expand Up @@ -131,7 +131,7 @@ def _init_atomic(self):
elif nelec_placed[_idx] < 5:
s = 2. / (self.init_domain['atom_num'][_idx] - 2)
else:
s = 3. / (self.init_domain['atom_num'][_idx] - 10)
s = 3. / (self.init_domain['atom_num'][_idx] - 3)
xyz[ielec,
:] += np.random.normal(scale=s, size=(1, 3))
nelec_placed[_idx] += 1
Expand Down
25 changes: 16 additions & 9 deletions qmctorch/utils/plot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def plot_data(observable, obsname):
plt.show()


def plot_walkers_traj(eloc, traj_index='all'):
def plot_walkers_traj(eloc, walkers='mean'):
"""Plot the trajectory of all the individual walkers
Args:
obs (SimpleNamespace): Namespace of the observables
traj_index (int, str, optional): all or index of a given walker Defaults to 'all'
walkers (int, str, optional): all, mean or index of a given walker Defaults to 'all'
Returns:
float : Decorelation time
Expand All @@ -97,21 +97,28 @@ def plot_walkers_traj(eloc, traj_index='all'):

Tc = (var_decor / var)**2

if traj_index is not None:
plt.subplot(1, 2, 1)

if traj_index == 'all':
if walkers is not None:
# plt.subplot(1, 2, 1)

if walkers == 'all':
plt.plot(eloc, 'o', alpha=1 / nwalkers, c='grey')
cmap = cm.hot(np.linspace(0, 1, nwalkers))
for i in range(nwalkers):
plt.plot(celoc.T[:, i], color=cmap[i])

elif walkers == 'mean':
plt.plot(eloc, 'o', alpha=1 / nwalkers, c='grey')
plt.plot(np.mean(celoc.T, axis=1), linewidth=5)

else:
plt.plot(eloc[traj_index, :], 'o',
plt.plot(eloc[walkers, :], 'o',
alpha=1 / nwalkers, c='grey')
plt.plot(celoc.T[traj_index, :])
plt.subplot(1, 2, 2)
plt.hist(Tc)
plt.grid()
plt.xlabel('Monte Carlo Steps')
plt.ylabel('Energy (Hartree)')
# plt.subplot(1, 2, 2)
# plt.hist(Tc)

plt.show()

Expand Down

0 comments on commit a483ece

Please sign in to comment.