First attempt at Coulomb collisions #46

Merged
JorgeGonz merged 21 commits from feature/CoulombLinear into development 2023-07-16 14:47:59 +02:00
Showing only changes of commit 63fc2842be - Show all commits

Small changes

Just some small changes to the code to improve its quality.

Nothing regarding conservation was done yet.
Jorge Gonzalez 2023-07-11 11:22:19 +02:00

View file

@ -971,9 +971,10 @@ MODULE moduleMesh
TYPE(outputFormat):: output TYPE(outputFormat):: output
REAL(8), ALLOCATABLE:: densityNodes(:), velocityNodes(:,:), temperatureNodes(:) !values in node REAL(8), ALLOCATABLE:: densityNodes(:), velocityNodes(:,:), temperatureNodes(:) !values in node
REAL(8):: density, velocity(1:3), temperature!values at particle position REAL(8):: density, velocity(1:3), temperature!values at particle position
REAL(8):: C(1:3), W(1:3) !relative velocity and velocity in the relative frame of reference REAL(8):: C(1:3), C_per, W(1:3) !relative velocity and velocity in the relative frame of reference
REAL(8):: l, lW, l2 REAL(8):: l, lW, l2
REAL(8):: normC, normW REAL(8):: GlW, HlW
REAL(8):: normC
REAL(8):: theta, phi !angles between w and c REAL(8):: theta, phi !angles between w and c
REAL(8):: cosThe, sinThe REAL(8):: cosThe, sinThe
REAL(8):: cosPhi, sinPhi REAL(8):: cosPhi, sinPhi
@ -1038,11 +1039,17 @@ MODULE moduleMesh
END IF END IF
theta = ACOS(C(3) / normC) theta = ACOS(C(3) / normC)
cosThe = COS(theta) cosThe = COS(theta)
sinThe = SIN(theta) sinThe = SIN(theta)
phi = SIGN(1.D0, C(1)) * ACOS(C(1) / SQRT(C(1)**2 + C(2)**2)) C_per = SQRT(C(1)**2 + C(2)**2)
IF (C_per > eps) THEN
phi = SIGN(1.D0, C(1)) * ACOS(C(1) / C_per)
ELSE
phi = 0.D0
END IF
cosPhi = COS(phi) cosPhi = COS(phi)
sinPhi = SIN(phi) sinPhi = SIN(phi)
@ -1052,14 +1059,18 @@ MODULE moduleMesh
!W at start is = (0, 0, normC), so normW = normC !W at start is = (0, 0, normC), so normW = normC
lW = l * normC lW = l * normC
GlW = G(lW)
HlW = H(lW)
A = coulombMatrix(k)%A_i*density A = coulombMatrix(k)%A_i*density
AW = A / normC AW = A / normC
deltaW_par = - A * coulombMatrix(k)%one_plus_massRatio_ij * l2 * G(lW) * tauMin !Calculate changes in W due to collision process
deltaW_par_square = SQRT(AW * G(lW) * tauMin)*randomMaxwellian() deltaW_par = - A * coulombMatrix(k)%one_plus_massRatio_ij * l2 * GlW * tauMin
deltaW_per_square = SQRT(AW * H(lW) * tauMin)*randomMaxwellian() deltaW_par_square = SQRT(AW * GlW * tauMin)*randomMaxwellian()
deltaW_per_square = SQRT(AW * HlW * tauMin)*randomMaxwellian()
theta_per = PI2*random() theta_per = PI2*random()
!Change W !Change W
W(1) = deltaW_per_square * COS(theta_per) W(1) = deltaW_per_square * COS(theta_per)
W(2) = deltaW_per_square * SIN(theta_per) W(2) = deltaW_per_square * SIN(theta_per)