Merge branch 'issue/initialIteration' into 'development'

Implementation of initial iteration.

See merge request JorgeGonz/fpakc!18
This commit is contained in:
Jorge Gonzalez 2021-04-17 09:00:57 +00:00
commit 302e4ecc1a
7 changed files with 38 additions and 26 deletions

Binary file not shown.

View file

@ -595,8 +595,13 @@ make
Array dimension 'number of species'. Array dimension 'number of species'.
Defines the different time steps for each species. Defines the different time steps for each species.
Even if all time steps are equal, they need to be defined as an array. Even if all time steps are equal, they need to be defined as an array.
\item \textbf{time}: Real. \item \textbf{finalTime}: Real.
Total simulation time in $\unit{s}$. Units of $\unit{s}$.
Final simulation time.
\item \textbf{initialTime}: Real.
Units of $\unit{s}$.
Initial simulation time.
If no value is provided, the initial time is set to $\unit[0]{s}$.
\item \textbf{pusher}: Character. \item \textbf{pusher}: Character.
Array dimension 'number of species'. Array dimension 'number of species'.
Indicates the type of pusher used for each species: Indicates the type of pusher used for each species:

View file

@ -11,7 +11,7 @@ PROGRAM fpakc
IMPLICIT NONE IMPLICIT NONE
! t = time step ! t = time step
INTEGER:: t = 0 INTEGER:: t
! arg1 = Input argument 1 (input file) ! arg1 = Input argument 1 (input file)
CHARACTER(200):: arg1 CHARACTER(200):: arg1
! inputFile = path+name of input file ! inputFile = path+name of input file
@ -26,6 +26,8 @@ PROGRAM fpakc
!Reads the json configuration file !Reads the json configuration file
CALL readConfig(inputFile) CALL readConfig(inputFile)
!Do '0' iteration
t = tInitial
!$OMP PARALLEL DEFAULT(SHARED) !$OMP PARALLEL DEFAULT(SHARED)
!$OMP SINGLE !$OMP SINGLE
@ -45,7 +47,7 @@ PROGRAM fpakc
CALL doOutput(t) CALL doOutput(t)
CALL verboseError('Starting main loop...') CALL verboseError('Starting main loop...')
!$OMP PARALLEL DEFAULT(SHARED) !$OMP PARALLEL DEFAULT(SHARED)
DO t = 1, tmax DO t = tInitial + 1, tFinal
!Insert new particles and push them !Insert new particles and push them
!$OMP SINGLE !$OMP SINGLE
tStep = omp_get_wtime() tStep = omp_get_wtime()

View file

