2021-02-02 13:57:53 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
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):
|
2021-01-26 10:02:38 +01:00
|
|
|
energy = 0.
|
|
|
|
normalization = 0.
|
2021-01-29 13:23:00 +01:00
|
|
|
|
2021-01-12 01:01:52 +01:00
|
|
|
for istep in range(nmax):
|
|
|
|
r = np.random.uniform(-5., 5., (3))
|
2021-01-29 13:23:00 +01:00
|
|
|
|
2021-01-12 01:01:52 +01:00
|
|
|
w = psi(a,r)
|
|
|
|
w = w*w
|
2021-01-29 13:23:00 +01:00
|
|
|
|
|
|
|
energy += w * e_loc(a,r)
|
2021-01-26 10:02:38 +01:00
|
|
|
normalization += w
|
2021-01-07 10:01:55 +01:00
|
|
|
|
2021-01-29 13:23:00 +01:00
|
|
|
return energy / normalization
|
|
|
|
|
2021-02-02 13:57:53 +01:00
|
|
|
a = 1.2
|
2021-01-12 01:01:52 +01:00
|
|
|
nmax = 100000
|
2021-01-29 13:23:00 +01:00
|
|
|
|
2021-01-12 01:01:52 +01:00
|
|
|
X = [MonteCarlo(a,nmax) for i in range(30)]
|
|
|
|
E, deltaE = ave_error(X)
|
2021-01-29 13:23:00 +01:00
|
|
|
|
2021-01-12 01:01:52 +01:00
|
|
|
print(f"E = {E} +/- {deltaE}")
|