1
0
mirror of https://github.com/TREX-CoE/qmc-lttc.git synced 2024-11-09 23:54:04 +01:00
qmc-lttc/vmc.py
2021-01-29 13:23:00 +01:00

28 lines
588 B
Python

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 = 0.9
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}")