Improve to collisions
Improvement into the collision model to better compute number of particles collisions.
This commit is contained in:
parent
97718209cc
commit
78a97ed7a0
12 changed files with 227 additions and 219 deletions
|
|
@ -662,17 +662,24 @@ MODULE moduleMesh
|
|||
CLASS(meshVol), POINTER:: vol
|
||||
INTEGER:: nPart !Number of particles inside the cell
|
||||
REAL(8):: pMax !Maximum probability of collision
|
||||
INTEGER:: rnd !random index
|
||||
TYPE(pointerArray), ALLOCATABLE:: partTemp(:)
|
||||
INTEGER:: i, j !random particle indexes
|
||||
TYPE(particle), POINTER:: part_i, part_j
|
||||
INTEGER:: n !collision
|
||||
INTEGER:: ij, k
|
||||
REAL(8):: sigmaVrelMaxNew
|
||||
TYPE(pointerArray), ALLOCATABLE:: partTemp(:)
|
||||
REAL(8):: vRel, eRel
|
||||
REAL(8):: sigmaVrelTotal
|
||||
REAL(8), ALLOCATABLE:: sigmaVrel(:), probabilityColl(:)
|
||||
REAL(8):: rnd !Random number for collision
|
||||
INTEGER:: realCollisions
|
||||
|
||||
IF (MOD(t, everyColl) == 0) THEN
|
||||
!Collisions need to be performed in this iteration
|
||||
!$OMP DO SCHEDULE(DYNAMIC)
|
||||
DO e=1, self%numVols
|
||||
|
||||
realCollisions = 0
|
||||
|
||||
vol => self%vols(e)%obj
|
||||
nPart = vol%listPart_in%amount
|
||||
|
||||
|
|
@ -694,21 +701,54 @@ MODULE moduleMesh
|
|||
END IF
|
||||
|
||||
DO n = 1, vol%nColl
|
||||
!Select random numbers
|
||||
rnd = random(1, nPart)
|
||||
part_i => partTemp(rnd)%part
|
||||
rnd = random(1, nPart)
|
||||
part_j => partTemp(rnd)%part
|
||||
ij = interactionIndex(part_i%species%n, part_j%species%n)
|
||||
sigmaVrelMaxNew = 0.D0
|
||||
DO k = 1, interactionMatrix(ij)%amount
|
||||
CALL interactionMatrix(ij)%collisions(k)%obj%collide(vol%sigmaVrelMax, sigmaVrelMaxNew, part_i, part_j)
|
||||
|
||||
!Select random different particles
|
||||
i = 0
|
||||
j = 0
|
||||
DO WHILE (i == j)
|
||||
i = random(1, nPart)
|
||||
j = random(1, nPart)
|
||||
END DO
|
||||
part_i => partTemp(i)%part
|
||||
part_j => partTemp(j)%part
|
||||
!TODO: I think that from here forward it can be passed to a procedure in interactionMatrix
|
||||
ij = interactionIndex(part_i%species%n, part_j%species%n)
|
||||
|
||||
!Update maximum cross section*v_rel per each collision
|
||||
IF (sigmaVrelMaxNew > vol%sigmaVrelMax) THEN
|
||||
vol%sigmaVrelMax = sigmaVrelMaxNew
|
||||
IF (interactionMatrix(ij)%amount > 0) THEN
|
||||
!Obtain the cross sections for the different processes
|
||||
vRel = NORM2(part_i%v-part_j%v)
|
||||
eRel = interactionMatrix(ij)%rMass*vRel**2
|
||||
CALL interactionMatrix(ij)%getSigmaVrel(vRel, eRel, sigmaVrelTotal, sigmaVrel)
|
||||
|
||||
!Update maximum sigma*v_rel
|
||||
IF (sigmaVrelTotal > vol%sigmaVrelMax) THEN
|
||||
vol%sigmaVrelMax = sigmaVrelTotal
|
||||
|
||||
END IF
|
||||
|
||||
ALLOCATE(probabilityColl(0:interactionMatrix(ij)%amount))
|
||||
probabilityColl(0) = 0.0
|
||||
probabilityColl(1:interactionMatrix(ij)%amount) = sigmaVrel/vol%sigmaVrelMax
|
||||
|
||||
!Selects random number between 0 and 1
|
||||
rnd = random()
|
||||
|
||||
!If the random number is below the total probability of collision, do collisions
|
||||
IF (rnd < sigmaVrelTotal / vol%sigmaVrelMax) THEN
|
||||
|
||||
!Loop over collisions
|
||||
DO k = 1, interactionMatrix(ij)%amount
|
||||
IF (SUM(probabilityColl(0:k-1)) + rnd <= probabilityColl(k)) THEN
|
||||
CALL interactionMatrix(ij)%collisions(k)%obj%collide(part_i, part_j, vRel)
|
||||
realCollisions = realCollisions + 1
|
||||
|
||||
END IF
|
||||
|
||||
END DO
|
||||
|
||||
END IF
|
||||
|
||||
!Deallocate arrays for next collision
|
||||
DEALLOCATE(sigmaVrel, probabilityColl)
|
||||
|
||||
END IF
|
||||
|
||||
|
|
@ -716,6 +756,8 @@ MODULE moduleMesh
|
|||
|
||||
END IF
|
||||
|
||||
vol%nColl = realCollisions
|
||||
|
||||
END DO
|
||||
!$OMP END DO
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue