Finally, the right values for velocity distributions
This commit is contained in:
parent
20f15fb239
commit
cf4488976a
3 changed files with 44 additions and 90 deletions
|
|
@ -67,19 +67,20 @@ MODULE moduleRandom
|
|||
end function randomMaxwellian
|
||||
|
||||
!Returns a random number in a Maxwellian distribution of mean 0 and width 1
|
||||
FUNCTION randomHalfMaxwellian() RESULT(rnd)
|
||||
function randomHalfMaxwellian() result(rnd)
|
||||
IMPLICIT NONE
|
||||
|
||||
REAL(8):: rnd
|
||||
REAL(8):: x
|
||||
real(8):: rnd
|
||||
real(8):: v1
|
||||
|
||||
rnd = 0.D0
|
||||
x = 0.D0
|
||||
DO WHILE (x == 0.D0)
|
||||
CALL RANDOM_NUMBER(x)
|
||||
END DO
|
||||
v1 = 0.D0
|
||||
do while (v1 == 0.D0)
|
||||
v1 = random()
|
||||
|
||||
end do
|
||||
|
||||
rnd = DSQRT(-DLOG(x))
|
||||
rnd = sqrt(-2.d0*log(v1))
|
||||
|
||||
END FUNCTION randomHalfMaxwellian
|
||||
|
||||
|
|
|
|||
|
|
@ -53,12 +53,11 @@ module velocityDistribution
|
|||
function randomVelMaxwellian(self) result (v)
|
||||
use moduleRandom
|
||||
implicit none
|
||||
|
||||
class(velDistMaxwellian), intent(in):: self
|
||||
real(8):: v
|
||||
v = 0.D0
|
||||
|
||||
v = self%vTh*randomMaxwellian()/sqrt(2.d0)
|
||||
v = self%vTh*randomMaxwellian()
|
||||
|
||||
end function randomVelMaxwellian
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue