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
|
vRel = species(1)%obj%m*NORM2(part_i%v - part_j%v)**2
|
||||||
sigmaVrel = self%crossSec%get(vRel)*vRel
|
sigmaVrel = self%crossSec%get(vRel)*vRel
|
||||||
sigmaVrelMaxNew = sigmaVrelMaxNew + sigmaVrel
|
sigmaVrelMaxNew = sigmaVrelMaxNew + sigmaVrel
|
||||||
|
PRINT *, sigmaVrelMaxNew/sigmaVrelMax, RAND()
|
||||||
IF (sigmaVrelMaxNew/sigmaVrelMax > RAND()) THEN
|
IF (sigmaVrelMaxNew/sigmaVrelMax > RAND()) THEN
|
||||||
!Applies the collision
|
!Applies the collision
|
||||||
v_i = NORM2(part_i%v)
|
v_i = NORM2(part_i%v)
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,8 @@ MODULE moduleMesh
|
||||||
INTEGER(KIND=OMP_LOCK_KIND):: lock
|
INTEGER(KIND=OMP_LOCK_KIND):: lock
|
||||||
!Number of collisions per volume
|
!Number of collisions per volume
|
||||||
INTEGER:: nColl = 0
|
INTEGER:: nColl = 0
|
||||||
|
!Total weight of particles inside cell
|
||||||
|
REAL(8):: totalWeight = 0.D0
|
||||||
CONTAINS
|
CONTAINS
|
||||||
PROCEDURE(initVol_interface), DEFERRED, PASS:: init
|
PROCEDURE(initVol_interface), DEFERRED, PASS:: init
|
||||||
PROCEDURE(scatter_interface), DEFERRED, PASS:: scatter
|
PROCEDURE(scatter_interface), DEFERRED, PASS:: scatter
|
||||||
|
|
|
||||||
|
|
@ -454,6 +454,7 @@ MODULE moduleMeshCyl
|
||||||
!Assign particle to listPart_in
|
!Assign particle to listPart_in
|
||||||
CALL OMP_SET_LOCK(self%lock)
|
CALL OMP_SET_LOCK(self%lock)
|
||||||
CALL self%listPart_in%add(part)
|
CALL self%listPart_in%add(part)
|
||||||
|
self%totalWeight = self%totalWeight + part%weight
|
||||||
CALL OMP_UNSET_LOCK(self%lock)
|
CALL OMP_UNSET_LOCK(self%lock)
|
||||||
|
|
||||||
ELSE
|
ELSE
|
||||||
|
|
@ -525,28 +526,29 @@ MODULE moduleMeshCyl
|
||||||
USE moduleCollisions
|
USE moduleCollisions
|
||||||
USE moduleSpecies
|
USE moduleSpecies
|
||||||
USE moduleList
|
USE moduleList
|
||||||
|
use moduleRefParam
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
CLASS(meshVolCyl), INTENT(inout):: self
|
CLASS(meshVolCyl), INTENT(inout):: self
|
||||||
INTEGER:: Npart !Number of particles inside the cell
|
INTEGER:: nPart !Number of particles inside the cell
|
||||||
REAL(8):: Fn !Specific weight
|
REAL(8):: pMax !Maximum probability of collision
|
||||||
REAL(8):: Pmax !Maximum probability of collision
|
|
||||||
INTEGER:: rnd !random index
|
INTEGER:: rnd !random index
|
||||||
TYPE(particle), POINTER:: part_i, part_j
|
TYPE(particle), POINTER:: part_i, part_j
|
||||||
INTEGER:: n !collision
|
INTEGER:: n !collision
|
||||||
INTEGER:: ij, k
|
INTEGER:: ij, k
|
||||||
REAL(8):: sigmaVrelMaxNew
|
REAL(8):: sigmaVrelMaxNew
|
||||||
|
|
||||||
Fn = species(1)%obj%weight!TODO: Check how to do this for multiple species
|
self%nColl = 0
|
||||||
Npart = self%listPart_in%amount
|
nPart = self%listPart_in%amount
|
||||||
Pmax = Fn*self%sigmaVrelMax*tau/self%volume
|
IF (nPart > 1) THEN
|
||||||
self%nColl = INT(REAL(Npart*(Npart-1))*Pmax*0.5D0)
|
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
|
!Select random numbers
|
||||||
rnd = 1 + FLOOR(Npart*RAND())
|
rnd = 1 + FLOOR(nPart*RAND())
|
||||||
part_i => self%listPart_in%get(rnd)
|
part_i => self%listPart_in%get(rnd)
|
||||||
rnd = 1 + FLOOR(Npart*RAND())
|
rnd = 1 + FLOOR(nPart*RAND())
|
||||||
part_j => self%listPart_in%get(rnd)
|
part_j => self%listPart_in%get(rnd)
|
||||||
ij = interactionIndex(part_i%pt, part_j%pt)
|
ij = interactionIndex(part_i%pt, part_j%pt)
|
||||||
sigmaVrelMaxNew = 0.D0
|
sigmaVrelMaxNew = 0.D0
|
||||||
|
|
@ -563,6 +565,10 @@ MODULE moduleMeshCyl
|
||||||
|
|
||||||
END DO
|
END DO
|
||||||
|
|
||||||
|
END IF
|
||||||
|
|
||||||
|
self%totalWeight = 0.D0
|
||||||
|
|
||||||
!Reset output in nodes
|
!Reset output in nodes
|
||||||
CALL self%resetOutput()
|
CALL self%resetOutput()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue