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
Raw Normal View History

#!/usr/bin/env python3
2021-01-13 18:11:13 +01:00
from hydrogen import *
from qmc_stats import *
2021-01-29 13:23:00 +01:00
def MonteCarlo(a,dt,nmax):
sq_dt = np.sqrt(dt)
2021-01-13 18:11:13 +01:00
# 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))
2021-01-29 13:23:00 +01:00
r_new = r_old + dt * d_old + chi*sq_dt
2021-01-13 18:11:13 +01:00
N += 1.
E += e_loc(a,r_new)
r_old = r_new
return E/N
a = 1.2
2021-01-13 18:11:13 +01:00
nmax = 100000
2021-01-29 13:23:00 +01:00
dt = 0.2
X = [MonteCarlo(a,dt,nmax) for i in range(30)]
2021-01-13 18:11:13 +01:00
E, deltaE = ave_error(X)
print(f"E = {E} +/- {deltaE}")