Change in injection to achieve uniform density of particles. #50
1 changed files with 13 additions and 2 deletions
Quick because food
Cartesian fixed now
commit
6389c8ba2d
|
|
@ -73,10 +73,21 @@ MODULE moduleRandom
|
||||||
REAL(8), INTENT(in):: cumWeight(1:)
|
REAL(8), INTENT(in):: cumWeight(1:)
|
||||||
REAL(8), INTENT(in):: sumWeight
|
REAL(8), INTENT(in):: sumWeight
|
||||||
REAL(8):: rnd0b
|
REAL(8):: rnd0b
|
||||||
INTEGER:: rnd
|
INTEGER:: rnd, i
|
||||||
|
|
||||||
rnd0b = random(0.D0, sumWeight)
|
rnd0b = random(0.D0, sumWeight)
|
||||||
rnd = MINLOC(DABS(rnd0b - cumWeight), 1)
|
i = 1
|
||||||
|
DO
|
||||||
|
IF (rnd0b <= cumWeight(i)) THEN
|
||||||
|
rnd = i
|
||||||
|
EXIT
|
||||||
|
|
||||||
|
ELSE
|
||||||
|
i = i +1
|
||||||
|
|
||||||
|
END IF
|
||||||
|
END DO
|
||||||
|
! rnd = MINLOC(DABS(rnd0b - cumWeight), 1)
|
||||||
|
|
||||||
END FUNCTION randomWeighted
|
END FUNCTION randomWeighted
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue