Implementing output for injects. Cleaning code
This commit is contained in:
parent
f400bd46eb
commit
04cd9dffc6
10 changed files with 283 additions and 169 deletions
|
|
@ -72,7 +72,7 @@ PROGRAM fpakc
|
||||||
call boundariesEM_update()
|
call boundariesEM_update()
|
||||||
|
|
||||||
! Update injects
|
! Update injects
|
||||||
call updateInjects
|
call updateInjects()
|
||||||
|
|
||||||
!Checks if a species needs to me moved in this iteration
|
!Checks if a species needs to me moved in this iteration
|
||||||
CALL solver%updatePushSpecies()
|
CALL solver%updatePushSpecies()
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ MODULE moduleRandom
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
real(8):: rnd
|
real(8):: rnd
|
||||||
real(8):: v1, v2, Rsquare
|
real(8):: v1, v2
|
||||||
|
|
||||||
v1 = 0.d0
|
v1 = 0.d0
|
||||||
do while (v1 <= 0.d0)
|
do while (v1 <= 0.d0)
|
||||||
|
|
|
||||||
|
|
@ -628,6 +628,7 @@ MODULE moduleInput
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
USE moduleCaseParam
|
USE moduleCaseParam
|
||||||
USE moduleRefParam
|
USE moduleRefParam
|
||||||
|
use moduleOutput, only: collOutput
|
||||||
USE OMP_LIB
|
USE OMP_LIB
|
||||||
USE json_module
|
USE json_module
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
@ -1426,50 +1427,17 @@ MODULE moduleInput
|
||||||
CHARACTER(2):: iString
|
CHARACTER(2):: iString
|
||||||
CHARACTER(:), ALLOCATABLE:: object
|
CHARACTER(:), ALLOCATABLE:: object
|
||||||
LOGICAL:: found
|
LOGICAL:: found
|
||||||
CHARACTER(:), ALLOCATABLE:: speciesName
|
|
||||||
CHARACTER(:), ALLOCATABLE:: name
|
|
||||||
REAL(8):: v
|
|
||||||
REAL(8), ALLOCATABLE:: temperature(:), normal(:)
|
|
||||||
REAL(8):: flow
|
|
||||||
CHARACTER(:), ALLOCATABLE:: units
|
|
||||||
character(:), allocatable:: type
|
|
||||||
INTEGER:: physicalSurface
|
|
||||||
INTEGER:: particlesPerEdge
|
|
||||||
INTEGER:: sp
|
|
||||||
|
|
||||||
CALL config%info('inject', found, n_children = nInject)
|
CALL config%info('inject', found, n_children = nInject)
|
||||||
ALLOCATE(inject(1:nInject))
|
ALLOCATE(injects(1:nInject))
|
||||||
nPartInj = 0
|
nPartInj = 0
|
||||||
DO i = 1, nInject
|
DO i = 1, nInject
|
||||||
WRITE(iString, '(i2)') i
|
WRITE(iString, '(i2)') i
|
||||||
object = 'inject(' // trim(iString) // ')'
|
object = 'inject(' // trim(iString) // ')'
|
||||||
|
|
||||||
!Find species
|
CALL initInject(injects(i)%obj, i, object, config)
|
||||||
CALL config%get(object // '.species', speciesName, found)
|
|
||||||
sp = speciesName2Index(speciesName)
|
|
||||||
|
|
||||||
CALL config%get(object // '.name', name, found)
|
CALL readVelDistr(config, injects(i)%obj, object)
|
||||||
CALL config%get(object // '.v', v, found)
|
|
||||||
CALL config%get(object // '.T', temperature, found)
|
|
||||||
CALL config%get(object // '.n', normal, found)
|
|
||||||
IF (.NOT. found) THEN
|
|
||||||
ALLOCATE(normal(1:3))
|
|
||||||
normal = 0.D0
|
|
||||||
END IF
|
|
||||||
CALL config%get(object // '.flow', flow, found)
|
|
||||||
CALL config%get(object // '.units', units, found)
|
|
||||||
CALL config%get(object // '.type', type, found)
|
|
||||||
if (.not. found) then
|
|
||||||
! If no type is found, assume constant injection of particles
|
|
||||||
type = 'constant'
|
|
||||||
end if
|
|
||||||
CALL config%get(object // '.physicalSurface', physicalSurface, found)
|
|
||||||
particlesPerEdge = 0
|
|
||||||
CALL config%get(object // '.particlesPerEdge', particlesPerEdge, found)
|
|
||||||
|
|
||||||
CALL inject(i)%init(i, v, normal, temperature, flow, units, type, sp, physicalSurface, particlesPerEdge)
|
|
||||||
|
|
||||||
CALL readVelDistr(config, inject(i), object)
|
|
||||||
|
|
||||||
END DO
|
END DO
|
||||||
|
|
||||||
|
|
@ -1528,7 +1496,7 @@ MODULE moduleInput
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
TYPE(json_file), INTENT(inout):: config
|
TYPE(json_file), INTENT(inout):: config
|
||||||
TYPE(injectGeneric), INTENT(inout):: inj
|
class(injectGeneric), INTENT(inout):: inj
|
||||||
CHARACTER(:), ALLOCATABLE, INTENT(in):: object
|
CHARACTER(:), ALLOCATABLE, INTENT(in):: object
|
||||||
INTEGER:: i
|
INTEGER:: i
|
||||||
CHARACTER(2):: iString
|
CHARACTER(2):: iString
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
module moduleMeshOutputText
|
module moduleMeshOutputText
|
||||||
|
use moduleOutput, only: prefix, &
|
||||||
|
informFileCreation, &
|
||||||
|
formatFileName, &
|
||||||
|
generateFilePath
|
||||||
|
|
||||||
contains
|
contains
|
||||||
|
|
||||||
subroutine writeSpeciesOutput(self, fileID, speciesIndex)
|
subroutine writeSpeciesOutput(self, fileID, speciesIndex)
|
||||||
use moduleMesh
|
use moduleMesh
|
||||||
use moduleOutput
|
use moduleOutput, only: calculateOutput, outputFormat
|
||||||
use moduleRefParam, only: L_ref
|
use moduleRefParam, only: L_ref
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
|
|
@ -88,7 +93,6 @@ module moduleMeshOutputText
|
||||||
speciesIndex)
|
speciesIndex)
|
||||||
|
|
||||||
use moduleMesh
|
use moduleMesh
|
||||||
use moduleOutput
|
|
||||||
use moduleAverage
|
use moduleAverage
|
||||||
use moduleRefParam, only: L_ref
|
use moduleRefParam, only: L_ref
|
||||||
implicit none
|
implicit none
|
||||||
|
|
@ -151,8 +155,8 @@ module moduleMeshOutputText
|
||||||
|
|
||||||
subroutine printCollText(self)
|
subroutine printCollText(self)
|
||||||
use moduleMesh
|
use moduleMesh
|
||||||
use moduleOutput
|
|
||||||
use moduleCaseParam, only: timeStep
|
use moduleCaseParam, only: timeStep
|
||||||
|
use moduleOutput, only: collOutput
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
class(meshGeneric), intent(in):: self
|
class(meshGeneric), intent(in):: self
|
||||||
|
|
@ -190,6 +194,7 @@ module moduleMeshOutputText
|
||||||
subroutine printEMText(self)
|
subroutine printEMText(self)
|
||||||
use moduleMesh
|
use moduleMesh
|
||||||
use moduleCaseParam, only: timeStep
|
use moduleCaseParam, only: timeStep
|
||||||
|
use moduleOutput, only: emOutput
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
class(meshParticles), intent(in):: self
|
class(meshParticles), intent(in):: self
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
MODULE moduleMeshOutputVTU
|
MODULE moduleMeshOutputVTU
|
||||||
|
use moduleOutput, only: prefix, informFileCreation, formatFileName, generateFilePath
|
||||||
|
|
||||||
CONTAINS
|
CONTAINS
|
||||||
|
|
||||||
SUBROUTINE writeHeader(nNodes, nCells, fileID)
|
SUBROUTINE writeHeader(nNodes, nCells, fileID)
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
|
use moduleOutput, only: fmtInt
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
INTEGER, INTENT(in):: nNodes, nCells
|
INTEGER, INTENT(in):: nNodes, nCells
|
||||||
|
|
@ -77,6 +79,7 @@ MODULE moduleMeshOutputVTU
|
||||||
SUBROUTINE writeMesh(self, fileID)
|
SUBROUTINE writeMesh(self, fileID)
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
USE moduleRefParam
|
USE moduleRefParam
|
||||||
|
use moduleOutput, only: fmtReal, fmtInt
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
CLASS(meshGeneric), INTENT(in):: self
|
CLASS(meshGeneric), INTENT(in):: self
|
||||||
|
|
@ -159,6 +162,7 @@ MODULE moduleMeshOutputVTU
|
||||||
SUBROUTINE writeCollOutput(self,fileID)
|
SUBROUTINE writeCollOutput(self,fileID)
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
USE moduleCollisions
|
USE moduleCollisions
|
||||||
|
use moduleOutput, only: fmtInt
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
CLASS(meshGeneric), INTENT(in):: self
|
CLASS(meshGeneric), INTENT(in):: self
|
||||||
|
|
@ -185,6 +189,7 @@ MODULE moduleMeshOutputVTU
|
||||||
SUBROUTINE writeEM(self, fileID)
|
SUBROUTINE writeEM(self, fileID)
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
USE moduleRefParam
|
USE moduleRefParam
|
||||||
|
use moduleOutput, only: fmtReal
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
CLASS(meshParticles), INTENT(in):: self
|
CLASS(meshParticles), INTENT(in):: self
|
||||||
|
|
@ -381,6 +386,7 @@ MODULE moduleMeshOutputVTU
|
||||||
SUBROUTINE printEMVTU(self)
|
SUBROUTINE printEMVTU(self)
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
USE moduleCaseParam, ONLY: timeStep
|
USE moduleCaseParam, ONLY: timeStep
|
||||||
|
use moduleOutput, only: emOutput
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
CLASS(meshParticles), INTENT(in):: self
|
CLASS(meshParticles), INTENT(in):: self
|
||||||
|
|
@ -414,7 +420,6 @@ MODULE moduleMeshOutputVTU
|
||||||
|
|
||||||
SUBROUTINE printAverageVTU(self)
|
SUBROUTINE printAverageVTU(self)
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
use moduleOutput
|
|
||||||
USE moduleSpecies
|
USE moduleSpecies
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
!moduleMesh: General module for Finite Element mesh
|
!moduleMesh: General module for Finite Element mesh
|
||||||
MODULE moduleMesh
|
MODULE moduleMesh
|
||||||
USE moduleList
|
USE moduleList
|
||||||
USE moduleOutput
|
USE moduleOutput, only: outputNode, emNode
|
||||||
USE moduleCollisions
|
USE moduleCollisions
|
||||||
use moduleSpecies, only: nSpecies
|
use moduleSpecies, only: nSpecies
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ submodule(moduleMesh) boundaryEM
|
||||||
use json_module
|
use json_module
|
||||||
use moduleRefParam, ONLY: Volt_ref, ti_ref
|
use moduleRefParam, ONLY: Volt_ref, ti_ref
|
||||||
use moduleErrors
|
use moduleErrors
|
||||||
|
use moduleOutput, only: path
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
class(boundaryEMGeneric), allocatable, intent(inout):: self
|
class(boundaryEMGeneric), allocatable, intent(inout):: self
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,7 @@ submodule(moduleMesh) boundaryParticle
|
||||||
|
|
||||||
! Print
|
! Print
|
||||||
subroutine ionization_print(self, fileID)
|
subroutine ionization_print(self, fileID)
|
||||||
|
use moduleOutput, only: fmtInt
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
class(boundaryParticleGeneric), intent(inout):: self
|
class(boundaryParticleGeneric), intent(inout):: self
|
||||||
|
|
@ -473,6 +474,7 @@ submodule(moduleMesh) boundaryParticle
|
||||||
|
|
||||||
! Print output
|
! Print output
|
||||||
subroutine quasiNeutrality_print(self, fileID)
|
subroutine quasiNeutrality_print(self, fileID)
|
||||||
|
use moduleOutput, only: fmtColInt, fmtColReal
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
class(boundaryParticleGeneric), intent(inout):: self
|
class(boundaryParticleGeneric), intent(inout):: self
|
||||||
|
|
@ -613,6 +615,7 @@ submodule(moduleMesh) boundaryParticle
|
||||||
|
|
||||||
! Print
|
! Print
|
||||||
subroutine outflowAdaptive_print(self, fileID)
|
subroutine outflowAdaptive_print(self, fileID)
|
||||||
|
use moduleOutput, only: fmtColInt, fmtColReal
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
class(boundaryParticleGeneric), intent(inout):: self
|
class(boundaryParticleGeneric), intent(inout):: self
|
||||||
|
|
@ -691,7 +694,12 @@ submodule(moduleMesh) boundaryParticle
|
||||||
! Writes the output into the Step_XXXXX_boundaryParticles file when the %print procedure is associated
|
! Writes the output into the Step_XXXXX_boundaryParticles file when the %print procedure is associated
|
||||||
module subroutine boundariesParticle_write()
|
module subroutine boundariesParticle_write()
|
||||||
use moduleCaseparam, only: timeStep
|
use moduleCaseparam, only: timeStep
|
||||||
use moduleOutput, only:fileID_boundaryParticle, formatFileName, informFileCreation
|
use moduleOutput, only: fileID_boundaryParticle, &
|
||||||
|
formatFileName, &
|
||||||
|
informFileCreation,&
|
||||||
|
boundaryParticleOutput,&
|
||||||
|
generateFilePath, &
|
||||||
|
prefix
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer:: b
|
integer:: b
|
||||||
|
|
@ -700,7 +708,7 @@ submodule(moduleMesh) boundaryParticle
|
||||||
if (boundaryParticleOutput) then
|
if (boundaryParticleOutput) then
|
||||||
fileName = formatFileName(prefix, 'boundariesParticle', 'csv', timeStep)
|
fileName = formatFileName(prefix, 'boundariesParticle', 'csv', timeStep)
|
||||||
call informFileCreation(fileName)
|
call informFileCreation(fileName)
|
||||||
open(fileID_boundaryParticle, file = path // folder // '/' // fileName)
|
open(fileID_boundaryParticle, file = generateFilePath(fileName))
|
||||||
|
|
||||||
do b = 1, nBoundariesParticle
|
do b = 1, nBoundariesParticle
|
||||||
if (associated(boundariesParticle(b)%obj%print)) then
|
if (associated(boundariesParticle(b)%obj%print)) then
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ MODULE moduleInject
|
||||||
use moduleMesh, only: meshEdgePointer
|
use moduleMesh, only: meshEdgePointer
|
||||||
|
|
||||||
!Generic injection of particles
|
!Generic injection of particles
|
||||||
TYPE:: injectGeneric
|
TYPE, abstract:: injectGeneric
|
||||||
INTEGER:: id
|
INTEGER:: id
|
||||||
CHARACTER(:), ALLOCATABLE:: name
|
CHARACTER(:), ALLOCATABLE:: name
|
||||||
REAL(8):: vMod !Velocity (module)
|
REAL(8):: vMod !Velocity (module)
|
||||||
|
|
@ -14,46 +14,130 @@ MODULE moduleInject
|
||||||
LOGICAL:: fixDirection !The injection of particles has a fix direction defined by n
|
LOGICAL:: fixDirection !The injection of particles has a fix direction defined by n
|
||||||
INTEGER:: nParticles !Number of particles to introduce each time step
|
INTEGER:: nParticles !Number of particles to introduce each time step
|
||||||
CLASS(speciesGeneric), POINTER:: species !Species of injection
|
CLASS(speciesGeneric), POINTER:: species !Species of injection
|
||||||
character(:), allocatable:: type
|
|
||||||
INTEGER:: nEdges
|
INTEGER:: nEdges
|
||||||
type(meshEdgePointer), allocatable:: edges(:)
|
type(meshEdgePointer), allocatable:: edges(:)
|
||||||
INTEGER, ALLOCATABLE:: particlesPerEdge(:) ! Particles per edge
|
INTEGER, ALLOCATABLE:: particlesPerEdge(:) ! Particles per edge
|
||||||
REAL(8), ALLOCATABLE:: weightPerEdge(:) ! Weight per edge
|
REAL(8), ALLOCATABLE:: weightPerEdge(:) ! Weight per edge
|
||||||
REAL(8):: surface ! Total surface of injection
|
REAL(8):: surface ! Total surface of injection
|
||||||
TYPE(velDistCont):: v(1:3) !Velocity distribution function in each direction
|
TYPE(velDistCont):: v(1:3) !Velocity distribution function in each direction
|
||||||
|
procedure(updateInject_interface), pointer, pass:: update => null()
|
||||||
|
procedure(printInject_interface), pointer, pass:: print => null()
|
||||||
CONTAINS
|
CONTAINS
|
||||||
PROCEDURE, PASS:: init => initInject
|
|
||||||
PROCEDURE, PASS:: addParticles
|
PROCEDURE, PASS:: addParticles
|
||||||
|
|
||||||
END TYPE injectGeneric
|
END TYPE injectGeneric
|
||||||
|
|
||||||
|
abstract interface
|
||||||
|
! Update the values of the particle boundary model
|
||||||
|
subroutine updateInject_interface(self)
|
||||||
|
import injectGeneric
|
||||||
|
|
||||||
|
class(injectGeneric), intent(inout):: self
|
||||||
|
|
||||||
|
end subroutine updateInject_interface
|
||||||
|
|
||||||
|
! Write the values of the particle boundary model
|
||||||
|
subroutine printInject_interface(self, fileID)
|
||||||
|
import injectGeneric
|
||||||
|
|
||||||
|
class(injectGeneric), intent(inout):: self
|
||||||
|
integer, intent(in):: fileID
|
||||||
|
|
||||||
|
end subroutine printInject_interface
|
||||||
|
|
||||||
|
end interface
|
||||||
|
|
||||||
|
! Default type, constant inject of particles
|
||||||
|
type, extends(injectGeneric):: injectConstant
|
||||||
|
|
||||||
|
end type injectconstant
|
||||||
|
|
||||||
|
type, extends(injectGeneric):: injectQuasiNeutral
|
||||||
|
|
||||||
|
end type injectQuasiNeutral
|
||||||
|
|
||||||
|
! Wrapper for injects
|
||||||
|
type:: injectWrapper
|
||||||
|
class(injectGeneric), allocatable:: obj
|
||||||
|
|
||||||
|
end type injectWrapper
|
||||||
|
|
||||||
INTEGER:: nInject
|
INTEGER:: nInject
|
||||||
TYPE(injectGeneric), ALLOCATABLE, target:: inject(:)
|
TYPE(injectWrapper), ALLOCATABLE, target:: injects(:)
|
||||||
|
|
||||||
CONTAINS
|
CONTAINS
|
||||||
!Initialize an injection of particles
|
!Initialize an injection of particles
|
||||||
SUBROUTINE initInject(self, i, v, n, temperature, flow, units, type, sp, ps, particlesPerEdge)
|
SUBROUTINE initInject(self, i, object, config)
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
USE moduleRefParam
|
USE moduleRefParam
|
||||||
USE moduleConstParam
|
USE moduleConstParam
|
||||||
USE moduleSpecies
|
USE moduleSpecies
|
||||||
USE moduleSolver
|
USE moduleSolver
|
||||||
USE moduleErrors
|
USE moduleErrors
|
||||||
|
use json_module
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
CLASS(injectGeneric), INTENT(inout):: self
|
CLASS(injectGeneric), allocatable, INTENT(inout):: self
|
||||||
INTEGER, INTENT(in):: i
|
INTEGER, INTENT(in):: i
|
||||||
REAL(8), INTENT(in):: v, n(1:3), temperature(1:3)
|
character(:), allocatable, intent(in):: object
|
||||||
INTEGER, INTENT(in):: sp, ps, particlesPerEdge
|
type(json_file), intent(inout):: config
|
||||||
|
character(:), allocatable:: type
|
||||||
|
logical:: found
|
||||||
|
REAL(8):: v
|
||||||
|
real(8), allocatable:: n(:), temperature(:)
|
||||||
|
INTEGER:: sp, ps, particlesPerEdge
|
||||||
|
character(:), allocatable:: speciesName
|
||||||
integer:: ps_index
|
integer:: ps_index
|
||||||
REAL(8):: tauInject
|
REAL(8):: tauInject
|
||||||
REAL(8), INTENT(in):: flow
|
REAL(8):: flow
|
||||||
CHARACTER(:), ALLOCATABLE, INTENT(in):: units
|
CHARACTER(:), ALLOCATABLE:: units
|
||||||
character(:), allocatable, intent(in):: type
|
|
||||||
INTEGER:: e
|
INTEGER:: e
|
||||||
REAL(8):: fluxPerStep = 0.D0
|
REAL(8):: fluxPerStep = 0.D0
|
||||||
|
|
||||||
|
!Type of injection
|
||||||
|
call config%get(object // '.type', type, found)
|
||||||
|
if (.not. found) then
|
||||||
|
! If no type is found, assume constant injection of particles
|
||||||
|
type = 'constant'
|
||||||
|
end if
|
||||||
|
|
||||||
|
! Assign type to inject and allocates it
|
||||||
|
select case(type)
|
||||||
|
case ('constant')
|
||||||
|
allocate(injectConstant:: self)
|
||||||
|
|
||||||
|
case ('quasiNeutral')
|
||||||
|
allocate(injectQuasiNeutral:: self)
|
||||||
|
|
||||||
|
self%update => updateQuasiNeutral
|
||||||
|
|
||||||
|
case default
|
||||||
|
call criticalError('No injection type ' // type // ' defined', 'initInject')
|
||||||
|
end select
|
||||||
|
|
||||||
self%id = i
|
self%id = i
|
||||||
|
call config%get(object // '.name', self%name, found)
|
||||||
|
|
||||||
|
!Find species
|
||||||
|
CALL config%get(object // '.species', speciesName, found)
|
||||||
|
sp = speciesName2Index(speciesName)
|
||||||
|
|
||||||
|
! Velocity and direction of injection
|
||||||
|
call config%get(object // '.v', v, found)
|
||||||
|
call config%get(object // '.n', n, found)
|
||||||
|
if (.not. found) then
|
||||||
|
allocate(n(1:3))
|
||||||
|
n = 0.D0
|
||||||
|
end if
|
||||||
|
! Temperature of injection
|
||||||
|
call config%get(object // '.T', temperature, found)
|
||||||
|
! Flow
|
||||||
|
call config%get(object // '.flow', flow, found)
|
||||||
|
call config%get(object // '.units', units, found)
|
||||||
|
CALL config%get(object // '.physicalSurface', ps, found)
|
||||||
|
particlesPerEdge = 0
|
||||||
|
CALL config%get(object // '.particlesPerEdge', particlesPerEdge, found)
|
||||||
|
|
||||||
self%vMod = v / v_ref
|
self%vMod = v / v_ref
|
||||||
self%n = n / NORM2(n)
|
self%n = n / NORM2(n)
|
||||||
self%temperature = temperature / T_ref
|
self%temperature = temperature / T_ref
|
||||||
|
|
@ -145,54 +229,31 @@ MODULE moduleInject
|
||||||
!Scale particles for different species steps
|
!Scale particles for different species steps
|
||||||
IF (self%nParticles == 0) CALL criticalError("The number of particles for inject is 0.", 'initInject')
|
IF (self%nParticles == 0) CALL criticalError("The number of particles for inject is 0.", 'initInject')
|
||||||
|
|
||||||
! Assign type to inject
|
|
||||||
select case(type)
|
|
||||||
case ('constant', 'quasiNeutral')
|
|
||||||
self%type = type
|
|
||||||
case default
|
|
||||||
call criticalError('No injection type ' // type // ' defined', 'initInject')
|
|
||||||
end select
|
|
||||||
|
|
||||||
END SUBROUTINE initInject
|
END SUBROUTINE initInject
|
||||||
|
|
||||||
!Injection of particles
|
|
||||||
SUBROUTINE doInjects()
|
|
||||||
USE moduleSpecies
|
|
||||||
USE moduleSolver
|
|
||||||
IMPLICIT NONE
|
|
||||||
|
|
||||||
INTEGER:: i
|
|
||||||
|
|
||||||
!$OMP SINGLE
|
|
||||||
nPartInj = 0
|
|
||||||
DO i = 1, nInject
|
|
||||||
IF (solver%pusher(inject(i)%species%n)%pushSpecies) THEN
|
|
||||||
nPartInj = nPartInj + inject(i)%nParticles
|
|
||||||
|
|
||||||
END IF
|
|
||||||
|
|
||||||
END DO
|
|
||||||
|
|
||||||
IF (ALLOCATED(partInj)) DEALLOCATE(partInj)
|
|
||||||
ALLOCATE(partInj(1:nPartInj))
|
|
||||||
!$OMP END SINGLE
|
|
||||||
|
|
||||||
DO i=1, nInject
|
|
||||||
IF (solver%pusher(inject(i)%species%n)%pushSpecies) THEN
|
|
||||||
CALL inject(i)%addParticles()
|
|
||||||
|
|
||||||
END IF
|
|
||||||
END DO
|
|
||||||
|
|
||||||
END SUBROUTINE doInjects
|
|
||||||
|
|
||||||
! Update the value of injects
|
! Update the value of injects
|
||||||
subroutine updateInjects()
|
subroutine updateInjects()
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
integer:: i
|
||||||
|
|
||||||
|
do i = 1, nInject
|
||||||
|
if (associated(injects(i)%obj%update)) then
|
||||||
|
call injects(i)%obj%update()
|
||||||
|
|
||||||
|
end if
|
||||||
|
|
||||||
|
end do
|
||||||
|
|
||||||
|
end subroutine updateInjects
|
||||||
|
|
||||||
|
! Updates the flow in the injection to maintain quasineutrality
|
||||||
|
subroutine updateQuasiNeutral(self)
|
||||||
use moduleMesh, only: meshEdge, meshNode, mesh, qSpecies
|
use moduleMesh, only: meshEdge, meshNode, mesh, qSpecies
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer:: i, e, s, n
|
class(injectGeneric), intent(inout):: self
|
||||||
class(injectGeneric), pointer:: self
|
integer:: e, s, n
|
||||||
integer, allocatable:: nodes(:)
|
integer, allocatable:: nodes(:)
|
||||||
class(meshEdge), pointer:: edge
|
class(meshEdge), pointer:: edge
|
||||||
real(8), allocatable:: density_nodes(:)
|
real(8), allocatable:: density_nodes(:)
|
||||||
|
|
@ -201,10 +262,8 @@ MODULE moduleInject
|
||||||
real(8):: density_incident, density_rest
|
real(8):: density_incident, density_rest
|
||||||
real(8):: alpha
|
real(8):: alpha
|
||||||
|
|
||||||
do i = 1, nInject
|
select type(self)
|
||||||
self => inject(i)
|
type is (injectQuasiNeutral)
|
||||||
select case(inject(i)%type)
|
|
||||||
case ('quasiNeutral')
|
|
||||||
do e = 1, self%nEdges
|
do e = 1, self%nEdges
|
||||||
edge => self%edges(e)%obj
|
edge => self%edges(e)%obj
|
||||||
|
|
||||||
|
|
@ -245,44 +304,47 @@ MODULE moduleInject
|
||||||
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
print *, e, alpha
|
||||||
|
|
||||||
! Adjust the weight of particles to match the new current
|
! Adjust the weight of particles to match the new current
|
||||||
self%weightPerEdge(e) = self%weightPerEdge(e) + 1.0d-2 * alpha
|
self%weightPerEdge(e) = self%weightPerEdge(e) + 1.0d-1 * alpha
|
||||||
|
|
||||||
end do
|
end do
|
||||||
|
|
||||||
end select
|
end select
|
||||||
end do
|
|
||||||
|
|
||||||
end subroutine updateInjects
|
end subroutine updateQuasiNeutral
|
||||||
|
|
||||||
SUBROUTINE initVelDistMaxwellian(velDist, temperature, m)
|
!Injection of particles
|
||||||
|
SUBROUTINE doInjects()
|
||||||
|
USE moduleSpecies
|
||||||
|
USE moduleSolver
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
CLASS(velDistGeneric), ALLOCATABLE, INTENT(out):: velDist
|
INTEGER:: i
|
||||||
REAL(8), INTENT(in):: temperature, m
|
|
||||||
|
|
||||||
velDist = velDistMaxwellian(vTh = DSQRT(2.d0*temperature/m))
|
!$OMP SINGLE
|
||||||
|
nPartInj = 0
|
||||||
|
DO i = 1, nInject
|
||||||
|
IF (solver%pusher(injects(i)%obj%species%n)%pushSpecies) THEN
|
||||||
|
nPartInj = nPartInj + injects(i)%obj%nParticles
|
||||||
|
|
||||||
END SUBROUTINE initVelDistMaxwellian
|
END IF
|
||||||
|
|
||||||
SUBROUTINE initVelDistHalfMaxwellian(velDist, temperature, m)
|
END DO
|
||||||
IMPLICIT NONE
|
|
||||||
|
|
||||||
CLASS(velDistGeneric), ALLOCATABLE, INTENT(out):: velDist
|
IF (ALLOCATED(partInj)) DEALLOCATE(partInj)
|
||||||
REAL(8), INTENT(in):: temperature, m
|
ALLOCATE(partInj(1:nPartInj))
|
||||||
|
!$OMP END SINGLE
|
||||||
|
|
||||||
velDist = velDistHalfMaxwellian(vTh = DSQRT(2.d0*temperature/m))
|
DO i=1, nInject
|
||||||
|
IF (solver%pusher(injects(i)%obj%species%n)%pushSpecies) THEN
|
||||||
|
CALL injects(i)%obj%addParticles()
|
||||||
|
|
||||||
END SUBROUTINE initVelDistHalfMaxwellian
|
END IF
|
||||||
|
END DO
|
||||||
|
|
||||||
SUBROUTINE initVelDistDelta(velDist)
|
END SUBROUTINE doInjects
|
||||||
IMPLICIT NONE
|
|
||||||
|
|
||||||
CLASS(velDistGeneric), ALLOCATABLE, INTENT(out):: velDist
|
|
||||||
|
|
||||||
velDist = velDistDelta()
|
|
||||||
|
|
||||||
END SUBROUTINE initVelDistDelta
|
|
||||||
|
|
||||||
!Add particles for the injection
|
!Add particles for the injection
|
||||||
SUBROUTINE addParticles(self)
|
SUBROUTINE addParticles(self)
|
||||||
|
|
@ -304,8 +366,8 @@ MODULE moduleInject
|
||||||
!$OMP SINGLE
|
!$OMP SINGLE
|
||||||
nMin = 0
|
nMin = 0
|
||||||
DO i = 1, self%id -1
|
DO i = 1, self%id -1
|
||||||
IF (solver%pusher(inject(i)%species%n)%pushSpecies) THEN
|
IF (solver%pusher(injects(i)%obj%species%n)%pushSpecies) THEN
|
||||||
nMin = nMin + inject(i)%nParticles
|
nMin = nMin + injects(i)%obj%nParticles
|
||||||
|
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
|
@ -381,4 +443,67 @@ MODULE moduleInject
|
||||||
|
|
||||||
END SUBROUTINE addParticles
|
END SUBROUTINE addParticles
|
||||||
|
|
||||||
|
! Writes the value of injects
|
||||||
|
subroutine writeInjects()
|
||||||
|
use moduleCaseparam, only: timeStep
|
||||||
|
use moduleOutput, only: fileID_inject, &
|
||||||
|
formatFileName, &
|
||||||
|
informFileCreation,&
|
||||||
|
injectOutput,&
|
||||||
|
generateFilePath, &
|
||||||
|
prefix
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
integer:: i
|
||||||
|
character(:), allocatable:: fileName
|
||||||
|
|
||||||
|
if (injectOutput) then
|
||||||
|
fileName = formatFileName(prefix, 'injects', 'csv', timeStep)
|
||||||
|
call informFileCreation(fileName)
|
||||||
|
open(fileID_inject, file = generateFilePath(fileName))
|
||||||
|
|
||||||
|
do i = 1, nInject
|
||||||
|
if (associated(injects(i)%obj%print)) then
|
||||||
|
call injects(i)%obj%print(fileID_inject)
|
||||||
|
|
||||||
|
end if
|
||||||
|
|
||||||
|
end do
|
||||||
|
|
||||||
|
close(fileID_inject)
|
||||||
|
|
||||||
|
end if
|
||||||
|
|
||||||
|
end subroutine writeInjects
|
||||||
|
|
||||||
|
! Inits for different velocity distribution functions
|
||||||
|
SUBROUTINE initVelDistMaxwellian(velDist, temperature, m)
|
||||||
|
IMPLICIT NONE
|
||||||
|
|
||||||
|
CLASS(velDistGeneric), ALLOCATABLE, INTENT(out):: velDist
|
||||||
|
REAL(8), INTENT(in):: temperature, m
|
||||||
|
|
||||||
|
velDist = velDistMaxwellian(vTh = DSQRT(2.d0*temperature/m))
|
||||||
|
|
||||||
|
END SUBROUTINE initVelDistMaxwellian
|
||||||
|
|
||||||
|
SUBROUTINE initVelDistHalfMaxwellian(velDist, temperature, m)
|
||||||
|
IMPLICIT NONE
|
||||||
|
|
||||||
|
CLASS(velDistGeneric), ALLOCATABLE, INTENT(out):: velDist
|
||||||
|
REAL(8), INTENT(in):: temperature, m
|
||||||
|
|
||||||
|
velDist = velDistHalfMaxwellian(vTh = DSQRT(2.d0*temperature/m))
|
||||||
|
|
||||||
|
END SUBROUTINE initVelDistHalfMaxwellian
|
||||||
|
|
||||||
|
SUBROUTINE initVelDistDelta(velDist)
|
||||||
|
IMPLICIT NONE
|
||||||
|
|
||||||
|
CLASS(velDistGeneric), ALLOCATABLE, INTENT(out):: velDist
|
||||||
|
|
||||||
|
velDist = velDistDelta()
|
||||||
|
|
||||||
|
END SUBROUTINE initVelDistDelta
|
||||||
|
|
||||||
END MODULE moduleInject
|
END MODULE moduleInject
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ MODULE moduleOutput
|
||||||
LOGICAL:: collOutput = .FALSE.
|
LOGICAL:: collOutput = .FALSE.
|
||||||
LOGICAL:: emOutput = .FALSE.
|
LOGICAL:: emOutput = .FALSE.
|
||||||
logical:: boundaryParticleOutput = .false.
|
logical:: boundaryParticleOutput = .false.
|
||||||
|
logical:: injectOutput = .false.
|
||||||
|
|
||||||
! Prefix for iteration files
|
! Prefix for iteration files
|
||||||
character(len=*), parameter:: prefix = 'Step'
|
character(len=*), parameter:: prefix = 'Step'
|
||||||
|
|
@ -33,6 +34,7 @@ MODULE moduleOutput
|
||||||
integer, parameter:: fileID_output = 20 ! Base id for species/collisions/EM output
|
integer, parameter:: fileID_output = 20 ! Base id for species/collisions/EM output
|
||||||
integer, parameter:: fileID_boundaryParticle = 30 ! Particle boundaries
|
integer, parameter:: fileID_boundaryParticle = 30 ! Particle boundaries
|
||||||
integer, parameter:: fileID_boundaryEM = 31 ! EM boundaries
|
integer, parameter:: fileID_boundaryEM = 31 ! EM boundaries
|
||||||
|
integer, parameter:: fileID_inject = 32 ! Injects
|
||||||
integer, parameter:: fileID_reference = 40 ! Reference values
|
integer, parameter:: fileID_reference = 40 ! Reference values
|
||||||
integer, parameter:: fileID_time =50 ! Computation time
|
integer, parameter:: fileID_time =50 ! Computation time
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue