10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-11-06 22:23:39 +01:00
qmcchem/src/SAMPLING/reconfigure.irp.f

92 lines
1.9 KiB
FortranFixed
Raw Normal View History

2015-12-20 00:54:56 +01:00
subroutine reconfigure(ipos,w)
implicit none
integer, intent(inout) :: ipos(*)
double precision, intent(in) :: w(*)
integer :: kptab(walk_num), kmtab(walk_num)
double precision :: wp(walk_num), wm(walk_num)
double precision :: tmp
2016-01-14 13:07:44 +01:00
double precision :: dwalk_num
tmp = 0.d0
2015-12-20 00:54:56 +01:00
do k=1,walk_num
ipos(k) = k
2016-01-14 13:07:44 +01:00
tmp = tmp + w(k)
2015-12-20 00:54:56 +01:00
enddo
2016-01-14 13:07:44 +01:00
dwalk_num = dble(walk_num)/tmp
2015-12-20 00:54:56 +01:00
2016-01-14 13:07:44 +01:00
integer :: kp, km
2015-12-20 00:54:56 +01:00
kp=0
km=0
2016-01-14 13:07:44 +01:00
double precision :: accup, accum
2015-12-20 00:54:56 +01:00
accup = 0.d0
accum = 0.d0
2016-01-14 13:07:44 +01:00
integer :: k
2015-12-20 00:54:56 +01:00
do k=1,walk_num
tmp = dwalk_num*w(k)-1.d0
if (tmp >= 0.d0) then
2016-01-14 13:07:44 +01:00
kp = kp+1
wp(kp) = dabs(tmp)
accup = accup + wp(kp)
2015-12-20 00:54:56 +01:00
kptab(kp) = k
else
2016-01-14 13:07:44 +01:00
km = km+1
wm(km) = dabs(tmp)
accum = accum + wm(km)
2015-12-20 00:54:56 +01:00
kmtab(km) = k
endif
enddo
2016-01-14 13:07:44 +01:00
2015-12-20 00:54:56 +01:00
if(kp+km /= walk_num) then
print *, kp, km
call abrt(irp_here,'pb in reconfiguration +/-')
endif
2016-01-14 13:07:44 +01:00
if(dabs(accup-accum) > 1.d-11) then
2015-12-20 00:54:56 +01:00
print *, accup, accum
call abrt(irp_here,'pb in reconfiguration')
endif
double precision :: qmc_ranf, rand
double precision :: rando(walk_num)
rand = qmc_ranf()
do k=1,walk_num
rando(k) = dble(k-1)+rand
enddo
double precision :: averageconf, current
integer :: kcp
integer :: kadd, kremove
averageconf = accup
kcp = 1
rand = rando(kcp)
2016-01-14 13:07:44 +01:00
2015-12-20 00:54:56 +01:00
do while (rand < averageconf)
k=1
current=wm(k)
do while (rand > current)
2016-01-14 13:07:44 +01:00
k = k+1
current = current + wm(k)
2015-12-20 00:54:56 +01:00
enddo
kremove = kmtab(k)
k=1
current=wp(k)
do while (rand > current)
2016-01-14 13:07:44 +01:00
k = k+1
current = current + wp(k)
2015-12-20 00:54:56 +01:00
enddo
kadd = kptab(k)
2016-01-14 13:07:44 +01:00
2015-12-20 00:54:56 +01:00
ipos(kremove) = kadd
2016-01-14 13:07:44 +01:00
kcp = kcp + 1
2015-12-20 00:54:56 +01:00
rand = rando(kcp)
enddo
end