From d1e73297eb9f51a6586c78e07bb53dc39ed8c4ea Mon Sep 17 00:00:00 2001 From: JGonzalez Date: Sun, 27 Jul 2025 18:17:01 +0200 Subject: [PATCH] Adjust flux when no particlesPerEdge is used This does not affects the cases of the IEPC, but I am also doing other stuff. --- src/modules/moduleInject.f90 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/moduleInject.f90 b/src/modules/moduleInject.f90 index b6fc64b..000823e 100644 --- a/src/modules/moduleInject.f90 +++ b/src/modules/moduleInject.f90 @@ -199,17 +199,21 @@ MODULE moduleInject END DO + self%nParticles = SUM(self%particlesPerEdge) + ELSE ! No particles assigned per edge, use the species weight self%weightPerEdge = self%species%weight DO et = 1, self%nEdges - self%particlesPerEdge(et) = FLOOR(fluxPerStep*mesh%edges(self%edges(et))%obj%surface /self%species%weight) - + self%particlesPerEdge(et) = max(1,FLOOR(fluxPerStep*mesh%edges(self%edges(et))%obj%surface / self%species%weight)) END DO - END IF + self%nParticles = SUM(self%particlesPerEdge) - self%nParticles = SUM(self%particlesPerEdge) + !Rescale weight to match flux + self%weightPerEdge = fluxPerStep * self%surface / (real(self%nParticles)) + + END IF !Scale particles for different species steps IF (self%nParticles == 0) CALL criticalError("The number of particles for inject is 0.", 'initInject')