First conservative implementation of Coulomb
I am doing a trick in which I ensure that energy is conserved for Coulomb collisions. This was not happening and what an issue for different mass ratios. Still, this can cause an issue on getting the right relaxation rates, still necessary to check it.
This commit is contained in:
parent
f8af7a8dae
commit
fe94615a27
4 changed files with 26 additions and 13 deletions
|
|
@ -975,10 +975,11 @@ MODULE moduleMesh
|
|||
REAL(8):: delta_par, delta_par_square, delta_per, delta_per_square
|
||||
REAL(8):: W(3), dW(2), normW !Relative velocity between particle and species and its increment
|
||||
REAL(8):: l2, l, lW, AW
|
||||
REAL(8):: deltaV(1:3), totalDeltaV_ij, normDeltaV
|
||||
REAL(8):: rnd
|
||||
|
||||
|
||||
!$OMP SINGLE
|
||||
!$OMP DO SCHEDULE(DYNAMIC) PRIVATE(partTemp)
|
||||
DO e = 1, self%numCells
|
||||
cell => self%cells(e)%obj
|
||||
cellNodes = cell%getNodes(cell%nNodes)
|
||||
|
|
@ -1003,6 +1004,7 @@ MODULE moduleMesh
|
|||
END DO
|
||||
|
||||
!Loop over particles of species_i
|
||||
totalDeltaV_ij = 0.D0
|
||||
partTemp => cell%listPart_in(i)%head
|
||||
DO WHILE(ASSOCIATED(partTemp))
|
||||
density = cell%gatherF(partTemp%part%Xi, cell%nNodes, densityNodes)
|
||||
|
|
@ -1036,16 +1038,18 @@ MODULE moduleMesh
|
|||
e2(3) = 0.D0
|
||||
e2 = normalize(e2)
|
||||
!Third one is perpendicular to the other two
|
||||
e3 = crossProduct(e2, e1)
|
||||
e3 = crossProduct(e1, e2)
|
||||
e3 = normalize(e3)
|
||||
|
||||
!Random number for direction
|
||||
rnd = PI2*random()
|
||||
|
||||
!Change particle velocity
|
||||
partTemp%part%v = partTemp%part%v + dW(1)*e1 + dW(2)*(COS(rnd)*e2 + &
|
||||
SIN(rnd)*e3)
|
||||
deltaV = dW(1)*e1 + dW(2)*(COS(rnd)*e2 + SIN(rnd)*e3)
|
||||
|
||||
totalDeltaV_ij = totalDeltaV_ij + NORM2(deltaV)
|
||||
!Change particle velocity
|
||||
partTemp%part%v = partTemp%part%v + deltaV
|
||||
|
||||
partTemp => partTemp%next
|
||||
|
||||
END DO
|
||||
|
|
@ -1062,6 +1066,8 @@ MODULE moduleMesh
|
|||
|
||||
END DO
|
||||
|
||||
!Divide total momentum exchanged among all the particles of species j
|
||||
normDeltaV = totalDeltaV_ij / REAL(cell%listPart_in(j)%amount) * (self%sp_i%weight*self%sp_i%m)/(self%sp_j%weight*self%sp_j%m)
|
||||
!Loop over particles of species_j
|
||||
partTemp => cell%listPart_in(j)%head
|
||||
DO WHILE(ASSOCIATED(partTemp))
|
||||
|
|
@ -1086,6 +1092,10 @@ MODULE moduleMesh
|
|||
dW(1) = delta_par*tauMin + randomMaxwellian()*SQRT(delta_par_square*tauMin)
|
||||
dW(2) = ABS(randomMaxwellian()*SQRT(delta_per_square*tauMin))
|
||||
|
||||
!Normalize with average exchange per particle
|
||||
!TODO: This is a dirty trick, it should not be neccessary but I don't lnow why it is.
|
||||
dW = normDeltaV*dW/NORM2(dW)
|
||||
|
||||
!System of reference for the velocity change
|
||||
!First one is parallel to the relative velocity
|
||||
e1 = normalize(W)
|
||||
|
|
@ -1095,15 +1105,16 @@ MODULE moduleMesh
|
|||
e2(3) = 0.D0
|
||||
e2 = normalize(e2)
|
||||
!Third one is perpendicular to the other two
|
||||
e3 = crossProduct(e2, e1)
|
||||
e3 = crossProduct(e1, e2)
|
||||
e3 = normalize(e3)
|
||||
|
||||
!Random number for direction
|
||||
rnd = PI2*random()
|
||||
|
||||
deltaV = dW(1)*e1 + dW(2)*(COS(rnd)*e2 + SIN(rnd)*e3)
|
||||
|
||||
!Change particle velocity
|
||||
partTemp%part%v = partTemp%part%v + dW(1)*e1 + dW(2)*(COS(rnd)*e2 + &
|
||||
SIN(rnd)*e3)
|
||||
partTemp%part%v = partTemp%part%v + deltaV
|
||||
|
||||
partTemp => partTemp%next
|
||||
|
||||
|
|
@ -1114,7 +1125,7 @@ MODULE moduleMesh
|
|||
END DO
|
||||
|
||||
END DO
|
||||
!$OMP END SINGLE
|
||||
!$OMP END DO
|
||||
|
||||
END SUBROUTINE doCoulomb
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue