diff --git a/Build/Scripts/HYPRE/build_hypre.bat b/Build/Scripts/HYPRE/build_hypre.bat index 00fed886aff..04c0a2777ca 100644 --- a/Build/Scripts/HYPRE/build_hypre.bat +++ b/Build/Scripts/HYPRE/build_hypre.bat @@ -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 diff --git a/Build/Scripts/HYPRE/build_hypre.sh b/Build/Scripts/HYPRE/build_hypre.sh index f3a9fa6dfa5..b6dfc5ec91a 100755 --- a/Build/Scripts/HYPRE/build_hypre.sh +++ b/Build/Scripts/HYPRE/build_hypre.sh @@ -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 diff --git a/Build/Scripts/SUNDIALS/build_sundials.bat b/Build/Scripts/SUNDIALS/build_sundials.bat index 0cb3c630320..2db4f153877 100644 --- a/Build/Scripts/SUNDIALS/build_sundials.bat +++ b/Build/Scripts/SUNDIALS/build_sundials.bat @@ -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 @@ -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 diff --git a/Build/Scripts/SUNDIALS/build_sundials.sh b/Build/Scripts/SUNDIALS/build_sundials.sh index 0b0478e186a..6c9c477ae67 100755 --- a/Build/Scripts/SUNDIALS/build_sundials.sh +++ b/Build/Scripts/SUNDIALS/build_sundials.sh @@ -1,5 +1,5 @@ #!/bin/bash -SUNDIALS_LIB_TAG=v6.7.0 +SUNDIALS_LIB_TAG=v7.5.0 CONFMAKE=$1 CLEAN_SUNDIALS=$2 @@ -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 @@ -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 diff --git a/Build/Scripts/SUNDIALS/confmake.sh b/Build/Scripts/SUNDIALS/confmake.sh index b6f0caf98c0..ff35dc023f6 100755 --- a/Build/Scripts/SUNDIALS/confmake.sh +++ b/Build/Scripts/SUNDIALS/confmake.sh @@ -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 diff --git a/Build/makefile b/Build/makefile index 9a9997097cf..071a5555ff5 100644 --- a/Build/makefile +++ b/Build/makefile @@ -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 @@ -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. diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b4d5ea35e4..6889af90cee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 diff --git a/Source/chem.f90 b/Source/chem.f90 index 8998f5d56c8..d7d2cc2d327 100644 --- a/Source/chem.f90 +++ b/Source/chem.f90 @@ -15,6 +15,7 @@ MODULE CVODE_INTERFACE USE TYPES USE CHEMCONS USE, INTRINSIC :: ISO_C_BINDING +USE FSUNDIALS_CORE_MOD IMPLICIT NONE @@ -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 @@ -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 @@ -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 @@ -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) @@ -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 @@ -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. @@ -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. @@ -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 diff --git a/Utilities/Python/FDS_verification_script.py b/Utilities/Python/FDS_verification_script.py index 1a4aa81bfb7..05b8444baf6 100644 --- a/Utilities/Python/FDS_verification_script.py +++ b/Utilities/Python/FDS_verification_script.py @@ -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__") diff --git a/Utilities/Python/scripts/cantera_ignition_delay.py b/Utilities/Python/scripts/cantera_ignition_delay.py index 40004134ecb..12b9319a338 100644 --- a/Utilities/Python/scripts/cantera_ignition_delay.py +++ b/Utilities/Python/scripts/cantera_ignition_delay.py @@ -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 diff --git a/Utilities/Python/scripts/cantera_reaction_rates.py b/Utilities/Python/scripts/cantera_reaction_rates.py index 0d2e5bc9e76..7f7616840f9 100644 --- a/Utilities/Python/scripts/cantera_reaction_rates.py +++ b/Utilities/Python/scripts/cantera_reaction_rates.py @@ -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 _soln.csv file under Verification/Species folder. +""" import numpy as np import os import cantera as ct @@ -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) diff --git a/Utilities/Python/scripts/cantera_turbulent_batch_reactor.py b/Utilities/Python/scripts/cantera_turbulent_batch_reactor.py index 3eade7e7205..9c153b1f17b 100644 --- a/Utilities/Python/scripts/cantera_turbulent_batch_reactor.py +++ b/Utilities/Python/scripts/cantera_turbulent_batch_reactor.py @@ -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 _soln.csv file under Verification/Chemistry folder. """ import sys