Merge branch 'feature/collisionPairs' into feature/electromagnetic

Merging branches and fixing a number of important issues:

- Initial particles were not being assigned to the list of particles.

- List of particles was being erased every iteration, even if species
  was not pushed.

These caused issues with the calculation of collisions when a species
was frozen.

Now, things should work properly. All particles are properly added to
the volume list and the list is erased ONLY if the species has been
updated.

I hope that collisions are now properly accounted for per species pair.
This commit is contained in:
Jorge Gonzalez 2022-04-23 20:48:34 +02:00
commit cbb5fe0bf2
12 changed files with 179 additions and 81 deletions

View file

@ -67,6 +67,8 @@ MODULE moduleCollisions
!Type for interaction matrix
TYPE:: interactionsBinary
CLASS(speciesGeneric), POINTER:: sp_i
CLASS(speciesGeneric), POINTER:: sp_j
INTEGER:: amount
REAL(8):: rMass !Reduced mass
TYPE(collisionCont), ALLOCATABLE:: collisions(:)
@ -142,16 +144,24 @@ MODULE moduleCollisions
END FUNCTION interactionIndex
!Inits the binary interaction
SUBROUTINE initInteractionBinary(self, amount, mass_i, mass_j)
SUBROUTINE initInteractionBinary(self, amount, i, j)
USE moduleMath
USE moduleSpecies
IMPLICIT NONE
CLASS(interactionsBinary), INTENT(inout):: self
INTEGER, INTENT(in):: amount
REAL(8), INTENT(in):: mass_i, mass_j
INTEGER, INTENT(in):: i, j
REAL(8):: mass_i, mass_j
self%sp_i => species(i)%obj
self%sp_j => species(j)%obj
self%amount = amount
mass_i = species(i)%obj%m
mass_j = species(j)%obj%m
self%rMass = reducedMass(mass_i, mass_j)
ALLOCATE(self%collisions(1:self%amount))
@ -165,14 +175,14 @@ MODULE moduleCollisions
REAL(8), INTENT(in):: vRel, eRel
REAL(8), INTENT(out):: sigmaVrelTotal
REAL(8), INTENT(out), ALLOCATABLE:: sigmaVrel(:)
INTEGER:: k
INTEGER:: c
sigmaVrelTotal = 0.D0
ALLOCATE(sigmaVrel(1:self%amount))
DO k = 1, self%amount
sigmaVrel(k) = self%collisions(k)%obj%crossSec%get(eRel)*vRel
DO c = 1, self%amount
sigmaVrel(c) = self%collisions(c)%obj%crossSec%get(eRel)*vRel
END DO
sigmaVrelTotal = SUM(sigmaVrel)
@ -222,8 +232,13 @@ MODULE moduleCollisions
vp = vRel*randomDirectionVHS()
!Assign velocities to particles
PRINT *, part_i%v
part_i%v = vCM + m_j*vp / (m_i + m_j)
PRINT *, part_i%v
PRINT *, part_j%v
part_j%v = vCM - m_i*vp / (m_i + m_j)
PRINT *, part_j%v
PRINT *
END SUBROUTINE collideBinaryElastic