Skip to content

Commit 881534a

Browse files
authored
Merge pull request #15538 from cxp484/FireX
FireX: Merge with firemodels/master
2 parents 41d1216 + 6e16556 commit 881534a

File tree

6 files changed

+210
-64
lines changed

6 files changed

+210
-64
lines changed

Manuals/FDS_User_Guide/FDS_User_Guide.tex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9140,7 +9140,8 @@ \section{Flux Limiters}
91409140
Central differencing & \ct{'CENTRAL'} \\
91419141
Godunov & \ct{'GODUNOV'} \\
91429142
Superbee (VLES, SVLES default) & \ct{'SUPERBEE'} \\
9143-
CHARM (DNS, LES default) & \ct{'CHARM'} \\
9143+
CHARM (DNS, LES default) & \ct{'CHARM'} \\
9144+
\hline
91449145
\end{tabular}
91459146
\end{table}
91469147

@@ -9171,9 +9172,9 @@ \subsection{Density}
91719172

91729173
The density of the gas has a natural lower bound of zero, but if the density in a cell decreases to nearly zero, the temperature would then increase to an extremely high value due to the equation of state. Thus, by default, the density is kept within the following range:
91739174
\be
9174-
\min \left( 0.1 \, \rho_\infty , \frac{2 \, p_\infty \, W_{\min}}{\R \, T_{\max}} \right) < \rho < \frac{2 \, p_\infty \, W_{\max}}{\R \, T_{\min}}
9175+
0.01 \; \mbox{kg/m$^3$} < \rho < 100 \; \mbox{kg/m$^3$}
91759176
\ee
9176-
where $W_{\min}$ and $W_{\max}$ are the minimum and maximum values of the molecular weight of the tracked gas species in units of g/mol, and $\R$ is the universal gas constant, 8314.5~J/(kmol$\cdot$K). $T_{\min}$ and $T_{\max}$ are described above. To override the limits of density, specify \ct{MINIMUM_DENSITY} and/or \ct{MAXIMUM_DENSITY} on the \ct{CLIP} line in units of kg/m$^3$.
9177+
To override the limits of density, specify \ct{MINIMUM_DENSITY} and/or \ct{MAXIMUM_DENSITY} on the \ct{CLIP} line in units of kg/m$^3$.
91779178

91789179
Clipping of density and mass fractions violates mass conservation, so it is preferable to avoid clipping if possible. As discussed in Sec.~\ref{info:Stability_Constraints}, the time step is set to adhere to the CFL constraints of the flow field. The proper \ct{DT} combined with flux limiters generally avoids the need for clipping. Beyond this, FDS then employs a mass redistribution scheme, as discussed in FDS Technical Guide~\cite{FDS_Math_Guide}. If this fails, there is yet one more attempt to avoid clipping---the time step is decreased by 10~\% ($\dt_{\mathrm{new}} = 0.9 \,\dt$) and the scalar transport equations are reiterated. This process is carried out a maximum of \ct{CLIP_DT_RESTRICTIONS_MAX} times; the default is 5. In some very extreme circumstances, this loop can drive the time step into numerical instability range ($\dt/\dt_{\mathrm{init}} < \mbox{\ct{LIMITING_DT_RATIO}}$). You can control the max number of time step restrictions by setting the parameter \ct{CLIP_DT_RESTRICTIONS_MAX} on the \ct{CLIP} line (set to 0 to bypass the algorithm altogether). The number of restrictions (if any) is noted in the \ct{CHID.out} file for a given time step.
91799180

