Now, the solver needs to be an input parameter of the case, to select if it is for charged or neutral particles. Resolution of Poisson equation with Dirichlet boundary conditions is possible. The source vector is the charge density. This resolution is done in two steps to save computational time: 1. When reading the mesh, the PLU factorization of the K matrix is computed. 2. In each iteration, the system K*u = f is solved, in which f is the source vector (charge density) and u is the solution (potential) in each node. No case has been added to the repository. This will be done in next commit. The 'non-analog' scheme has been commented. It still needs to split the particle to avoid 'overweight' particles.
130 lines
3.6 KiB
Fortran
130 lines
3.6 KiB
Fortran
!Contains information about output
|
|
MODULE moduleOutput
|
|
IMPLICIT NONE
|
|
!Output for each node
|
|
TYPE outputNode
|
|
REAL(8):: den, mom(1:3), tensorS(1:3,1:3)
|
|
|
|
END TYPE
|
|
|
|
!Type for EM data in node
|
|
TYPE emNode
|
|
CHARACTER(:), ALLOCATABLE:: type
|
|
REAL(8):: phi
|
|
|
|
END TYPE emNode
|
|
|
|
!Output in dimensional units to print
|
|
TYPE outputFormat
|
|
REAL(8):: density, velocity(1:3), pressure, temperature
|
|
|
|
END TYPE
|
|
|
|
CHARACTER(:), ALLOCATABLE:: path
|
|
CHARACTER(:), ALLOCATABLE:: folder
|
|
INTEGER:: triggerOutput, counterOutput
|
|
LOGICAL:: timeOutput = .FALSE.
|
|
LOGICAL:: collOutput = .FALSE.
|
|
LOGICAL:: emOutput = .FALSE.
|
|
|
|
CONTAINS
|
|
FUNCTION outerProduct(a,b) RESULT(s)
|
|
IMPLICIT NONE
|
|
|
|
REAL(8), DIMENSION(1:3):: a, b
|
|
REAL(8):: s(1:3,1:3)
|
|
|
|
s = SPREAD(a, dim = 2, ncopies = 3)*SPREAD(b, dim = 1, ncopies = 3)
|
|
|
|
END FUNCTION outerProduct
|
|
|
|
FUNCTION tensorTrace(a) RESULT(t)
|
|
IMPLICIT NONE
|
|
|
|
REAL(8), DIMENSION(1:3,1:3):: a
|
|
REAL(8):: t
|
|
|
|
t = 0.D0
|
|
t = a(1,1)+a(2,2)+a(3,3)
|
|
|
|
END FUNCTION tensorTrace
|
|
|
|
SUBROUTINE calculateOutput(rawValues, formatValues, nodeVol, speciesIn)
|
|
USE moduleConstParam
|
|
USE moduleRefParam
|
|
USE moduleSpecies
|
|
IMPLICIT NONE
|
|
|
|
TYPE(outputNode), INTENT(in):: rawValues
|
|
TYPE(outputFormat), INTENT(out):: formatValues
|
|
REAL(8), INTENT(in):: nodeVol
|
|
CLASS(speciesGeneric), INTENT(in):: speciesIn
|
|
REAL(8), DIMENSION(1:3,1:3):: tensorTemp
|
|
REAL(8), DIMENSION(1:3):: tempVel
|
|
REAL(8):: tempVol
|
|
|
|
!Resets the node outputs
|
|
formatValues%density = 0.D0
|
|
formatValues%velocity = 0.D0
|
|
formatValues%pressure = 0.D0
|
|
formatValues%temperature = 0.D0
|
|
tempVol = 1.D0/(nodeVol*Vol_ref)
|
|
IF (rawValues%den > 0.D0) THEN
|
|
tempVel = rawValues%mom(:)/rawValues%den
|
|
IF ((tempVel(1) - 1.D0) .EQ. tempVel(1)) THEN
|
|
PRINT *, rawValues%mom
|
|
END IF
|
|
tensorTemp = (rawValues%tensorS(:,:) - rawValues%den*outerProduct(tempVel,tempVel))
|
|
formatValues%density = rawValues%den*tempVol
|
|
formatValues%velocity(:) = tempVel
|
|
IF (tensorTrace(tensorTemp) > 0.D0) THEN
|
|
formatValues%pressure = speciesIn%m*tensorTrace(tensorTemp)*tempVol/3.D0
|
|
formatValues%temperature = formatValues%pressure/(formatValues%density*kb)
|
|
|
|
END IF
|
|
END IF
|
|
|
|
formatValues%velocity = formatValues%velocity*v_ref
|
|
formatValues%pressure = formatValues%pressure*m_ref*v_ref**2
|
|
formatValues%temperature = formatValues%temperature*m_ref*v_ref**2
|
|
|
|
END SUBROUTINE calculateOutput
|
|
|
|
SUBROUTINE printTime(t, first)
|
|
USE moduleSpecies
|
|
USE moduleCompTime
|
|
IMPLICIT NONE
|
|
|
|
INTEGER, INTENT(in):: t
|
|
LOGICAL, INTENT(in), OPTIONAL:: first
|
|
CHARACTER(:), ALLOCATABLE:: fileName
|
|
|
|
fileName = 'cpuTime.dat'
|
|
|
|
IF (timeOutput) THEN
|
|
IF (PRESENT(first)) THEN
|
|
IF (first) THEN
|
|
OPEN(20, file = path // folder // '/' // fileName, action = 'write')
|
|
WRITE(20, "(A1, 8X, A1, 9X, A1, 5(A20))") "#","t","n","total","push","reset","collision","weighting"
|
|
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName
|
|
|
|
ELSE
|
|
|
|
END IF
|
|
OPEN(20, file = path // folder // '/' // fileName, position = 'append', action = 'write')
|
|
|
|
ELSE
|
|
OPEN(20, file = path // folder // '/' // fileName, position = 'append', action = 'write')
|
|
|
|
END IF
|
|
|
|
WRITE (20, "(I10, I10, 5(ES20.6E3))") t, nPartOld, tStep, tPush, tReset, tColl, tWeight
|
|
|
|
CLOSE(20)
|
|
|
|
END IF
|
|
|
|
END SUBROUTINE printTime
|
|
|
|
END MODULE moduleOutput
|
|
|