@ -29,7 +29,7 @@ MODULE moduleMeshOutputGmsh2
WRITE(60, "(A)") '$EndMeshFormat' WRITE(60, "(A)") '$EndMeshFormat'
WRITE(60, "(A)") '$NodeData' WRITE(60, "(A)") '$NodeData'
WRITE(60, "(A)") '1' WRITE(60, "(A)") '1'
WRITE(60, "(A)") '"Density ' // species(i)%obj%name // ' (m^-3)"' WRITE(60, "(A)") '"' // species(i)%obj%name // ' density (m^-3)"'
WRITE(60, *) 1 WRITE(60, *) 1
WRITE(60, *) time WRITE(60, *) time
WRITE(60, *) 3 WRITE(60, *) 3
@ -43,7 +43,7 @@ MODULE moduleMeshOutputGmsh2
WRITE(60, "(A)") '$EndNodeData' WRITE(60, "(A)") '$EndNodeData'
WRITE(60, "(A)") '$NodeData' WRITE(60, "(A)") '$NodeData'
WRITE(60, "(A)") '1' WRITE(60, "(A)") '1'
WRITE(60, "(A)") '"Velocity ' // species(i)%obj%name // ' (m/s)"' WRITE(60, "(A)") '"' // species(i)%obj%name // ' velocity (m/s)"'
WRITE(60, *) 1 WRITE(60, *) 1
WRITE(60, *) time WRITE(60, *) time
WRITE(60, *) 3 WRITE(60, *) 3
@ -56,7 +56,7 @@ MODULE moduleMeshOutputGmsh2
WRITE(60, "(A)") '$EndNodeData' WRITE(60, "(A)") '$EndNodeData'
WRITE(60, "(A)") '$NodeData' WRITE(60, "(A)") '$NodeData'
WRITE(60, "(A)") '1' WRITE(60, "(A)") '1'
WRITE(60, "(A)") '"Pressure ' // species(i)%obj%name // ' (Pa)"' WRITE(60, "(A)") '"' // species(i)%obj%name // ' pressure (Pa)"'
WRITE(60, *) 1 WRITE(60, *) 1
WRITE(60, *) time WRITE(60, *) time
WRITE(60, *) 3 WRITE(60, *) 3
@ -69,7 +69,7 @@ MODULE moduleMeshOutputGmsh2
WRITE(60, "(A)") '$EndNodeData' WRITE(60, "(A)") '$EndNodeData'
WRITE(60, "(A)") '$NodeData' WRITE(60, "(A)") '$NodeData'
WRITE(60, "(A)") '1' WRITE(60, "(A)") '1'
WRITE(60, "(A)") '"Temperature ' // species(i)%obj%name // ' (K)"' WRITE(60, "(A)") '"' // species(i)%obj%name // ' temperature (K)"'
WRITE(60, *) 1 WRITE(60, *) 1
WRITE(60, *) time WRITE(60, *) time
WRITE(60, *) 3 WRITE(60, *) 3

View file

@ -1,7 +1,7 @@
!Problems of the case !Problems of the case
MODULE moduleCaseParam MODULE moduleCaseParam
!Maximum number of iterations and number of species !Final and initial iterations
INTEGER:: tmax INTEGER:: tFinal, tInitial = 0
REAL(8), ALLOCATABLE:: tau(:) REAL(8), ALLOCATABLE:: tau(:)
REAL(8):: tauMin REAL(8):: tauMin

View file

