Split velocity distribution function. Still don't know how to deal with injects
This commit is contained in:
parent
7535f5aaaa
commit
21b112a591
4 changed files with 94 additions and 85 deletions
|
|
@ -1,6 +1,7 @@
|
|||
OBJS = moduleCompTime.o moduleCaseParam.o moduleConstParam.o \
|
||||
moduleErrors.o moduleMath.o moduleParallel.o \
|
||||
moduleRandom.o moduleRefParam.o moduleTable.o
|
||||
moduleRandom.o moduleRefParam.o moduleTable.o \
|
||||
velocityDistribution.o
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
|||
88
src/modules/common/velocityDistribution.f90
Normal file
88
src/modules/common/velocityDistribution.f90
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
! Functions that return a random velocity based on the distribution function
|
||||
module velocityDistribution
|
||||
use moduleRandom
|
||||
!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):: vTh !Thermal Velocity
|
||||
contains
|
||||
procedure, pass:: randomVel => randomVelMaxwellian
|
||||
|
||||
end type velDistMaxwellian
|
||||
|
||||
type, extends(velDistGeneric):: velDistHalfMaxwellian
|
||||
real(8):: vTh !Thermal Velocity
|
||||
contains
|
||||
procedure, pass:: randomVel => randomVelHalfMaxwellian
|
||||
|
||||
end type velDistHalfMaxwellian
|
||||
|
||||
!Dirac's delta distribution function
|
||||
type, extends(velDistGeneric):: velDistDelta
|
||||
contains
|
||||
procedure, pass:: randomVel => randomVelDelta
|
||||
|
||||
end type velDistDelta
|
||||
|
||||
contains
|
||||
!Random velocity from Maxwellian distribution
|
||||
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)
|
||||
|
||||
end function randomVelMaxwellian
|
||||
|
||||
!Random velocity from Half Maxwellian distribution
|
||||
function randomVelHalfMaxwellian(self) result (v)
|
||||
implicit none
|
||||
|
||||
class(velDistHalfMaxwellian), intent(in):: self
|
||||
real(8):: v
|
||||
v = 0.D0
|
||||
|
||||
v = self%vTh*randomHalfMaxwellian()
|
||||
|
||||
end function randomVelHalfMaxwellian
|
||||
|
||||
!Random velocity from Dirac's delta distribution
|
||||
PURE function randomVelDelta(self) result(v)
|
||||
implicit none
|
||||
|
||||
class(velDistDelta), intent(in):: self
|
||||
real(8):: v
|
||||
|
||||
v = 0.D0
|
||||
|
||||
end function randomVelDelta
|
||||
|
||||
end module velocityDistribution
|
||||
|
|
@ -35,6 +35,9 @@ moduleProbe.o: mesh.o moduleProbe.f90
|
|||
moduleSpecies.o: common.o moduleSpecies.f90
|
||||
$(FC) $(FCFLAGS) -c $(subst .o,.f90,$@) -o $(OBJDIR)/$@
|
||||
|
||||
moduleInject.o: common.o moduleInject.f90
|
||||
$(FC) $(FCFLAGS) -c $(subst .o,.f90,$@) -o $(OBJDIR)/$@
|
||||
|
||||
%.o: %.f90
|
||||
$(FC) $(FCFLAGS) -c $< -o $(OBJDIR)/$@
|
||||
|
||||
|
|
|
|||
|
|
@ -1,53 +1,7 @@
|
|||
!injection of particles
|
||||
MODULE moduleInject
|
||||
USE moduleSpecies
|
||||
|
||||
!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):: vTh !Thermal Velocity
|
||||
CONTAINS
|
||||
PROCEDURE, PASS:: randomVel => randomVelMaxwellian
|
||||
|
||||
END TYPE velDistMaxwellian
|
||||
|
||||
TYPE, EXTENDS(velDistGeneric):: velDistHalfMaxwellian
|
||||
REAL(8):: vTh !Thermal Velocity
|
||||
CONTAINS
|
||||
PROCEDURE, PASS:: randomVel => randomVelHalfMaxwellian
|
||||
|
||||
END TYPE velDistHalfMaxwellian
|
||||
|
||||
!Dirac's delta distribution function
|
||||
TYPE, EXTENDS(velDistGeneric):: velDistDelta
|
||||
CONTAINS
|
||||
PROCEDURE, PASS:: randomVel => randomVelDelta
|
||||
|
||||
END TYPE velDistDelta
|
||||
use velocityDistribution
|
||||
|
||||
!Generic injection of particles
|
||||
TYPE:: injectGeneric
|
||||
|
|
@ -280,43 +234,6 @@ MODULE moduleInject
|
|||
|
||||
END SUBROUTINE initVelDistDelta
|
||||
|
||||
!Random velocity from Maxwellian distribution
|
||||
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)
|
||||
|
||||
END FUNCTION randomVelMaxwellian
|
||||
|
||||
!Random velocity from Half Maxwellian distribution
|
||||
FUNCTION randomVelHalfMaxwellian(self) RESULT (v)
|
||||
USE moduleRandom
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(velDistHalfMaxwellian), INTENT(in):: self
|
||||
REAL(8):: v
|
||||
v = 0.D0
|
||||
|
||||
v = self%vTh*randomHalfMaxwellian()
|
||||
|
||||
END FUNCTION randomVelHalfMaxwellian
|
||||
|
||||
!Random velocity from Dirac's delta distribution
|
||||
PURE FUNCTION randomVelDelta(self) RESULT(v)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(velDistDelta), INTENT(in):: self
|
||||
REAL(8):: v
|
||||
|
||||
v = 0.D0
|
||||
|
||||
END FUNCTION randomVelDelta
|
||||
|
||||
!Add particles for the injection
|
||||
SUBROUTINE addParticles(self)
|
||||
USE moduleSpecies
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue