Files renamed and makefile make compatible with ifort.
This commit is contained in:
parent
3b125d0952
commit
af74205932
25 changed files with 5439 additions and 0 deletions
202
src/modules/moduleInject.f90
Normal file
202
src/modules/moduleInject.f90
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
!injection of particles
|
||||
MODULE moduleInject
|
||||
|
||||
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
|
||||
CONTAINS
|
||||
PROCEDURE, PASS:: init => initInject
|
||||
PROCEDURE, PASS:: addParticles => addParticlesMaxwellian
|
||||
|
||||
END TYPE injectGeneric
|
||||
|
||||
INTEGER:: nInject
|
||||
TYPE(injectGeneric), ALLOCATABLE:: inject(:)
|
||||
|
||||
CONTAINS
|
||||
!Initialize an injection of particles
|
||||
SUBROUTINE initInject(self, i, v, n, T, flow, units, sp, physicalSurface)
|
||||
USE moduleMesh
|
||||
USE moduleRefParam
|
||||
USE moduleConstParam
|
||||
USE moduleSpecies
|
||||
USE moduleSolver
|
||||
USE moduleErrors
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(injectGeneric), INTENT(inout):: self
|
||||
INTEGER, INTENT(in):: i
|
||||
REAL(8), INTENT(in):: v, n(1:3), T(1:3)
|
||||
INTEGER, INTENT(in):: sp, physicalSurface
|
||||
REAL(8), INTENT(in):: flow
|
||||
CHARACTER(:), ALLOCATABLE, INTENT(in):: units
|
||||
INTEGER:: e, et
|
||||
INTEGER:: phSurface(1:mesh%numEdges)
|
||||
|
||||
self%id = i
|
||||
self%vMod = v/v_ref
|
||||
self%n = n
|
||||
self%T = T/T_ref
|
||||
SELECT CASE(units)
|
||||
CASE ("sccm")
|
||||
!Standard cubic centimeter per minute
|
||||
self%nParticles = INT(flow*sccm2atomPerS*tauMin*ti_ref/species(sp)%obj%weight)
|
||||
|
||||
CASE ("A")
|
||||
!Input current in Ampers
|
||||
self%nParticles = INT(flow*tauMin*ti_ref/(qe*species(sp)%obj%weight))
|
||||
|
||||
CASE DEFAULT
|
||||
CALL criticalError("No support for units: " // units, 'initInject')
|
||||
|
||||
END SELECT
|
||||
IF (self%nParticles == 0) CALL criticalError("The number of particles for inject is 0.", 'initInject')
|
||||
|
||||
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
|
||||
phSurface(e) = mesh%edges(e)%obj%physicalSurface
|
||||
|
||||
END DO
|
||||
|
||||
self%nEdges = COUNT(phSurface == physicalSurface)
|
||||
ALLOCATE(inject(i)%edges(1:self%nEdges))
|
||||
! ALLOCATE(inject(i)%weight(1:self%nEdges))
|
||||
et = 0
|
||||
DO e=1, mesh%numEdges
|
||||
IF (mesh%edges(e)%obj%physicalSurface == physicalSurface) THEN
|
||||
et = et + 1
|
||||
self%edges(et) = mesh%edges(e)%obj%n
|
||||
|
||||
END IF
|
||||
|
||||
END DO
|
||||
! self%sumWeight = SUM(self%weight)
|
||||
|
||||
END SUBROUTINE
|
||||
|
||||
!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)%sp)%pushSpecies) nPartInj = nPartInj + inject(i)%nParticles
|
||||
|
||||
END DO
|
||||
IF (ALLOCATED(partInj)) DEALLOCATE(partInj)
|
||||
ALLOCATE(partInj(1:nPartInj))
|
||||
!$OMP END SINGLE
|
||||
|
||||
DO i=1, nInject
|
||||
IF (solver%pusher(inject(i)%sp)%pushSpecies) CALL inject(i)%addParticles()
|
||||
END DO
|
||||
|
||||
END SUBROUTINE doInjects
|
||||
|
||||
!Random velocity from maxwellian distribution
|
||||
REAL(8) FUNCTION vBC(u, vth)
|
||||
USE moduleConstParam, ONLY: PI
|
||||
REAL(8), INTENT (in):: u, vth
|
||||
REAL(8):: x, y
|
||||
vBC=0.D0
|
||||
x = 0.D0
|
||||
|
||||
DO WHILE (x == 0.D0)
|
||||
CALL RANDOM_NUMBER(x)
|
||||
END DO
|
||||
CALL RANDOM_NUMBER(y)
|
||||
|
||||
vBC = u + vth*DSQRT(-2.D0*DLOG(x))*DCOS(2.D0*PI*y)
|
||||
|
||||
END FUNCTION vBC
|
||||
|
||||
SUBROUTINE addParticlesMaxwellian(self)
|
||||
USE moduleSpecies
|
||||
USE moduleSolver
|
||||
USE moduleMesh
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(injectGeneric), INTENT(in):: self
|
||||
INTEGER:: randomX
|
||||
INTEGER:: i!, j
|
||||
INTEGER, SAVE:: nMin, nMax !Min and Max index in partInj array
|
||||
INTEGER:: n
|
||||
REAL(8):: rnd
|
||||
CLASS(meshEdge), POINTER:: randomEdge
|
||||
|
||||
!Insert particles
|
||||
!$OMP SINGLE
|
||||
nMin = 0
|
||||
DO i = 1, self%id - 1
|
||||
IF (solver%pusher(inject(i)%sp)%pushSpecies) nMin = nMin + inject(i)%nParticles
|
||||
|
||||
END DO
|
||||
nMin = nMin + 1
|
||||
nMax = nMin + self%nParticles - 1
|
||||
!Assign particle type
|
||||
partInj(nMin:nMax)%sp = self%sp
|
||||
!Assign weight to particle.
|
||||
partInj(nMin:nMax)%weight = species(self%sp)%obj%weight
|
||||
!Particle is considered to be outside the domain
|
||||
partInj(nMin:nMax)%n_in = .FALSE.
|
||||
!Assign charge/mass to charged particle.
|
||||
SELECT TYPE(sp => species(self%sp)%obj)
|
||||
TYPE IS(speciesCharged)
|
||||
partInj(nMin:nMax)%qm = sp%qm
|
||||
|
||||
END SELECT
|
||||
!$OMP END SINGLE
|
||||
|
||||
!$OMP DO
|
||||
DO n = nMin, nMax
|
||||
CALL RANDOM_NUMBER(rnd)
|
||||
randomX = INT(DBLE(self%nEdges-1)*rnd) + 1
|
||||
|
||||
randomEdge => mesh%edges(self%edges(randomX))%obj
|
||||
!Random position in edge
|
||||
partInj(n)%r = randomEdge%randPos()
|
||||
!Volume associated to the edge:
|
||||
IF (DOT_PRODUCT(self%n, randomEdge%normal) >= 0.D0) THEN
|
||||
partInj(n)%vol = randomEdge%e1%n
|
||||
|
||||
ELSE
|
||||
partInj(n)%vol = randomEdge%e2%n
|
||||
|
||||
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)) /)
|
||||
|
||||
!Push new particle
|
||||
CALL solver%pusher(self%sp)%pushParticle(partInj(n))
|
||||
!Assign cell to new particle
|
||||
CALL solver%updateParticleCell(partInj(n))
|
||||
|
||||
END DO
|
||||
!$OMP END DO
|
||||
|
||||
END SUBROUTINE addParticlesMaxwellian
|
||||
|
||||
END MODULE moduleInject
|
||||
Loading…
Add table
Add a link
Reference in a new issue