Final implementation of ionization process by electron impact.
Possibility to input initial species distributions (density, velocity
and temperature) via an input file for each species.
New moduleRandom includes function to generate random numbers in
different ways (still uses) the implicit RANDOM_NUMBER().
This commit is contained in:
parent
e50cc3325b
commit
9e0d1a7cc7
16 changed files with 363 additions and 86 deletions
69
src/modules/moduleRandom.f90
Normal file
69
src/modules/moduleRandom.f90
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
MODULE moduleRandom
|
||||
!Interface for random number generator
|
||||
INTERFACE random
|
||||
MODULE PROCEDURE randomReal, randomRealAB, randomIntAB
|
||||
|
||||
END INTERFACE random
|
||||
|
||||
CONTAINS
|
||||
!Returns a Real random number between 0 and 1
|
||||
FUNCTION randomReal() RESULT(rnd)
|
||||
IMPLICIT NONE
|
||||
|
||||
REAL(8):: rnd
|
||||
|
||||
rnd = 0.D0
|
||||
CALL RANDOM_NUMBER(rnd)
|
||||
|
||||
END FUNCTION randomReal
|
||||
|
||||
!Returns a Real random number between a and b
|
||||
FUNCTION randomRealAB(a, b) RESULT(rnd)
|
||||
IMPLICIT NONE
|
||||
|
||||
REAL(8), INTENT(in):: a, b
|
||||
REAL(8):: rnd
|
||||
REAL(8):: rnd01 !random real between 0 and 1
|
||||
|
||||
rnd = 0.D0
|
||||
CALL RANDOM_NUMBER(rnd01)
|
||||
|
||||
rnd = (b - a) * rnd01 + a
|
||||
|
||||
END FUNCTION randomRealAB
|
||||
|
||||
!Returns an Integer random numnber between a and b
|
||||
FUNCTION randomIntAB(a, b) RESULT(rnd)
|
||||
IMPLICIT NONE
|
||||
|
||||
INTEGER, INTENT(in):: a, b
|
||||
INTEGER:: rnd
|
||||
REAL(8):: rnd01
|
||||
|
||||
rnd = 0.D0
|
||||
CALL RANDOM_NUMBER(rnd01)
|
||||
|
||||
rnd = INT(REAL(b - a) * rnd01) + 1
|
||||
|
||||
END FUNCTION randomIntAB
|
||||
|
||||
!Returns a random number in a Maxwellian distribution of mean 0 and width 1
|
||||
FUNCTION randomMaxwellian() RESULT(rnd)
|
||||
USE moduleConstParam, ONLY: PI
|
||||
IMPLICIT NONE
|
||||
|
||||
REAL(8):: rnd
|
||||
REAL(8):: x, y
|
||||
|
||||
rnd = 0.D0
|
||||
x = 0.D0
|
||||
DO WHILE (x == 0.D0)
|
||||
CALL RANDOM_NUMBER(x)
|
||||
END DO
|
||||
CALL RANDOM_NUMBER(y)
|
||||
|
||||
rnd = DSQRT(-2.D0*DLOG(x))*DCOS(2.D0*PI*y)
|
||||
|
||||
END FUNCTION randomMaxwellian
|
||||
|
||||
END MODULE moduleRandom
|
||||
Loading…
Add table
Add a link
Reference in a new issue