Source/chem.f90

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ SUBROUTINE CVODE_SERIAL(CC,ZZ_0, TMP_IN, TMP_UNMIX, PR_IN, ZETA0, TAU_MIX, CELL_
807807
TMP_OUT, CHEM_TIME, WRITE_SUBSTEPS, CVODE_CALL_OPTION)
808808
USE PHYSICAL_FUNCTIONS, ONLY : MOLAR_CONC_TO_MASS_FRAC, CALC_EQUIV_RATIO, GET_ENTHALPY, GET_MOLECULAR_WEIGHT
809809
USE COMP_FUNCTIONS, ONLY: GET_FILE_NUMBER
810+
USE CHEMCONS, ONLY: CVODE_WARNING_CELLS,CVODE_ERR_CODE_MIN,CVODE_ERR_CODE_MAX
810811
USE GLOBAL_CONSTANTS
811812
USE FCVODE_MOD ! FORTRAN INTERFACE TO CVODE
812813
USE FSUNDIALS_CONTEXT_MOD ! FORTRAN INTERFACE TO SUNCONTEXT
@@ -1015,15 +1016,18 @@ SUBROUTINE CVODE_SERIAL(CC,ZZ_0, TMP_IN, TMP_UNMIX, PR_IN, ZETA0, TAU_MIX, CELL_
10151016
ENDIF
10161017

10171018
IF (IERR_C .NE. CV_SUCCESS) THEN
1018-
IF (IERR_C == CV_TOO_MUCH_WORK) THEN
1019-
WRITE(LU_ERR,'(A, 2E18.8, I8, A)')" WARN: CVODE took all internal substeps. CUR_CFD_TIME, DT, MAXTRY=", CUR_CFD_TIME, &
1020-
(TEND-TCUR), MAXTRY, ". If the warning persists, reduce the timestep."
1021-
ELSE
1022-
WRITE(LU_ERR,'(A, I4, A, 2E18.8, A)')" WARN: CVODE didn't finish ODE solution with message code:", IERR_C, &
1023-
" and CUR_CFD_TIME, DT=", CUR_CFD_TIME, (TEND-TCUR), ". If the warning persists, reduce the timestep."
1019+
IF(IERR_C>=CVODE_ERR_CODE_MIN .AND. IERR_C<=CVODE_ERR_CODE_MAX) THEN
1020+
CVODE_WARNING_CELLS(IERR_C) = CVODE_WARNING_CELLS(IERR_C) + 1
10241021
ENDIF
1025-
10261022
IF (DEBUG) THEN
1023+
IF (IERR_C == CV_TOO_MUCH_WORK) THEN
1024+
WRITE(LU_ERR,'(A, 2E18.8, I8, A)')" WARN: CVODE took all internal substeps. CUR_CFD_TIME, DT, MAXTRY=", CUR_CFD_TIME, &
1025+
(TEND-TCUR), MAXTRY, ". If the warning persists, reduce the timestep."
1026+
ELSE
1027+
WRITE(LU_ERR,'(A, I4, A, 2E18.8, A)')" WARN: CVODE didn't finish ODE solution with message code:", IERR_C, &
1028+
" and CUR_CFD_TIME, DT=", CUR_CFD_TIME, (TEND-TCUR), ". If the warning persists, reduce the timestep."
1029+
ENDIF
1030+
10271031
CALL MOLAR_CONC_TO_MASS_FRAC(CC(1:N_TRACKED_SPECIES), ZZ(1:N_TRACKED_SPECIES))
10281032
CALL CALC_EQUIV_RATIO(ZZ(1:N_TRACKED_SPECIES), EQUIV)
10291033
DO NS = 1, N_TRACKED_SPECIES

Source/cons.f90

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,10 @@ MODULE CHEMCONS
968968
INTEGER :: MAX_CVODE_SUBSTEPS=100000
969969
INTEGER :: CVODE_MAX_TRY=4
970970
INTEGER :: CVODE_ORDER=0
971+
INTEGER :: CVODE_ERR_CODE_MIN=-100
972+
INTEGER :: CVODE_ERR_CODE_MAX=100
973+
INTEGER :: CVODE_WARNING_CELLS(-100:100)! Index of the array is error code and value is Cell count
974+
CHARACTER(LEN=100) :: CVODE_WARN_MESSAGES(-100:100)
971975

972976
! FOR WRITING CVODE SUBSTEPS
973977
LOGICAL :: WRITE_CVODE_SUBSTEPS = .FALSE.
@@ -988,4 +992,12 @@ MODULE CHEMCONS
988992
INTEGER :: N_IGNITION_ZONES = 0
989993
TYPE(IGNITION_ZONE_TYPE), DIMENSION(MAX_IGNITION_ZONES) :: IGNITION_ZONES !< Coordinates of ignition zones
990994

995+
CONTAINS
996+
SUBROUTINE INIT_CVODE_WARN_MESSAGES()
997+
CVODE_WARN_MESSAGES = 'CVODE didn''t finish ODE solution with this code.'
998+
CVODE_WARN_MESSAGES(-1) = 'CVODE took all internal substeps.'
999+
CVODE_WARN_MESSAGES(-3) = 'Minimum step size was reached.'
1000+
CVODE_WARN_MESSAGES(-4) = 'Convergence test failure.'
1001+
END SUBROUTINE INIT_CVODE_WARN_MESSAGES
1002+
9911003
END MODULE CHEMCONS

Source/fire.f90

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SUBROUTINE COMBUSTION_LOAD_BALANCED(T,DT)
4141

4242
USE SOOT_ROUTINES, ONLY: SOOT_SURFACE_OXIDATION
4343
USE COMP_FUNCTIONS, ONLY: CURRENT_TIME
44+
USE CHEMCONS, ONLY: CVODE_WARNING_CELLS,INIT_CVODE_WARN_MESSAGES
4445
REAL(EB), INTENT(IN) :: T,DT
4546
INTEGER :: NM,ICC,JCC
4647
REAL(EB) :: TNOW
@@ -55,12 +56,14 @@ SUBROUTINE COMBUSTION_LOAD_BALANCED(T,DT)
5556
COMBUSTION_INIT = .TRUE.
5657
NVAR_TO_SEND = N_TRACKED_SPECIES +7 ! NS, TEMP, RHO, PRES, MU, DELTA, VOL, IGN_ZN
5758
NVAR_TO_RECEIVE = N_TRACKED_SPECIES +4 ! NS, Q_OUT, MIX_TIME_OUT, CHI_R_OUT, CHEM_SUBIT_TMP_OUT
59+
CALL INIT_CVODE_WARN_MESSAGES()
5860
ENDIF
5961

6062
DO NM=LOWER_MESH_INDEX,UPPER_MESH_INDEX
6163
CALL POINT_TO_MESH(NM)
6264
Q = 0._EB
6365
CHI_R = 0._EB
66+
CVODE_WARNING_CELLS = 0
6467
IF (CC_IBM) THEN
6568
DO ICC=1,MESHES(NM)%N_CUTCELL_MESH
6669
DO JCC=1,CUT_CELL(ICC)%NCELL
@@ -109,6 +112,7 @@ SUBROUTINE COMBUSTION_GENERAL_LOAD_BALANCED(T,DT)
109112
REAL(EB) :: MIX_TIME_OUT, Q_OUT, CHI_R_OUT, MYTEMP, MYRHO, MYMU, DELTA, VOL, TNOW2
110113
INTEGER :: IGN_ZN
111114

115+
112116
Q_EXISTS = .FALSE.
113117

114118
!------
@@ -329,6 +333,13 @@ SUBROUTINE COMBUSTION_GENERAL_LOAD_BALANCED(T,DT)
329333
ENDDO
330334
ENDIF
331335

336+
! Output accumulated CVODE warnings (instead of cell by cell) in verbose mode
337+
#ifdef WITH_SUNDIALS
338+
IF (COMBUSTION_ODE_SOLVER == CVODE_SOLVER .AND. VERBOSE) THEN
339+
CALL DUMP_CVODE_WARNING_SUMMARY(NCHEM_ACTIVE_CELLS_AND_CC)
340+
ENDIF
341+
#endif
342+
332343
END SUBROUTINE COMBUSTION_GENERAL_LOAD_BALANCED
333344

334345

@@ -1271,6 +1282,60 @@ SUBROUTINE CALC_AFT_REAC_AND_PROD(ZZ,ZZ_REAC,ZZ_PROD)
12711282

12721283
END SUBROUTINE CALC_AFT_REAC_AND_PROD
12731284

1285+
!> \brief Dump CVODE warning summary
1286+
SUBROUTINE DUMP_CVODE_WARNING_SUMMARY(NCHEM_ACTIVE_CELLS_AND_CC)
1287+
USE CHEMCONS, ONLY: CVODE_WARNING_CELLS,CVODE_ERR_CODE_MIN,CVODE_ERR_CODE_MAX,CVODE_WARN_MESSAGES
1288+
1289+
INTEGER, INTENT(IN) :: NCHEM_ACTIVE_CELLS_AND_CC
1290+
INTEGER :: NCHEM_ACTIVE_CELLS_AND_CC_GLOBAL,IERR, CVODE_ERR_CODE, TOT_WARN_CELLS
1291+
REAL(EB) :: PCNT
1292+
CHARACTER(LEN=16) :: CELL_STR, PCNT_STR
1293+
CHARACTER(LEN=40) :: CELL_INFO
1294+
1295+
IF (N_MPI_PROCESSES > 1) THEN
1296+
CALL MPI_ALLREDUCE(MPI_IN_PLACE, CVODE_WARNING_CELLS, SIZE(CVODE_WARNING_CELLS), &
1297+
MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, IERR)
1298+
1299+
CALL MPI_ALLREDUCE(NCHEM_ACTIVE_CELLS_AND_CC, NCHEM_ACTIVE_CELLS_AND_CC_GLOBAL, &
1300+
1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, IERR)
1301+
ELSE
1302+
NCHEM_ACTIVE_CELLS_AND_CC_GLOBAL = NCHEM_ACTIVE_CELLS_AND_CC
1303+
END IF
1304+
TOT_WARN_CELLS = SUM(CVODE_WARNING_CELLS)
1305+
1306+
IF (TOT_WARN_CELLS > 0 .AND. NCHEM_ACTIVE_CELLS_AND_CC_GLOBAL > 0 .AND. MY_RANK == 0) THEN
1307+
1308+
WRITE(LU_ERR, '(A)') '--------------- CVODE Warning Summary ----------------'
1309+
WRITE(LU_ERR, '(A)') ' Code Cells (% Chem) Message'
1310+
1311+
DO CVODE_ERR_CODE = CVODE_ERR_CODE_MIN, CVODE_ERR_CODE_MAX
1312+
IF (CVODE_WARNING_CELLS(CVODE_ERR_CODE) > 0) THEN
1313+
1314+
PCNT = REAL(CVODE_WARNING_CELLS(CVODE_ERR_CODE)) / &
1315+
REAL(NCHEM_ACTIVE_CELLS_AND_CC_GLOBAL) * 100.0_EB
1316+
1317+
! Convert to strings and left-align
1318+
WRITE(CELL_STR, '(I0)') CVODE_WARNING_CELLS(CVODE_ERR_CODE)
1319+
WRITE(PCNT_STR, '(F6.2)') PCNT
1320+
CELL_STR = ADJUSTL(CELL_STR)
1321+
PCNT_STR = ADJUSTL(PCNT_STR)
1322+
1323+
! Combine count + percentage into one left-aligned string
1324+
WRITE(CELL_INFO, '(A, " (", A, " %)")') TRIM(CELL_STR), TRIM(PCNT_STR)
1325+
CELL_INFO = ADJUSTL(CELL_INFO)
1326+
1327+
! Print one line of summary
1328+
WRITE(LU_ERR, '(1X, I4, 5X, A, 5X, A)') CVODE_ERR_CODE, &
1329+
TRIM(CELL_INFO), TRIM(CVODE_WARN_MESSAGES(CVODE_ERR_CODE))
1330+
END IF
1331+
END DO
1332+
1333+
WRITE(LU_ERR, '(A)') '------------------------------------------------------'
1334+
1335+
END IF
1336+
1337+
END SUBROUTINE DUMP_CVODE_WARNING_SUMMARY
1338+
12741339
#endif
12751340

12761341
SUBROUTINE CHECK_AUTO_IGNITION(EXTINCT,TMP_IN,AIT,IIC,JJC,KKC,REAC_INDEX)

0 commit comments

Comments
 (0)