1
0
mirror of https://github.com/TREX-CoE/qmc-lttc.git synced 2024-11-09 07:34:00 +01:00
qmc-lttc/qmc_uniform.f90

42 lines
956 B
Fortran
Raw Normal View History

2021-01-07 10:01:55 +01:00
subroutine uniform_montecarlo(a,nmax,energy)
implicit none
double precision, intent(in) :: a
integer , intent(in) :: nmax
double precision, intent(out) :: energy
integer*8 :: istep
double precision :: norm, r(3), w
double precision, external :: e_loc, psi
energy = 0.d0
norm = 0.d0
do istep = 1,nmax
call random_number(r)
r(:) = -5.d0 + 10.d0*r(:)
w = psi(a,r)
w = w*w
norm = norm + w
energy = energy + w * e_loc(a,r)
end do
energy = energy / norm
end subroutine uniform_montecarlo
program qmc
implicit none
double precision, parameter :: a = 0.9
integer , parameter :: nmax = 100000
integer , parameter :: nruns = 30
integer :: irun
double precision :: X(nruns)
double precision :: ave, err
do irun=1,nruns
call uniform_montecarlo(a,nmax,X(irun))
enddo
call ave_error(X,nruns,ave,err)
print *, 'E = ', ave, '+/-', err
end program qmc