From 8ae558f3c84dbe4b0044cc6cf85587dfe7f66d10 Mon Sep 17 00:00:00 2001 From: JGonzalez Date: Wed, 4 Feb 2026 11:23:03 +0100 Subject: [PATCH] Correction to ensure always correct direction in the injection --- src/modules/moduleInject.f90 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/moduleInject.f90 b/src/modules/moduleInject.f90 index cb1c7fb..0d761ea 100644 --- a/src/modules/moduleInject.f90 +++ b/src/modules/moduleInject.f90 @@ -391,15 +391,15 @@ MODULE moduleInject partInj(n)%v = self%vMod*direction + (/ self%v(1)%obj%randomVel(), & self%v(2)%obj%randomVel(), & self%v(3)%obj%randomVel() /) + !If injecting a no-drift distribution and velocity is negative, reflect + if ((self%vMod == 0.D0) .and. & + (dot_product(direction, partInj(n)%v) < 0.D0)) then + partInj(n)%v = - partInj(n)%v + + end if + end do - !If injecting a no-drift distribution and velocity is negative, reflect - if ((self%vMod == 0.D0) .and. & - (dot_product(direction, partInj(n)%v) < 0.D0)) then - partInj(n)%v = - partInj(n)%v - - end if - !Obtain natural coordinates of particle in cell partInj(n)%Xi = mesh%cells(partInj(n)%cell)%obj%phy2log(partInj(n)%r) !Push new particle with the minimum time step