Fixed bug with number of collisions not computing correctly because
INT/REAL conversions. Number of collisions now take into account the different weight of particles inside a cell without impacting performance.
This commit is contained in:
parent
bf6caad56a
commit
e14c3ef65b
3 changed files with 32 additions and 23 deletions
|
|
@ -135,6 +135,7 @@ MODULE moduleCollisions
|
|||
vRel = species(1)%obj%m*NORM2(part_i%v - part_j%v)**2
|
||||
sigmaVrel = self%crossSec%get(vRel)*vRel
|
||||
sigmaVrelMaxNew = sigmaVrelMaxNew + sigmaVrel
|
||||
PRINT *, sigmaVrelMaxNew/sigmaVrelMax, RAND()
|
||||
IF (sigmaVrelMaxNew/sigmaVrelMax > RAND()) THEN
|
||||
!Applies the collision
|
||||
v_i = NORM2(part_i%v)
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ MODULE moduleMesh
|
|||
INTEGER(KIND=OMP_LOCK_KIND):: lock
|
||||
!Number of collisions per volume
|
||||
INTEGER:: nColl = 0
|
||||
!Total weight of particles inside cell
|
||||
REAL(8):: totalWeight = 0.D0
|
||||
CONTAINS
|
||||
PROCEDURE(initVol_interface), DEFERRED, PASS:: init
|
||||
PROCEDURE(scatter_interface), DEFERRED, PASS:: scatter
|
||||
|
|
|
|||
|
|
@ -454,6 +454,7 @@ MODULE moduleMeshCyl
|
|||
!Assign particle to listPart_in
|
||||
CALL OMP_SET_LOCK(self%lock)
|
||||
CALL self%listPart_in%add(part)
|
||||
self%totalWeight = self%totalWeight + part%weight
|
||||
CALL OMP_UNSET_LOCK(self%lock)
|
||||
|
||||
ELSE
|
||||
|
|
@ -525,28 +526,29 @@ MODULE moduleMeshCyl
|
|||
USE moduleCollisions
|
||||
USE moduleSpecies
|
||||
USE moduleList
|
||||
use moduleRefParam
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(meshVolCyl), INTENT(inout):: self
|
||||
INTEGER:: Npart !Number of particles inside the cell
|
||||
REAL(8):: Fn !Specific weight
|
||||
REAL(8):: Pmax !Maximum probability of collision
|
||||
INTEGER:: nPart !Number of particles inside the cell
|
||||
REAL(8):: pMax !Maximum probability of collision
|
||||
INTEGER:: rnd !random index
|
||||
TYPE(particle), POINTER:: part_i, part_j
|
||||
INTEGER:: n !collision
|
||||
INTEGER:: ij, k
|
||||
REAL(8):: sigmaVrelMaxNew
|
||||
|
||||
Fn = species(1)%obj%weight!TODO: Check how to do this for multiple species
|
||||
Npart = self%listPart_in%amount
|
||||
Pmax = Fn*self%sigmaVrelMax*tau/self%volume
|
||||
self%nColl = INT(REAL(Npart*(Npart-1))*Pmax*0.5D0)
|
||||
self%nColl = 0
|
||||
nPart = self%listPart_in%amount
|
||||
IF (nPart > 1) THEN
|
||||
pMax = self%totalWeight*self%sigmaVrelMax*tau/self%volume
|
||||
self%nColl = INT(REAL(nPart)*pMax*0.5D0)
|
||||
|
||||
DO n = 1, self%NColl
|
||||
DO n = 1, self%nColl
|
||||
!Select random numbers
|
||||
rnd = 1 + FLOOR(Npart*RAND())
|
||||
rnd = 1 + FLOOR(nPart*RAND())
|
||||
part_i => self%listPart_in%get(rnd)
|
||||
rnd = 1 + FLOOR(Npart*RAND())
|
||||
rnd = 1 + FLOOR(nPart*RAND())
|
||||
part_j => self%listPart_in%get(rnd)
|
||||
ij = interactionIndex(part_i%pt, part_j%pt)
|
||||
sigmaVrelMaxNew = 0.D0
|
||||
|
|
@ -563,6 +565,10 @@ MODULE moduleMeshCyl
|
|||
|
||||
END DO
|
||||
|
||||
END IF
|
||||
|
||||
self%totalWeight = 0.D0
|
||||
|
||||
!Reset output in nodes
|
||||
CALL self%resetOutput()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue