Skip to content

Commit 5cc1bef

Browse files
authored
Add files via upload
Correct the random selection of partner particle in swap update
1 parent ca2d227 commit 5cc1bef

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

vpi_mod.f90

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,7 @@ subroutine Swap(trap,LogWF,VTable,dt,Lmax,iw,Path,xend,accepted,ipar,&
22782278
real (kind=8) :: DeltaS,SumDeltaS
22792279
real (kind=8) :: rij2
22802280
real (kind=8) :: Sk,Sw
2281+
real (kind=8) :: uran,sum
22812282
integer (kind=4) :: iit
22822283
integer (kind=4) :: ip,ib,k,accepted
22832284
integer (kind=4) :: j,ik,iw,ipar
@@ -2326,25 +2327,22 @@ subroutine Swap(trap,LogWF,VTable,dt,Lmax,iw,Path,xend,accepted,ipar,&
23262327
Sw = Sw+Pp(ip)
23272328

23282329
end do
2329-
2330+
23302331
!Selecting a random particle according to the probabilities that
23312332
!we have defined above
23322333

2333-
iit = 0
2334+
uran = grnd()
2335+
ip = 0
23342336

2335-
do
2336-
iit = iit+1
2337-
ip = int(Np*grnd())+1
2338-
if (grnd() <= Pp(ip)/Sw) then
2337+
do
2338+
ip = ip+1
2339+
sum = sum+Pp(ip)/Sw
2340+
if (uran <= sum) then
23392341
ik = ip
23402342
exit
23412343
end if
2342-
if (iit>10000) then
2343-
ik = iw
2344-
exit
2345-
end if
23462344
end do
2347-
2345+
23482346
!Check if the chosen partner is different from the Worm itself,
23492347
!otherwise the update is automatically rejected.
23502348

@@ -2467,7 +2465,6 @@ subroutine Swap(trap,LogWF,VTable,dt,Lmax,iw,Path,xend,accepted,ipar,&
24672465
swap_accepted = .true.
24682466
ipar = ik
24692467

2470-
!stop
24712468
else
24722469

24732470
do ib=0,2*Nb

0 commit comments

Comments
 (0)