@ -22,7 +22,7 @@ MODULE moduleInput
!Loads the config file !Loads the config file
CALL verboseError('Loading input file...') CALL verboseError('Loading input file...')
CALL config%load(filename = inputFile) CALL config%load(filename = inputFile)
CALL checkStatus(config, "load") CALL checkStatus(config, "loading")
!Reads reference parameters !Reads reference parameters
CALL verboseError('Reading Reference parameters...') CALL verboseError('Reading Reference parameters...')
@ -151,7 +151,8 @@ MODULE moduleInput
TYPE(json_file), INTENT(inout):: config TYPE(json_file), INTENT(inout):: config
LOGICAL:: found LOGICAL:: found
CHARACTER(:), ALLOCATABLE:: object CHARACTER(:), ALLOCATABLE:: object
REAL(8):: time !simulation time in [t] !simulation final and initial times in [t]
REAL(8):: finalTime, initialTime
CHARACTER(:), ALLOCATABLE:: pusherType, EMType, WSType CHARACTER(:), ALLOCATABLE:: pusherType, EMType, WSType
INTEGER:: nTau, nSolver INTEGER:: nTau, nSolver
INTEGER:: i INTEGER:: i
@ -176,11 +177,15 @@ MODULE moduleInput
END IF END IF
tauMin = MINVAL(tau) tauMin = MINVAL(tau)
!Gets the simulation time !Gets the simulation final time
CALL config%get(object // '.time', time, found) CALL config%get(object // '.finalTime', finalTime, found)
IF (.NOT. found) CALL criticalError('Required parameter time not found','readCase') IF (.NOT. found) CALL criticalError('Required parameter finalTime not found','readCase')
!Convert simulation time to number of iterations !Convert simulation time to number of iterations
tmax = INT(time/tauMin) tFinal = INT(finalTime / tauMin)
!Gets the simulation initial time
CALL config%get(object // '.initialTime', initialTime, found)
IF (found) tInitial = INT(initialTime / tauMin)
!Gest the pusher for each species !Gest the pusher for each species
CALL config%info(object // '.pusher', found, n_children = nSolver) CALL config%info(object // '.pusher', found, n_children = nSolver)
@ -215,7 +220,7 @@ MODULE moduleInput
tauMin = tauMin / ti_ref tauMin = tauMin / ti_ref
!Sets the format of output files accordint to iteration number !Sets the format of output files accordint to iteration number
iterationDigits = INT(LOG10(REAL(tmax))) + 1 iterationDigits = INT(LOG10(REAL(tFinal))) + 1
WRITE(tString, '(I1)') iterationDigits WRITE(tString, '(I1)') iterationDigits
iterationFormat = "(I" // tString // "." // tString // ")" iterationFormat = "(I" // tString // "." // tString // ")"
@ -327,10 +332,10 @@ MODULE moduleInput
temperatureXi = temperatureXi / T_ref temperatureXi = temperatureXi / T_ref
vTh = DSQRT(temperatureXi / species(sp)%obj%m) vTh = DSQRT(temperatureXi / species(sp)%obj%m)
partNew%v(1) = velocityXi(1) + vTh*randomMaxwellian() partNew%v(1) = velocityXi(1) + vTh*randomMaxwellian()
partNew%v(2) = velocityXi(2) + vTh*randomMaxwellian() partNew%v(2) = velocityXi(2) + vTh*randomMaxwellian()
partNew%v(3) = velocityXi(3) + vTh*randomMaxwellian() partNew%v(3) = velocityXi(3) + vTh*randomMaxwellian()
partNew%vol = e partNew%vol = e
IF (ASSOCIATED(meshForMCC, mesh)) THEN IF (ASSOCIATED(meshForMCC, mesh)) THEN
partNew%volColl = partNew%vol partNew%volColl = partNew%vol
@ -338,8 +343,8 @@ MODULE moduleInput
partNew%volColl = findCellBrute(meshColl, partNew%r) partNew%volColl = findCellBrute(meshColl, partNew%r)
END IF END IF
partNew%n_in = .TRUE. partNew%n_in = .TRUE.
partNew%weight = species(sp)%obj%weight partNew%weight = species(sp)%obj%weight
!If charged species, add qm to particle !If charged species, add qm to particle
SELECT TYPE(sp => species(sp)%obj) SELECT TYPE(sp => species(sp)%obj)
TYPE IS (speciesCharged) TYPE IS (speciesCharged)

View file

@ -833,7 +833,7 @@ MODULE moduleSolver
counterOutput = counterOutput + 1 counterOutput = counterOutput + 1
IF (counterOutput >= triggerOutput .OR. & IF (counterOutput >= triggerOutput .OR. &
t == tmax .OR. t == 0) THEN t == tFinal .OR. t == tInitial) THEN
!Resets output counter !Resets output counter
counterOutput=0 counterOutput=0
@ -841,7 +841,7 @@ MODULE moduleSolver
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)
WRITE(*, "(5X,A21,I10,A1,I10)") "t/tmax: ", t, "/", tmax WRITE(*, "(5X,A21,I10,A1,I10)") "t/tFinal: ", t, "/", tFinal
WRITE(*, "(5X,A21,I10)") "Particles: ", nPartOld WRITE(*, "(5X,A21,I10)") "Particles: ", nPartOld
IF (t == 0) THEN IF (t == 0) THEN
WRITE(*, "(5X,A21,F8.1,A2)") " init time: ", 1.D3*tStep, "ms" WRITE(*, "(5X,A21,F8.1,A2)") " init time: ", 1.D3*tStep, "ms"
@ -861,7 +861,7 @@ MODULE moduleSolver
counterCPUTime = counterCPUTime + 1 counterCPUTime = counterCPUTime + 1
IF (counterCPUTime >= triggerCPUTime .OR. & IF (counterCPUTime >= triggerCPUTime .OR. &
t == tmax .OR. t == 0) THEN t == tFinal .OR. t == tInitial) THEN
!Reset CPU Time counter !Reset CPU Time counter
counterCPUTime = 0 counterCPUTime = 0