Merge branch 'improve/probes' into 'development'

Probes were not working properly

See merge request JorgeGonz/fpakc!44
This commit is contained in:
Jorge Gonzalez 2023-02-23 12:45:38 +00:00
commit 7579d165ad
6 changed files with 24 additions and 11 deletions

View file

@ -314,6 +314,7 @@ MODULE moduleInput
USE moduleOutput USE moduleOutput
USE moduleRefParam USE moduleRefParam
USE moduleRandom USE moduleRandom
USE moduleProbe
USE json_module USE json_module
IMPLICIT NONE IMPLICIT NONE
@ -420,6 +421,9 @@ MODULE moduleInput
END IF END IF
!Assign particles to probes
CALL doProbes(partNew)
END DO END DO
DEALLOCATE(sourceScalar, sourceArray) DEALLOCATE(sourceScalar, sourceArray)
@ -1089,6 +1093,8 @@ MODULE moduleInput
END DO END DO
CALL resetProbes(tInitial)
END SUBROUTINE readProbes END SUBROUTINE readProbes
SUBROUTINE readEMBoundary(config) SUBROUTINE readEMBoundary(config)

View file

@ -508,7 +508,7 @@ MODULE moduleMesh2DCart
conv = 1.D0 conv = 1.D0
XiO = 0.D0 XiO = 0.D0
DO WHILE(conv > 1.D-2) DO WHILE(conv > 1.D-4)
dPsi = self%dPsi(XiO, 4) dPsi = self%dPsi(XiO, 4)
pDer = self%partialDer(4, dPsi) pDer = self%partialDer(4, dPsi)
detJ = self%detJac(pDer) detJ = self%detJac(pDer)
@ -516,8 +516,7 @@ MODULE moduleMesh2DCart
fPsi = self%fPsi(XiO, 4) fPsi = self%fPsi(XiO, 4)
f = (/ DOT_PRODUCT(fPsi,self%x), & f = (/ DOT_PRODUCT(fPsi,self%x), &
DOT_PRODUCT(fPsi,self%y), & DOT_PRODUCT(fPsi,self%y), &
0.D0 /) 0.D0 /) - r
f = f - r
Xi = XiO - MATMUL(invJ, f)/detJ Xi = XiO - MATMUL(invJ, f)/detJ
conv = MAXVAL(DABS(Xi-XiO),1) conv = MAXVAL(DABS(Xi-XiO),1)
XiO = Xi XiO = Xi

View file

@ -532,8 +532,7 @@ MODULE moduleMesh2DCyl
fPsi = self%fPsi(XiO, 4) fPsi = self%fPsi(XiO, 4)
f = (/ DOT_PRODUCT(fPsi,self%z), & f = (/ DOT_PRODUCT(fPsi,self%z), &
DOT_PRODUCT(fPsi,self%r), & DOT_PRODUCT(fPsi,self%r), &
0.D0 /) 0.D0 /) - r
f = f - r
Xi = XiO - MATMUL(invJ, f)/detJ Xi = XiO - MATMUL(invJ, f)/detJ
conv = MAXVAL(DABS(Xi-XiO),1) conv = MAXVAL(DABS(Xi-XiO),1)
XiO = Xi XiO = Xi

View file

@ -872,7 +872,7 @@ MODULE moduleMesh
!If particles do not belong to the species, skip collision !If particles do not belong to the species, skip collision
!This can happen, for example, if particle has been previously ionized or removed !This can happen, for example, if particle has been previously ionized or removed
!TODO: Try to find a way to no lose these collisions. Maybe check new 'k' and use that for the collision, maybe? !TODO: Try to find a way to not lose these collisions. Maybe check new 'k' and use that for the collision?
IF (part_i%species%n /= i .OR. & IF (part_i%species%n /= i .OR. &
part_j%species%n /= j) THEN part_j%species%n /= j) THEN
CYCLE CYCLE

View file

@ -91,11 +91,17 @@ MODULE moduleProbe
1:self%nv(3))) 1:self%nv(3)))
!Number of iterations between output !Number of iterations between output
IF (timeStep == 0.D0) THEN
self%every = 1
ELSE
self%every = NINT(timeStep/ tauMin / ti_ref) self%every = NINT(timeStep/ tauMin / ti_ref)
END IF
!Maximum radius !Maximum radius
!TODO: Make this an input parameter !TODO: Make this an input parameter
self%maxR = 1.D-1/L_ref self%maxR = 1.D0
!Init the probe lock !Init the probe lock
CALL OMP_INIT_LOCK(self%lock) CALL OMP_INIT_LOCK(self%lock)
@ -110,6 +116,8 @@ MODULE moduleProbe
INTEGER, INTENT(out):: i, j, k INTEGER, INTENT(out):: i, j, k
LOGICAL, INTENT(out):: inside LOGICAL, INTENT(out):: inside
inside = .TRUE.
i = FLOOR((vp(1) - self%vi(1))/self%vrange(1)*(REAL(self%nv(1) - 1)) + 1.D0) i = FLOOR((vp(1) - self%vi(1))/self%vrange(1)*(REAL(self%nv(1) - 1)) + 1.D0)
IF (i >= self%nv(1) .OR. i < 1) inside = .FALSE. IF (i >= self%nv(1) .OR. i < 1) inside = .FALSE.
j = FLOOR((vp(2) - self%vj(1))/self%vrange(2)*(REAL(self%nv(2) - 1)) + 1.D0) j = FLOOR((vp(2) - self%vj(1))/self%vrange(2)*(REAL(self%nv(2) - 1)) + 1.D0)
@ -198,7 +206,7 @@ MODULE moduleProbe
WRITE(tstring, iterationFormat) t WRITE(tstring, iterationFormat) t
WRITE(pstring, "(I3.3)") self%id WRITE(pstring, "(I3.3)") self%id
fileName='OUTPUT_' // tstring// '_f_' // pstring // '.dat' fileName='Probe_' // tstring// '_f_' // pstring // '.dat'
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName WRITE(*, "(6X,A15,A)") "Creating file: ", fileName
OPEN (10, file = path // folder // '/' // fileName) OPEN (10, file = path // folder // '/' // fileName)
WRITE(10, "(A1, 1X, A)") "# ", self%species%name WRITE(10, "(A1, 1X, A)") "# ", self%species%name
@ -268,7 +276,7 @@ MODULE moduleProbe
DO i = 1, nProbes DO i = 1, nProbes
probe(i)%f = 0.D0 probe(i)%f = 0.D0
probe(i)%update = MOD(t, probe(i)%every) == 0 .OR. t == tFinal probe(i)%update = t == tFinal .OR. t == tInitial .OR. MOD(t, probe(i)%every) == 0
END DO END DO

View file

@ -523,6 +523,8 @@ MODULE moduleSolver
END IF END IF
CALL outputProbes(t)
counterOutput = counterOutput + 1 counterOutput = counterOutput + 1
IF (counterOutput >= triggerOutput .OR. & IF (counterOutput >= triggerOutput .OR. &
t == tFinal .OR. t == tInitial) THEN t == tFinal .OR. t == tInitial) THEN
@ -530,7 +532,6 @@ MODULE moduleSolver
!Resets output counter !Resets output counter
counterOutput=0 counterOutput=0
CALL outputProbes(t)
CALL mesh%printOutput(t) CALL mesh%printOutput(t)
IF (ASSOCIATED(meshForMCC)) CALL meshForMCC%printColl(t) IF (ASSOCIATED(meshForMCC)) CALL meshForMCC%printColl(t)
CALL mesh%printEM(t) CALL mesh%printEM(t)