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
|
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
|
!Returns a random number weighted with the cumWeight array
|
||||||
FUNCTION randomWeighted(cumWeight, sumWeight) RESULT(rnd)
|
FUNCTION randomWeighted(cumWeight, sumWeight) RESULT(rnd)
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
|
||||||
|
|
@ -298,10 +298,7 @@ MODULE moduleInject
|
||||||
REAL(8):: v
|
REAL(8):: v
|
||||||
v = 0.D0
|
v = 0.D0
|
||||||
|
|
||||||
DO WHILE (v <= 0.D0)
|
v = self%vTh*randomHalfMaxwellian()
|
||||||
v = self%vTh*randomMaxwellian()
|
|
||||||
|
|
||||||
END DO
|
|
||||||
|
|
||||||
END FUNCTION randomVelHalfMaxwellian
|
END FUNCTION randomVelHalfMaxwellian
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue