Fix injection
Half-Maxwellian distribution should inject particles correctly
This commit is contained in:
parent
a2f9957f32
commit
7f73b69dc2
2 changed files with 18 additions and 4 deletions
|
|
@ -66,6 +66,23 @@ MODULE moduleRandom
|
|||
|
||||
END FUNCTION randomMaxwellian
|
||||
|
||||
!Returns a random number in a Maxwellian distribution of mean 0 and width 1
|
||||
FUNCTION randomHalfMaxwellian() RESULT(rnd)
|
||||
IMPLICIT NONE
|
||||
|
||||
REAL(8):: rnd
|
||||
REAL(8):: x
|
||||
|
||||
rnd = 0.D0
|
||||
x = 0.D0
|
||||
DO WHILE (x == 0.D0)
|
||||
CALL RANDOM_NUMBER(x)
|
||||
END DO
|
||||
|
||||
rnd = DSQRT(-DLOG(x))
|
||||
|
||||
END FUNCTION randomHalfMaxwellian
|
||||
|
||||
!Returns a random number weighted with the cumWeight array
|
||||
FUNCTION randomWeighted(cumWeight, sumWeight) RESULT(rnd)
|
||||
IMPLICIT NONE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue