1
0
mirror of https://github.com/TREX-CoE/qmc-lttc.git synced 2024-07-03 09:56:12 +02:00
qmc-lttc/qmc_uniform.py

20 lines
400 B
Python
Raw Normal View History

2021-01-07 10:01:55 +01:00
from hydrogen import *
from qmc_stats import *
2021-01-12 01:01:52 +01:00
def MonteCarlo(a, nmax):
E = 0.
N = 0.
for istep in range(nmax):
r = np.random.uniform(-5., 5., (3))
w = psi(a,r)
w = w*w
N += w
E += w * e_loc(a,r)
return E/N
2021-01-07 10:01:55 +01:00
2021-01-12 01:01:52 +01:00
a = 0.9
nmax = 100000
X = [MonteCarlo(a,nmax) for i in range(30)]
E, deltaE = ave_error(X)
print(f"E = {E} +/- {deltaE}")