From e9c86b4678ba9447c0f7cab1f683f4273147e5ce Mon Sep 17 00:00:00 2001 From: JGonzalez Date: Sat, 24 Dec 2022 11:30:20 +0100 Subject: [PATCH] Modification of Weighting scheme The weighting scheme has been modified so that particles are splitted without modifying the weight. I have to look a bit more into this. --- src/modules/moduleSolver.f90 | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/modules/moduleSolver.f90 b/src/modules/moduleSolver.f90 index be78420..d0b2d01 100644 --- a/src/modules/moduleSolver.f90 +++ b/src/modules/moduleSolver.f90 @@ -660,24 +660,18 @@ MODULE moduleSolver TYPE(particle), INTENT(inout):: part CLASS(meshVol), POINTER, INTENT(in):: volOld CLASS(meshVol), POINTER, INTENT(inout):: volNew - REAL(8):: fractionVolume, fractionWeight - INTEGER:: nSplit + REAL(8):: fractionVolume, pSplit - !If particle has change cell, call Weighting scheme - IF (volOld%n /= volNew%n) THEN + !If particle changes volume to smaller cell + IF (volOld%volume > volNew%volume) THEN fractionVolume = volOld%volume/volNew%volume - part%weight = part%weight * fractionVolume + !Calculate probability of splitting particle + pSplit = 1.D0 - DEXP(-fractionVolume) - fractionWeight = part%weight / part%species%weight - - IF (fractionWeight >= 2.D0) THEN - nSplit = FLOOR(fractionWeight) - CALL splitParticle(part, nSplit, volNew) - - ELSEIF (part%weight < 1.D0) THEN - !Particle has lost statistical meaning and will be terminated - part%n_in = .FALSE. + IF (random() < pSplit THEN + !Split particle in two + CALL splitParticle(part, 2, volNew) END IF