First attempt at Coulomb collisions

First attemp for Coulomb collisions based on the moments distribtuions.
Still the method is not done and far from being complete but input
options and basic math are implemented.
This commit is contained in:
Jorge Gonzalez 2023-02-24 21:46:01 +01:00
commit 601103105f
8 changed files with 295 additions and 26 deletions

View file

@ -0,0 +1,91 @@
MODULE moduleCoulomb
USE moduleSpecies
IMPLICIT NONE
INTEGER:: nCoulombPairs = 0
!Type for Coulomb iteraction matrix
TYPE:: interactionsCoulomb
CLASS(speciesGeneric), POINTER:: sp_i
CLASS(speciesGeneric), POINTER:: sp_j
REAL(8):: one_plus_massRatio_ij, one_plus_massRatio_ji
REAL(8):: lnCoulomb !This can be done a function in the future
REAL(8):: A_ij, A_ji
REAL(8):: l_j, l_i
CONTAINS
PROCEDURE, PASS:: init => initInteractionCoulomb
END TYPE interactionsCoulomb
!Coulomb collision 'matrix'
TYPE(interactionsCoulomb), ALLOCATABLE:: coulombMatrix(:)
CONTAINS
PURE REAL(8) FUNCTION G(x)
USE moduleConstParam
IMPLICIT NONE
REAL(8), INTENT(in):: x
G = 0.D0
IF (x /= 0.D0) THEN
G = (ERF(x) - x*2.D0/SQRT(PI)*EXP(-x**2))/(2.D0*x**2)
END IF
END FUNCTION G
PURE REAL(8) FUNCTION H(x)
IMPLICIT NONE
REAL(8), INTENT(in):: x
H = ERF(x) - G(x)
END FUNCTION H
SUBROUTINE initInteractionCoulomb(self, i, j)
USE moduleSpecies
USE moduleErrors
USE moduleConstParam
USE moduleRefParam
IMPLICIT NONE
CLASS(interactionsCoulomb), INTENT(out):: self
INTEGER, INTENT(in):: i, j
REAL(8):: Z_i, Z_j
self%sp_i => species(i)%obj
self%sp_j => species(j)%obj
self%one_plus_massRatio_ij = 1.D0 + (self%sp_i%weight*self%sp_i%m)/(self%sp_j%weight*self%sp_j%m)
self%one_plus_massRatio_ji = 1.D0 + (self%sp_j%weight*self%sp_j%m)/(self%sp_i%weight*self%sp_i%m)
SELECT TYPE(sp => self%sp_i)
TYPE IS (speciesCharged)
Z_i = sp%q
CLASS DEFAULT
CALL criticalError('Species ' // sp%name // ' for Coulomb scattering has no charge', 'initInteractionCoulomb')
END SELECT
SELECT TYPE(sp => self%sp_j)
TYPE IS (speciesCharged)
Z_j = sp%q
CLASS DEFAULT
CALL criticalError('Species ' // sp%name // ' for Coulomb scattering has no charge', 'initInteractionCoulomb')
END SELECT
self%lnCoulomb = 12.0
self%A_ij = 8.D0*PI*Z_i**2*Z_j**2*e_ref**4*self%lnCoulomb / self%sp_i%m
self%A_ji = 8.D0*PI*Z_j**2*Z_i**2*e_ref**4*self%lnCoulomb / self%sp_j%m
self%l_j = SQRT(self%sp_j%m / 2.D0) !Missing temperature because it's cell dependent
self%l_i = SQRT(self%sp_i%m / 2.D0) !Missing temperature because it's cell dependent
END SUBROUTINE initInteractionCoulomb
END MODULE moduleCoulomb