Particles are injected in each iteration and pushed with tauMin when

injected. Then, particles are pushed as normal in their own time step.
This commit is contained in:
Jorge Gonzalez 2021-01-02 16:31:31 +01:00
commit 5516e46ec3
3 changed files with 34 additions and 52 deletions

View file

@ -92,11 +92,11 @@ MODULE moduleInject
SELECT CASE(units)
CASE ("sccm")
!Standard cubic centimeter per minute
self%nParticles = INT(flow*sccm2atomPerS*tau(self%sp)*ti_ref/species(sp)%obj%weight)
self%nParticles = INT(flow*sccm2atomPerS*tauMin*ti_ref/species(sp)%obj%weight)
CASE ("A")
!Input current in Ampers
self%nParticles = INT(flow*tau(self%sp)*ti_ref/(qe*species(sp)%obj%weight))
self%nParticles = INT(flow*tauMin*ti_ref/(qe*species(sp)%obj%weight))
CASE DEFAULT
CALL criticalError("No support for units: " // units, 'initInject')
@ -106,7 +106,6 @@ MODULE moduleInject
IF (self%nParticles == 0) CALL criticalError("The number of particles for inject is 0.", 'initInject')
!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
@ -114,7 +113,6 @@ MODULE moduleInject
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
@ -124,7 +122,8 @@ MODULE moduleInject
END IF
END DO
! self%sumWeight = SUM(self%weight)
nPartInj = nPartInj + self%nParticles
END SUBROUTINE initInject
@ -137,17 +136,12 @@ MODULE moduleInject
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()
CALL inject(i)%addParticles()
END DO
END SUBROUTINE doInjects
@ -206,19 +200,13 @@ MODULE moduleInject
CLASS(injectGeneric), INTENT(in):: self
INTEGER:: randomX
INTEGER:: i!, j
INTEGER, SAVE:: nMin, nMax !Min and Max index in partInj array
INTEGER:: n
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
nMin = SUM(inject(1:(self%id-1))%nParticles) + 1
nMax = nMin + self%nParticles - 1
!Assign particle type
partInj(nMin:nMax)%sp = self%sp
@ -254,8 +242,8 @@ MODULE moduleInject
self%v(2)%obj%randomVel(), &
self%v(3)%obj%randomVel() /)
!Push new particle
CALL solver%pusher(self%sp)%pushParticle(partInj(n))
!Push new particle with the minimum time step
CALL solver%pusher(self%sp)%pushParticle(partInj(n), tauMin)
!Assign cell to new particle
CALL solver%updateParticleCell(partInj(n))