Rework of injection of particles with a special focus in 2DCyl to ensure an homogeneous distribution. #51
3 changed files with 18 additions and 27 deletions
Switching to variable particle weight
I have to change the injection of particles. Each edge will receive a similar number of particles and their weight will change to have a constant density based on the geometry. Still testing.
commit
b972120ed5
|
|
@ -40,10 +40,10 @@ MODULE moduleRandom
|
||||||
INTEGER:: rnd
|
INTEGER:: rnd
|
||||||
REAL(8):: rnd01
|
REAL(8):: rnd01
|
||||||
|
|
||||||
rnd = 0.D0
|
rnd = 0
|
||||||
CALL RANDOM_NUMBER(rnd01)
|
CALL RANDOM_NUMBER(rnd01)
|
||||||
|
|
||||||
rnd = INT(REAL(b - a) * rnd01) + 1
|
rnd = NINT(REAL(b - a) * rnd01) + a
|
||||||
|
|
||||||
END FUNCTION randomIntAB
|
END FUNCTION randomIntAB
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,7 @@ MODULE moduleMesh2DCyl
|
||||||
p1 = (/self%z(1), self%r(1) /)
|
p1 = (/self%z(1), self%r(1) /)
|
||||||
p2 = (/self%z(2), self%r(2) /)
|
p2 = (/self%z(2), self%r(2) /)
|
||||||
r(1:2) = (1.D0 - rnd)*p1 + rnd*p2
|
r(1:2) = (1.D0 - rnd)*p1 + rnd*p2
|
||||||
|
r(2) = (self%r(2) + self%r(1)) * 0.5D0
|
||||||
r(3) = 0.D0
|
r(3) = 0.D0
|
||||||
|
|
||||||
END FUNCTION randPosEdge
|
END FUNCTION randPosEdge
|
||||||
|
|
@ -578,9 +579,6 @@ MODULE moduleMesh2DCyl
|
||||||
REAL(8):: detJ
|
REAL(8):: detJ
|
||||||
REAL(8):: fPsi(1:4)
|
REAL(8):: fPsi(1:4)
|
||||||
REAL(8):: dPsi(1:3, 1:4), pDer(1:3, 1:3)
|
REAL(8):: dPsi(1:3, 1:4), pDer(1:3, 1:3)
|
||||||
REAL(8):: nodeR(1:3)
|
|
||||||
REAL(8), PARAMETER:: correction = 0.81D0 !TODO: No idea why this is needed, this needs more attention. Probably a better
|
|
||||||
! calculation of the volume is needed.
|
|
||||||
|
|
||||||
self%volume = 0.D0
|
self%volume = 0.D0
|
||||||
|
|
||||||
|
|
@ -594,26 +592,18 @@ MODULE moduleMesh2DCyl
|
||||||
!Computes total volume of the cell
|
!Computes total volume of the cell
|
||||||
self%volume = r*detJ*PI8 !4*2*pi
|
self%volume = r*detJ*PI8 !4*2*pi
|
||||||
!Computes volume per node
|
!Computes volume per node
|
||||||
self%n1%v = self%n1%v + fPsi(1)*self%volume
|
Xi = (/-5.D-1, -5.D-1, 0.D0/)
|
||||||
nodeR = self%n1%getCoordinates()
|
r = self%gatherF(Xi, 4, self%r)
|
||||||
if (nodeR(2) == 0.D0) then
|
self%n1%v = self%n1%v + fPsi(1)*r*detJ*PI8
|
||||||
self%n1%v = self%n1%v * correction
|
Xi = (/ 5.D-1, -5.D-1, 0.D0/)
|
||||||
end if
|
r = self%gatherF(Xi, 4, self%r)
|
||||||
self%n2%v = self%n2%v + fPsi(2)*self%volume
|
self%n2%v = self%n2%v + fPsi(2)*r*detJ*PI8
|
||||||
nodeR = self%n2%getCoordinates()
|
Xi = (/ 5.D-1, 5.D-1, 0.D0/)
|
||||||
if (nodeR(2) == 0.D0) then
|
r = self%gatherF(Xi, 4, self%r)
|
||||||
self%n2%v = self%n2%v * correction
|
self%n3%v = self%n3%v + fPsi(3)*r*detJ*PI8
|
||||||
end if
|
Xi = (/-5.D-1, 5.D-1, 0.D0/)
|
||||||
self%n3%v = self%n3%v + fPsi(3)*self%volume
|
r = self%gatherF(Xi, 4, self%r)
|
||||||
nodeR = self%n3%getCoordinates()
|
self%n4%v = self%n4%v + fPsi(4)*r*detJ*PI8
|
||||||
if (nodeR(2) == 0.D0) then
|
|
||||||
self%n3%v = self%n3%v * correction
|
|
||||||
end if
|
|
||||||
self%n4%v = self%n4%v + fPsi(4)*self%volume
|
|
||||||
nodeR = self%n4%getCoordinates()
|
|
||||||
if (nodeR(2) == 0.D0) then
|
|
||||||
self%n4%v = self%n4%v * correction
|
|
||||||
end if
|
|
||||||
|
|
||||||
END SUBROUTINE volumeQuad
|
END SUBROUTINE volumeQuad
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,7 @@ MODULE moduleInject
|
||||||
USE moduleMesh
|
USE moduleMesh
|
||||||
USE moduleRandom
|
USE moduleRandom
|
||||||
USE moduleErrors
|
USE moduleErrors
|
||||||
|
USE moduleRefParam, ONLY: L_ref
|
||||||
IMPLICIT NONE
|
IMPLICIT NONE
|
||||||
|
|
||||||
CLASS(injectGeneric), INTENT(in):: self
|
CLASS(injectGeneric), INTENT(in):: self
|
||||||
|
|
@ -312,12 +313,12 @@ MODULE moduleInject
|
||||||
|
|
||||||
!$OMP DO
|
!$OMP DO
|
||||||
DO n = nMin, nMax
|
DO n = nMin, nMax
|
||||||
randomX = randomWeighted(self%cumWeight, self%sumWeight)
|
randomX = random(1, self%nEdges)
|
||||||
randomEdge => mesh%edges(self%edges(randomX))%obj
|
randomEdge => mesh%edges(self%edges(randomX))%obj
|
||||||
!Random position in edge
|
!Random position in edge
|
||||||
partInj(n)%r = randomEdge%randPos()
|
partInj(n)%r = randomEdge%randPos()
|
||||||
!Assign weight to particle.
|
!Assign weight to particle.
|
||||||
partInj(n)%weight = self%species%weight
|
partInj(n)%weight = self%species%weight * sqrt(partInj(n)%r(2) / (0.1D0*L_ref))
|
||||||
!Volume associated to the edge:
|
!Volume associated to the edge:
|
||||||
IF (ASSOCIATED(randomEdge%e1)) THEN
|
IF (ASSOCIATED(randomEdge%e1)) THEN
|
||||||
partInj(n)%cell = randomEdge%e1%n
|
partInj(n)%cell = randomEdge%e1%n
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue