Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Build/Scripts/HYPRE/build_hypre.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
set LIB_TAG=v2.33.0
set LIB_TAG=v3.0.0

::*** library and tag name are the same

Expand Down
4 changes: 2 additions & 2 deletions Build/Scripts/HYPRE/build_hypre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ fi

echo "Checking for hypre library..."

if [ -d "$FIREMODELS/libs/hypre" ]; then
if [ -d "$FIREMODELS/libs/hypre/$HYPRE_LIB_TAG" ]; then
echo "Hypre library exists. Skipping hypre build."
# List all directories under $FIREMODELS/libs/hypre
hypre_lib_dir=$(ls -d $FIREMODELS/libs/hypre/*/)
hypre_lib_dir=$(ls -d $FIREMODELS/libs/hypre/$HYPRE_LIB_TAG/)
# Extract the version part (removes the leading path)
HYPRE_VERSION=$(basename $hypre_lib_dir)
export HYPRE_HOME=$FIREMODELS/libs/hypre/$HYPRE_VERSION
Expand Down
6 changes: 3 additions & 3 deletions Build/Scripts/SUNDIALS/build_sundials.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
set LIB_TAG=v6.7.0
set LIB_TAG=v7.5.0

::*** library and tag name are the same

Expand Down Expand Up @@ -123,8 +123,8 @@ cmake ..\ ^
-DBUILD_SHARED_LIBS=OFF ^
-DCMAKE_INSTALL_LIBDIR="lib" ^
-DCMAKE_MAKE_PROGRAM="%CMAKE_MAKE_PROGRAM%" ^
-DCMAKE_C_FLAGS_RELEASE="${CMAKE_C_FLAGS_RELEASE} /MT" ^
-DCMAKE_C_FLAGS_DEBUG="${CMAKE_C_FLAGS_DEBUG} /MTd"
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" ^
-DSUNDIALS_LOGGING_LEVEL=0

::*** build and install sundials

Expand Down
7 changes: 3 additions & 4 deletions Build/Scripts/SUNDIALS/build_sundials.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
SUNDIALS_LIB_TAG=v6.7.0
SUNDIALS_LIB_TAG=v7.5.0

CONFMAKE=$1
CLEAN_SUNDIALS=$2
Expand All @@ -15,10 +15,10 @@ fi

echo "Checking for sundials library..."

if [ -d "$FIREMODELS/libs/sundials" ]; then
if [ -d "$FIREMODELS/libs/sundials/$SUNDIALS_LIB_TAG" ]; then
echo "Sundials library exists. Skipping sundials build."
# List all directories under $FIREMODELS/libs/sundials
sundials_lib_dir=$(ls -d $FIREMODELS/libs/sundials/*/)
sundials_lib_dir=$(ls -d $FIREMODELS/libs/sundials/$SUNDIALS_LIB_TAG/)
# Extract the version part (removes the leading path)
SUNDIALS_VERSION=$(basename $sundials_lib_dir)
export SUNDIALS_HOME=$FIREMODELS/libs/sundials/$SUNDIALS_VERSION
Expand Down Expand Up @@ -47,7 +47,6 @@ if [ -d "$FIREMODELS/sundials" ]; then
else
echo "Your SUNDIALS repository is not up to date with the required tag: $SUNDIALS_LIB_TAG."
echo "The FDS build requires SUNDIALS version $SUNDIALS_LIB_TAG. Please update your SUNDIALS repository."
exit 1
fi
mkdir $FIREMODELS/sundials/BUILDDIR
cd $FIREMODELS/sundials/BUILDDIR
Expand Down
1 change: 1 addition & 0 deletions Build/Scripts/SUNDIALS/confmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cmake_args=(
-DEXAMPLES_ENABLE_F2003=OFF
-DENABLE_OPENMP=OFF
-DCMAKE_INSTALL_LIBDIR="lib"
-DSUNDIALS_LOGGING_LEVEL=0
)

# Add OSX deployment target if building for macOS
Expand Down
7 changes: 3 additions & 4 deletions Build/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

VPATH = ../Source

# 3rd party library versions
HYPRE_VERSION=v3.0.0
SUNDIALS_VERSION=v6.7.0
SUNDIALS_VERSION=v7.5.0

ifeq ($(shell echo "check_quotes"),"check_quotes")
# windows
Expand Down Expand Up @@ -113,8 +112,8 @@ endif # MKLROOT test
ifdef SUNDIALS_HOME # This assumes the SUNDIALS library is available.
FFLAGS_SUNDIALS = -DWITH_SUNDIALS ${SUNDIALS_INFO} -I"${SUNDIALS_HOME}/fortran"
FFLAGS_SUNDIALS_WIN = -DWITH_SUNDIALS ${SUNDIALS_INFO} /I"${SUNDIALS_HOME}\fortran"
LFLAGS_SUNDIALS = ${SUNDIALS_HOME}/lib/libsundials_fcvode_mod.a ${SUNDIALS_HOME}/lib/libsundials_fnvecserial_mod.a ${SUNDIALS_HOME}/lib/libsundials_cvode.a
LFLAGS_SUNDIALS_WIN = ${SUNDIALS_HOME}\lib\sundials_fcvode_mod.lib ${SUNDIALS_HOME}\lib\sundials_fnvecserial_mod.lib ${SUNDIALS_HOME}\lib\sundials_cvode.lib /link /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:libcmtd.lib
LFLAGS_SUNDIALS = ${SUNDIALS_HOME}/lib/libsundials_fcvode_mod.a ${SUNDIALS_HOME}/lib/libsundials_fnvecserial_mod.a ${SUNDIALS_HOME}/lib/libsundials_cvode.a ${SUNDIALS_HOME}/lib/libsundials_fcore_mod.a ${SUNDIALS_HOME}/lib/libsundials_core.a
LFLAGS_SUNDIALS_WIN = ${SUNDIALS_HOME}\lib\sundials_fcvode_mod_static.lib ${SUNDIALS_HOME}\lib\sundials_fnvecserial_mod_static.lib ${SUNDIALS_HOME}\lib\sundials_cvode_static.lib ${SUNDIALS_HOME}\lib\sundials_fcore_mod.lib ${SUNDIALS_HOME}\lib\sundials_core_static.lib /link /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:libcmtd.lib
endif

ifdef HYPRE_HOME # This assumes the HYPRE library is available.
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ if(USE_HYPRE)
include(FetchContent)
# As we are not using the system hypre, we need to choose the version we
# want
set(HYPRE_GIT_VERSION "2.32.0" )
set(HYPRE_GIT_VERSION "3.0.0" )
FetchContent_Declare(
HYPRE
GIT_REPOSITORY https://github.com/hypre-space/hypre.git
Expand Down Expand Up @@ -186,7 +186,7 @@ if(USE_SUNDIALS)
include(FetchContent)
# As we are not using the system sundials, we need to choose the version
# we want
set(SUNDIALS_GIT_VERSION "6.7.0")
set(SUNDIALS_GIT_VERSION "7.5.0")
FetchContent_Declare(
SUNDIALS
GIT_REPOSITORY https://github.com/LLNL/sundials.git
Expand Down
37 changes: 18 additions & 19 deletions Source/chem.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ MODULE CVODE_INTERFACE
USE TYPES
USE CHEMCONS
USE, INTRINSIC :: ISO_C_BINDING
USE FSUNDIALS_CORE_MOD

IMPLICIT NONE

Expand Down Expand Up @@ -44,7 +45,6 @@ MODULE CVODE_INTERFACE
INTEGER(C_INT) FUNCTION RHSFN(TN_C, SUNVEC_Y, SUNVEC_F, C_USER_DATA) &
RESULT(IERR) BIND(C,NAME='RHSFN')

USE FSUNDIALS_NVECTOR_MOD

! CALLING VARIABLES
REAL(C_DOUBLE), VALUE :: TN_C ! CURRENT TIME
Expand Down Expand Up @@ -268,9 +268,7 @@ INTEGER(C_INT) FUNCTION JACFN(TN_C, SUNVEC_Y, SUNVEC_F, SUNMAT_J, &
C_USER_DATA, TMP1, TMP2, TMP3) &
RESULT(IERR) BIND(C,NAME='JACFN')

USE FSUNDIALS_NVECTOR_MOD
USE FSUNMATRIX_DENSE_MOD
USE FSUNDIALS_MATRIX_MOD

! CALLING VARIABLES
REAL(C_DOUBLE), VALUE :: TN_C ! CURRENT TIME
Expand Down Expand Up @@ -810,13 +808,9 @@ SUBROUTINE CVODE_SERIAL(CC,ZZ_0, TMP_IN, TMP_UNMIX, PR_IN, ZETA0, TAU_MIX, CELL_
USE CHEMCONS, ONLY: CVODE_WARNING_CELLS,CVODE_ERR_CODE_MIN,CVODE_ERR_CODE_MAX
USE GLOBAL_CONSTANTS
USE FCVODE_MOD ! FORTRAN INTERFACE TO CVODE
USE FSUNDIALS_CONTEXT_MOD ! FORTRAN INTERFACE TO SUNCONTEXT
USE FNVECTOR_SERIAL_MOD ! FORTRAN INTERFACE TO SERIAL N_VECTOR
USE FSUNMATRIX_DENSE_MOD ! FORTRAN INTERFACE TO DENSE SUNMATRIX
USE FSUNLINSOL_DENSE_MOD ! FORTRAN INTERFACE TO DENSE SUNLINEARSOLVER
USE FSUNDIALS_LINEARSOLVER_MOD ! FORTRAN INTERFACE TO GENERIC SUNLINEARSOLVER
USE FSUNDIALS_MATRIX_MOD ! FORTRAN INTERFACE TO GENERIC SUNMATRIX
USE FSUNDIALS_NVECTOR_MOD ! FORTRAN INTERFACE TO GENERIC N_VECTOR

REAL(EB), INTENT(INOUT) :: CC(N_TRACKED_SPECIES)
REAL(EB), INTENT(IN) :: ZZ_0(N_TRACKED_SPECIES),TMP_IN,TMP_UNMIX,PR_IN,ZETA0,TAU_MIX,CELL_MASS,TCUR,TEND
Expand Down Expand Up @@ -864,7 +858,7 @@ SUBROUTINE CVODE_SERIAL(CC,ZZ_0, TMP_IN, TMP_UNMIX, PR_IN, ZETA0, TAU_MIX, CELL_
ATOLVEC_C(N_TRACKED_SPECIES+2) = 0.001_EB

! CREATE SUNDIALS CONTEXT
IERR_C = FSUNCONTEXT_CREATE(C_NULL_PTR, SUNCTX)
IERR_C = FSUNCONTEXT_CREATE(SUN_COMM_NULL, SUNCTX)

! CREATE SUNDIALS N_VECTOR
SUNVEC_Y => FN_VMAKE_SERIAL(NEQ, CVEC_C, SUNCTX)
Expand Down Expand Up @@ -943,7 +937,7 @@ SUBROUTINE CVODE_SERIAL(CC,ZZ_0, TMP_IN, TMP_UNMIX, PR_IN, ZETA0, TAU_MIX, CELL_
ENDIF

! SET ERROR HANDLER
IERR_C = FCVODESETERRHANDLERFN(CVODE_MEM, C_FUNLOC(FDS_CVODE_ERR_HANDLER), C_NULL_PTR)
IERR_C = FSUNCONTEXT_PUSHERRHANDLER(SUNCTX, C_FUNLOC(FDS_CVODE_ERR_HANDLER), C_NULL_PTR)
IF (IERR_C /= 0) THEN
WRITE(LU_ERR,*) 'ERROR IN FCVODESETMAXNUMSTEPS, IERR = ', IERR_C, '; HALTING'
STOP 1
Expand Down Expand Up @@ -1069,21 +1063,25 @@ END SUBROUTINE CVODE_SERIAL
!> \param FUNC_NAME The functio name where error occured send by CVODE
!> \param MESSAGE The error message
!> \param USER_DATA User data, not used in FDS.
SUBROUTINE FDS_CVODE_ERR_HANDLER( ERR_CODE, MOD_NAME, FUNC_NAME, MESSAGE, USER_DATA) &
SUBROUTINE FDS_CVODE_ERR_HANDLER(LINE, FUNC_NAME, FILE_NAME, MESSAGE, ERR_CODE, USER_DATA, CTX) &
BIND(C,NAME='FDS_CVODE_ERR_HANDLER')
INTEGER(C_INT), VALUE :: ERR_CODE
CHARACTER(KIND=C_CHAR),DIMENSION(*),INTENT(IN) :: MOD_NAME
CHARACTER(KIND=C_CHAR),DIMENSION(*),INTENT(IN) :: FUNC_NAME
CHARACTER(KIND=C_CHAR),DIMENSION(*),INTENT(IN) :: MESSAGE
TYPE(C_PTR), VALUE :: USER_DATA ! USER-DEFINED DATA

INTEGER(C_INT), VALUE :: LINE
CHARACTER(KIND=C_CHAR),DIMENSION(*),INTENT(IN):: FUNC_NAME
CHARACTER(KIND=C_CHAR),DIMENSION(*),INTENT(IN):: FILE_NAME
CHARACTER(KIND=C_CHAR),DIMENSION(*),INTENT(IN):: MESSAGE
INTEGER(C_INT), VALUE :: ERR_CODE
TYPE(C_PTR), VALUE :: USER_DATA
TYPE(C_PTR), VALUE :: CTX ! SUNCONTEXT POINTER

CHARACTER(LEN=200) :: TEMP_STRING
LOGICAL :: FOUND_NULL
INTEGER :: J


IF (DEBUG) THEN
WRITE(LU_ERR,'(A, E18.8)')" WARN: CVODE message at CFD time. CUR_CFD_TIME=", CUR_CFD_TIME
WRITE(LU_ERR,*) ' CVODE CODE : ', ERR_CODE
WRITE(LU_ERR,*) ' LINE NUMBER : ', LINE

! Print Message
FOUND_NULL = .FALSE.
Expand All @@ -1104,14 +1102,14 @@ SUBROUTINE FDS_CVODE_ERR_HANDLER( ERR_CODE, MOD_NAME, FUNC_NAME, MESSAGE, USER_D
TEMP_STRING = ''
J = 1
DO WHILE (.NOT. FOUND_NULL)
IF (MOD_NAME(J) == C_NULL_CHAR) THEN
IF (FILE_NAME(J) == C_NULL_CHAR) THEN
FOUND_NULL = .TRUE.
ELSE
TEMP_STRING(J:J) = MOD_NAME(J)
TEMP_STRING(J:J) = FILE_NAME(J)
J = J + 1
END IF
END DO
WRITE(LU_ERR,*) ' MODULE : ', TRIM(TEMP_STRING)
WRITE(LU_ERR,*) ' FILE NAME : ', TRIM(TEMP_STRING)

! Print func name
FOUND_NULL = .FALSE.
Expand All @@ -1128,6 +1126,7 @@ SUBROUTINE FDS_CVODE_ERR_HANDLER( ERR_CODE, MOD_NAME, FUNC_NAME, MESSAGE, USER_D
WRITE(LU_ERR,*) ' FUNCTION : ', TRIM(TEMP_STRING)

IF (.NOT. C_ASSOCIATED(USER_DATA)) WRITE(LU_ERR,*)" NO USER_DATA IS PROVIDED"
IF (.NOT. C_ASSOCIATED(CTX)) WRITE(LU_ERR,*)" SUNCONTEXT IS NOT VALID"
ENDIF

END SUBROUTINE FDS_CVODE_ERR_HANDLER
Expand Down
3 changes: 0 additions & 3 deletions Utilities/Python/FDS_verification_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
print("Using:", fdsplotlib.__file__)
# Scripts to run prior to dataplot

# print("ignition_delay..."); runpy.run_path("./scripts/cantera_ignition_delay.py", run_name="__main__")
# print("reaction_rates..."); runpy.run_path("./scripts/cantera_reaction_rates.py", run_name="__main__")
# print("turbulent_batch_reactor..."); runpy.run_path("./scripts/cantera_turbulent_batch_reactor.py", run_name="__main__")
print("ashrae_7..."); runpy.run_path("./scripts/ashrae_7.py", run_name="__main__")
print('burke_schumann...'); runpy.run_path("./scripts/burke_schumann.py", run_name="__main__")
print('cat_propane_depo...'); runpy.run_path("./scripts/cat_propane_depo.py", run_name="__main__")
Expand Down
4 changes: 4 additions & 0 deletions Utilities/Python/scripts/cantera_ignition_delay.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This script calculates ignition delays of different chamical mechanisms using Cantera.
This script creates the cantera_ignition_delay.csv file under Verification/Chemistry folder.
"""
import numpy as np
import time
import os
Expand Down
6 changes: 5 additions & 1 deletion Utilities/Python/scripts/cantera_reaction_rates.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This script calculates reaction rates using Cantera to validate the FDS Chemistry implementation for two-three steps mechanisms.
This script creates the <caseName>_soln.csv file under Verification/Species folder.
"""
import numpy as np
import os
import cantera as ct
Expand Down Expand Up @@ -61,7 +65,7 @@ def calc_reaction_rate(mechanismFile, T0, P0, Y0, tstart, tend, dt, caseName, co
stateArrReduced = stateArr[::writeInterval]
columnNames = ['Time'] + gas.species_names + ['Temperature'] + ['Pressure']
csvdata = pd.DataFrame(stateArrReduced, columns=columnNames)
# save_csv_file(Species_DIR+caseName+"_soln.csv",csvdata)
save_csv_file(Species_DIR+caseName+"_soln.csv",csvdata)



Expand Down
7 changes: 2 additions & 5 deletions Utilities/Python/scripts/cantera_turbulent_batch_reactor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""
McDermott
21 May 2024

Turbulent Batch Reactor (TBR) model
Constant-pressure, adiabatic kinetics simulation.
Turbulent batch reactor script using Cantera to validate the FDS turbulence batch reactor model implementation.
This script creates the <caseName>_soln.csv file under Verification/Chemistry folder.
"""

import sys
Expand Down
Loading