Merge IEPC2025 #54

Merged
JorgeGonz merged 19 commits from IEPC2025 into development 2025-09-23 18:42:06 +02:00
2 changed files with 18 additions and 4 deletions
Showing only changes of commit 7f73b69dc2 - Show all commits

Fix injection

Half-Maxwellian distribution should inject particles correctly
Jorge Gonzalez 2025-07-27 17:14:38 +02:00

View file

@ -66,6 +66,23 @@ MODULE moduleRandom
END FUNCTION randomMaxwellian END FUNCTION randomMaxwellian
!Returns a random number in a Maxwellian distribution of mean 0 and width 1
FUNCTION randomHalfMaxwellian() RESULT(rnd)
IMPLICIT NONE
REAL(8):: rnd
REAL(8):: x
rnd = 0.D0
x = 0.D0
DO WHILE (x == 0.D0)
CALL RANDOM_NUMBER(x)
END DO
rnd = DSQRT(-DLOG(x))
END FUNCTION randomHalfMaxwellian
!Returns a random number weighted with the cumWeight array !Returns a random number weighted with the cumWeight array
FUNCTION randomWeighted(cumWeight, sumWeight) RESULT(rnd) FUNCTION randomWeighted(cumWeight, sumWeight) RESULT(rnd)
IMPLICIT NONE IMPLICIT NONE

View file

@ -298,10 +298,7 @@ MODULE moduleInject
REAL(8):: v REAL(8):: v
v = 0.D0 v = 0.D0
DO WHILE (v <= 0.D0) v = self%vTh*randomHalfMaxwellian()
v = self%vTh*randomMaxwellian()
END DO
END FUNCTION randomVelHalfMaxwellian END FUNCTION randomVelHalfMaxwellian