1
0
mirror of https://github.com/TREX-CoE/qmc-lttc.git synced 2024-10-30 10:48:36 +01:00
qmc-lttc/vmc.py

30 lines
612 B
Python

#!/usr/bin/env python3
from hydrogen import *
from qmc_stats import *
def MonteCarlo(a,dt,nmax):
sq_dt = np.sqrt(dt)
# Initialization
E = 0.
N = 0.
r_old = np.random.normal(loc=0., scale=1.0, size=(3))
for istep in range(nmax):
d_old = drift(a,r_old)
chi = np.random.normal(loc=0., scale=1.0, size=(3))
r_new = r_old + dt * d_old + chi*sq_dt
N += 1.
E += e_loc(a,r_new)
r_old = r_new
return E/N
a = 1.2
nmax = 100000
dt = 0.2
X = [MonteCarlo(a,dt,nmax) for i in range(30)]
E, deltaE = ave_error(X)
print(f"E = {E} +/- {deltaE}")