Implementation of different distribution functions for velocities.
Maxwellian and Diract Delta distributions have been implemented. The input for injection of particles should be rewritten to allow more clear input file.
This commit is contained in:
parent
af74205932
commit
37b0139b1f
37 changed files with 252 additions and 5497 deletions
|
|
@ -1,21 +1,63 @@
|
|||
!injection of particles
|
||||
MODULE moduleInject
|
||||
|
||||
!Generic type for velocity distribution function
|
||||
TYPE, ABSTRACT:: velDistGeneric
|
||||
CONTAINS
|
||||
!Returns random velocity from distribution function
|
||||
PROCEDURE(randomVel_interface), DEFERRED, PASS:: randomVel
|
||||
|
||||
END TYPE velDistGeneric
|
||||
|
||||
ABSTRACT INTERFACE
|
||||
FUNCTION randomVel_interface(self) RESULT(v)
|
||||
IMPORT velDistGeneric
|
||||
|
||||
CLASS(velDistGeneric), INTENT(in):: self
|
||||
REAL(8):: v
|
||||
|
||||
END FUNCTION randomVel_interface
|
||||
|
||||
END INTERFACE
|
||||
|
||||
!Container for velocity distributions
|
||||
TYPE:: velDistCont
|
||||
CLASS(velDistGeneric), ALLOCATABLE:: obj
|
||||
|
||||
END TYPE velDistCont
|
||||
|
||||
!Maxwellian distribution function
|
||||
TYPE, EXTENDS(velDistGeneric):: velDistMaxwellian
|
||||
REAL(8):: v !Velocity
|
||||
REAL(8):: vTh !Thermal Velocity
|
||||
CONTAINS
|
||||
PROCEDURE, PASS:: randomVel => randomVelMaxwellian
|
||||
|
||||
END TYPE velDistMaxwellian
|
||||
|
||||
!Dirac's delta distribution function
|
||||
TYPE, EXTENDS(velDistGeneric):: velDistDelta
|
||||
REAL(8):: v !Velocity
|
||||
CONTAINS
|
||||
PROCEDURE, PASS:: randomVel => randomVelDelta
|
||||
|
||||
END TYPE velDistDelta
|
||||
|
||||
!Generic injection of particles
|
||||
TYPE:: injectGeneric
|
||||
INTEGER:: id
|
||||
CHARACTER(:), ALLOCATABLE:: name
|
||||
REAL(8):: vMod !Velocity (module)
|
||||
REAL(8):: T(1:3) !Temperature
|
||||
REAL(8):: v(1:3) !Velocity(vector)
|
||||
REAL(8):: vTh(1:3) !Thermal Velocity
|
||||
REAL(8):: n(1:3) !Direction of injection
|
||||
INTEGER:: nParticles !Number of particles to introduce each time step
|
||||
INTEGER:: sp !Species of injection
|
||||
INTEGER:: nEdges
|
||||
INTEGER, ALLOCATABLE:: edges(:) !Array with edges
|
||||
TYPE(velDistCont):: v(1:3) !Velocity distribution function in each direction
|
||||
CONTAINS
|
||||
PROCEDURE, PASS:: init => initInject
|
||||
PROCEDURE, PASS:: addParticles => addParticlesMaxwellian
|
||||
PROCEDURE, PASS:: addParticles
|
||||
|
||||
END TYPE injectGeneric
|
||||
|
||||
|
|
@ -64,9 +106,6 @@ MODULE moduleInject
|
|||
self%nParticles = self%nParticles * solver%pusher(sp)%every
|
||||
self%sp = sp
|
||||
|
||||
self%v = self%vMod * self%n
|
||||
self%vTh = DSQRT(self%T/species(self%sp)%obj%m)
|
||||
|
||||
!Gets the edge elements from which particles are injected
|
||||
!TODO: Improve this A LOT
|
||||
DO e = 1, mesh%numEdges
|
||||
|
|
@ -88,7 +127,7 @@ MODULE moduleInject
|
|||
END DO
|
||||
! self%sumWeight = SUM(self%weight)
|
||||
|
||||
END SUBROUTINE
|
||||
END SUBROUTINE initInject
|
||||
|
||||
!Injection of particles
|
||||
SUBROUTINE doInjects()
|
||||
|
|
@ -114,12 +153,35 @@ MODULE moduleInject
|
|||
|
||||
END SUBROUTINE doInjects
|
||||
|
||||
!Random velocity from maxwellian distribution
|
||||
REAL(8) FUNCTION vBC(u, vth)
|
||||
SUBROUTINE initVelDistMaxwellian(velDist, v, T, m)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(velDistGeneric), ALLOCATABLE, INTENT(out):: velDist
|
||||
REAL(8), INTENT(in):: v, T, m
|
||||
|
||||
velDist = velDistMaxwellian(v = v, vTh = DSQRT(T/m))
|
||||
|
||||
END SUBROUTINE initVelDistMaxwellian
|
||||
|
||||
SUBROUTINE initVelDistDelta(velDist, v)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(velDistGeneric), ALLOCATABLE, INTENT(out):: velDist
|
||||
REAL(8), INTENT(in):: v
|
||||
|
||||
velDist = velDistDelta(v = v)
|
||||
|
||||
END SUBROUTINE initVelDistDelta
|
||||
|
||||
!Random velocity from Maxwellian distribution
|
||||
FUNCTION randomVelMaxwellian(self) RESULT (v)
|
||||
USE moduleConstParam, ONLY: PI
|
||||
REAL(8), INTENT (in):: u, vth
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(velDistMaxwellian), INTENT(in):: self
|
||||
REAL(8):: v
|
||||
REAL(8):: x, y
|
||||
vBC=0.D0
|
||||
v = 0.D0
|
||||
x = 0.D0
|
||||
|
||||
DO WHILE (x == 0.D0)
|
||||
|
|
@ -127,11 +189,23 @@ MODULE moduleInject
|
|||
END DO
|
||||
CALL RANDOM_NUMBER(y)
|
||||
|
||||
vBC = u + vth*DSQRT(-2.D0*DLOG(x))*DCOS(2.D0*PI*y)
|
||||
v = self%v + self%vTh*DSQRT(-2.D0*DLOG(x))*DCOS(2.D0*PI*y)
|
||||
|
||||
END FUNCTION vBC
|
||||
END FUNCTION randomVelMaxwellian
|
||||
|
||||
SUBROUTINE addParticlesMaxwellian(self)
|
||||
!Random velocity from Dirac's delta distribution
|
||||
PURE FUNCTION randomVelDelta(self) RESULT(v)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(velDistDelta), INTENT(in):: self
|
||||
REAL(8):: v
|
||||
|
||||
v = self%v
|
||||
|
||||
END FUNCTION randomVelDelta
|
||||
|
||||
!Add particles for the injection
|
||||
SUBROUTINE addParticles(self)
|
||||
USE moduleSpecies
|
||||
USE moduleSolver
|
||||
USE moduleMesh
|
||||
|
|
@ -185,9 +259,9 @@ MODULE moduleInject
|
|||
|
||||
END IF
|
||||
|
||||
partInj(n)%v = (/ vBC(self%v(1), self%vTh(1)), &
|
||||
vBC(self%v(2), self%vTh(2)), &
|
||||
vBC(self%v(3), self%vTh(3)) /)
|
||||
partInj(n)%v = (/ self%v(1)%obj%randomVel(), &
|
||||
self%v(2)%obj%randomVel(), &
|
||||
self%v(3)%obj%randomVel() /)
|
||||
|
||||
!Push new particle
|
||||
CALL solver%pusher(self%sp)%pushParticle(partInj(n))
|
||||
|
|
@ -197,6 +271,6 @@ MODULE moduleInject
|
|||
END DO
|
||||
!$OMP END DO
|
||||
|
||||
END SUBROUTINE addParticlesMaxwellian
|
||||
END SUBROUTINE addParticles
|
||||
|
||||
END MODULE moduleInject
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue