diff --git a/.github/workflows/CPU_inferencce_validation.yml b/.github/workflows/CPU_inferencce_validation.yml index c77ed47f4..de3113b8c 100644 --- a/.github/workflows/CPU_inferencce_validation.yml +++ b/.github/workflows/CPU_inferencce_validation.yml @@ -33,6 +33,7 @@ jobs: conda activate libcantera conda install -c cantera libcantera-devel=2.6 conda install pytorch pybind11 + conda install pkg-config conda install --channel https://conda.anaconda.org/zhaofeng-shu33 easydict git clone https://github.com/deepmodeling/deepflame-dev.git cd deepflame-dev @@ -52,7 +53,7 @@ jobs: && cp -r flareFGM_Table_Download/SandiaD/flare.tbl examples/dfLowMachFoam/2DSandiaD_flareFGM/ && git clone https://github.com/intelligent-algorithm-team/intelligent-combustion.git && cp -r intelligent-combustion/DeePCK/Model/HE04_Hydrogen_ESH2_GMS_sub_20221101/ mechanisms/ && source ~/miniconda3/etc/profile.d/conda.sh && conda activate libcantera && source /opt/openfoam7/etc/bashrc - && . configure.sh && source ./bashrc && . install.sh + && . configure.sh --use_pytorch&& source ./bashrc && . install.sh && cd test && ./Allrun && conda deactivate " - name: test diff --git a/applications/solvers/df0DFoam/CMakeLists.txt b/applications/solvers/df0DFoam/CMakeLists.txt index e579696ed..270d5e183 100644 --- a/applications/solvers/df0DFoam/CMakeLists.txt +++ b/applications/solvers/df0DFoam/CMakeLists.txt @@ -29,7 +29,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as- SET(CMAKE_C_COMPILER g++) SET(PATH_LIB_OPENMPI "openmpi-system") # Foundation version -SET(EXE_COMPILE_OPTION "-std=c++17 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 +SET(EXE_COMPILE_OPTION "-std=c++14 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 diff --git a/applications/solvers/df0DFoam/Make/options b/applications/solvers/df0DFoam/Make/options index 2dcb7285d..c31ba58b8 100644 --- a/applications/solvers/df0DFoam/Make/options +++ b/applications/solvers/df0DFoam/Make/options @@ -1,6 +1,6 @@ -include $(GENERAL_RULES)/mplibType -EXE_INC = -std=c++17 \ +EXE_INC = -std=c++14 \ -Wno-unused-variable \ -Wno-unused-but-set-variable \ -Wno-old-style-cast \ diff --git a/applications/solvers/dfHighSpeedFoam/CMakeLists.txt b/applications/solvers/dfHighSpeedFoam/CMakeLists.txt index f37407970..e510c852a 100644 --- a/applications/solvers/dfHighSpeedFoam/CMakeLists.txt +++ b/applications/solvers/dfHighSpeedFoam/CMakeLists.txt @@ -29,7 +29,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as- SET(CMAKE_C_COMPILER g++) SET(PATH_LIB_OPENMPI "openmpi-system") # Foundation version -SET(EXE_COMPILE_OPTION "-std=c++17 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 +SET(EXE_COMPILE_OPTION "-std=c++14 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 diff --git a/applications/solvers/dfHighSpeedFoam/Make/options b/applications/solvers/dfHighSpeedFoam/Make/options index 6108bdb19..eaa122c08 100644 --- a/applications/solvers/dfHighSpeedFoam/Make/options +++ b/applications/solvers/dfHighSpeedFoam/Make/options @@ -1,6 +1,6 @@ -include $(GENERAL_RULES)/mplibType -EXE_INC = -std=c++17 \ +EXE_INC = -std=c++14 \ -Wno-unused-variable \ -Wno-unused-but-set-variable \ -Wno-old-style-cast \ diff --git a/applications/solvers/dfLowMachFoam/CMakeLists.txt b/applications/solvers/dfLowMachFoam/CMakeLists.txt index 1899beec8..68168e717 100644 --- a/applications/solvers/dfLowMachFoam/CMakeLists.txt +++ b/applications/solvers/dfLowMachFoam/CMakeLists.txt @@ -33,7 +33,7 @@ SET (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}) SET(CMAKE_C_COMPILER g++) SET(PATH_LIB_OPENMPI "openmpi-system") # Foundation version -SET(EXE_COMPILE_OPTION "-std=c++17 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 +SET(EXE_COMPILE_OPTION "-std=c++14 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 diff --git a/applications/solvers/dfLowMachFoam/Make/options b/applications/solvers/dfLowMachFoam/Make/options index 78152c7fa..67c743453 100644 --- a/applications/solvers/dfLowMachFoam/Make/options +++ b/applications/solvers/dfLowMachFoam/Make/options @@ -1,6 +1,6 @@ -include $(GENERAL_RULES)/mplibType -EXE_INC = -std=c++17 \ +EXE_INC = -std=c++14 \ -g \ -fopenmp \ -Wno-unused-variable \ diff --git a/applications/solvers/dfSprayFoam/CMakeLists.txt b/applications/solvers/dfSprayFoam/CMakeLists.txt index a71f1a0ae..549970049 100644 --- a/applications/solvers/dfSprayFoam/CMakeLists.txt +++ b/applications/solvers/dfSprayFoam/CMakeLists.txt @@ -29,7 +29,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as- SET(CMAKE_C_COMPILER g++) SET(PATH_LIB_OPENMPI "openmpi-system") # Foundation version -SET(EXE_COMPILE_OPTION "-std=c++17 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 +SET(EXE_COMPILE_OPTION "-std=c++14 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 diff --git a/applications/solvers/dfSprayFoam/Make/options b/applications/solvers/dfSprayFoam/Make/options index 90d6d495e..4098a7740 100644 --- a/applications/solvers/dfSprayFoam/Make/options +++ b/applications/solvers/dfSprayFoam/Make/options @@ -1,6 +1,6 @@ -include $(GENERAL_RULES)/mplibType -EXE_INC = -std=c++17 \ +EXE_INC = -std=c++14 \ -Wno-unused-variable \ -Wno-unused-but-set-variable \ -Wno-old-style-cast \ diff --git a/applications/utilities/flameSpeed/Make/options b/applications/utilities/flameSpeed/Make/options index 070d9aa11..f9fc54cc3 100644 --- a/applications/utilities/flameSpeed/Make/options +++ b/applications/utilities/flameSpeed/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -Wno-unused-variable \ -Wno-unused-but-set-variable \ -Wno-old-style-cast \ diff --git a/src/TurbulenceModels/compressible/Make/options b/src/TurbulenceModels/compressible/Make/options index a595de104..5a6c23eb2 100644 --- a/src/TurbulenceModels/compressible/Make/options +++ b/src/TurbulenceModels/compressible/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ diff --git a/src/TurbulenceModels/turbulenceModels/Make/options b/src/TurbulenceModels/turbulenceModels/Make/options index 3f961524d..351ac4581 100755 --- a/src/TurbulenceModels/turbulenceModels/Make/options +++ b/src/TurbulenceModels/turbulenceModels/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ diff --git a/src/dfCanteraMixture/Make/options b/src/dfCanteraMixture/Make/options index 1d43f4107..1c14f9398 100644 --- a/src/dfCanteraMixture/Make/options +++ b/src/dfCanteraMixture/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -Wno-old-style-cast \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ diff --git a/src/dfChemistryModel/Make/options b/src/dfChemistryModel/Make/options index 9b8be4544..411866f73 100644 --- a/src/dfChemistryModel/Make/options +++ b/src/dfChemistryModel/Make/options @@ -1,6 +1,6 @@ -include $(GENERAL_RULES)/mplibType -EXE_INC = -std=c++17 \ +EXE_INC = -std=c++14 \ -Wno-old-style-cast \ $(PFLAGS) $(PINC) \ $(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \ diff --git a/src/dfChemistryModel/dfChemistryModel.C b/src/dfChemistryModel/dfChemistryModel.C index 8a6809e76..20a785aa3 100644 --- a/src/dfChemistryModel/dfChemistryModel.C +++ b/src/dfChemistryModel/dfChemistryModel.C @@ -69,6 +69,20 @@ Foam::dfChemistryModel::dfChemistryModel alpha_(const_cast(thermo.alpha())), T_(thermo.T()), p_(thermo.p()), + mixfrac_ + ( + IOobject + ( + "Z", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar(dimless, -1) + ), + useThermoTranNN(false), // rho_(mesh_.objectRegistry::lookupObject("rho")), rho_(const_cast(dynamic_cast(thermo).rho())), // mu_(const_cast(dynamic_cast(thermo).mu()())), @@ -183,6 +197,15 @@ Foam::dfChemistryModel::dfChemistryModel time_vec2ndarray_ = 0; time_python_ = 0; + + useThermoTranNN = this->lookupOrDefault("useThermoTranNN", false); + if(useThermoTranNN) + { + call_ThermoTranNN = pybind11::module_::import("ThermoTranNN"); + Info << nl << "ThermoTranNN.py was loaded." << nl << endl; + } + + #endif #if defined USE_LIBTORCH || defined USE_PYTORCH @@ -391,9 +414,10 @@ void Foam::dfChemistryModel::setNumerics(Cantera::ReactorNet &sim) sim.setTolerances(relTol_,absTol_); } + template void Foam::dfChemistryModel::correctThermo() -{ +{ try { psi_.oldTime(); @@ -404,51 +428,115 @@ void Foam::dfChemistryModel::correctThermo() { yTemp_[i] = Y_[i][celli]; } - CanteraGas_->setState_PY(p_[celli], yTemp_.begin()); - if(mixture_.heName()=="ha") + if(useThermoTranNN) { - CanteraGas_->setState_HP(thermo_.he()[celli], p_[celli]); // setState_HP needs (J/kg) + #ifdef USE_PYTORCH + psi_.oldTime(); + pybind11::str fuel = call_ThermoTranNN.attr("fuel"); + pybind11::str ox = call_ThermoTranNN.attr("ox"); + Info << "using ThermoNet" << endl; + const scalarField& inputH = thermo_.he().primitiveField(); + const scalarField& inputP = p_.primitiveField(); + CanteraGas_->setMassFractions(yTemp_.begin()); + + Info << CanteraGas_->mixtureFraction(fuel,ox) << endl; + mixfrac_[celli] = CanteraGas_->mixtureFraction(fuel,ox); + scalarField inputZ = mixfrac_.primitiveField(); + + pybind11::array_t vec6 = pybind11::array_t({inputH.size()}, {8}, &inputH[0]); // cast vector to np.array + // pybind11::array_t vec7 = pybind11::array_t({inputP.size()}, {8}, &inputP[0]); + pybind11::array_t vec8 = pybind11::array_t({inputZ.size()}, {8}, &inputZ[0]); + + Info << "vectors have all been constructed \n" << endl; + // pybind11::object result1 = call_ThermoTranNN.attr("useNet1")(vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7); // for rho only + pybind11::object result1 = call_ThermoTranNN.attr("useNet1")(vec8, vec6); + pybind11::array_t result_array1(result1); + double* data_ptr1 = result_array1.mutable_data(); + pybind11::object result2 = call_ThermoTranNN.attr("useNet2")(vec8, vec6); // call python function, for T only + pybind11::array_t result_array2(result2);// Convert the pybind11::object result to a pybind11::array_t object + double* data_ptr2 = result_array2.mutable_data(); // Get the pointer to the data in the array + pybind11::object result3 = call_ThermoTranNN.attr("useNet3")(vec8, vec6); + pybind11::array_t result_array3(result3); + double* data_ptr3 = result_array3.mutable_data(); + pybind11::object result4 = call_ThermoTranNN.attr("useNet4")(vec8, vec6); + pybind11::array_t result_array4(result4); + double* data_ptr4 = result_array4.mutable_data(); + pybind11::object result5 = call_ThermoTranNN.attr("useNet5")(vec8, vec6); + pybind11::array_t result_array5(result5); + double* data_ptr5 = result_array5.mutable_data(); + forAll(T_, celli) + { + T_[celli] = data_ptr2[celli]; + psi_[celli] = data_ptr3[3*celli+2]; + rho_[celli] = data_ptr1[celli]; + mu_[celli] = data_ptr3[3*celli]; + alpha_[celli] = data_ptr3[3*celli+1]; + + rhoD_[0][celli] = data_ptr4[6*celli]; // O2 + rhoD_[1][celli] = data_ptr4[6*celli+4];//H2O + rhoD_[2][celli] = data_ptr4[6*celli+1]; //CH4 + rhoD_[3][celli] = data_ptr4[6*celli+2]; //CO + rhoD_[4][celli] = data_ptr4[6*celli+3]; //CO2 + rhoD_[5][celli] = data_ptr4[6*celli+5]; //N2 + + hai_[0][celli] = data_ptr5[6*celli]; // O2 + hai_[1][celli] = data_ptr5[6*celli+4]; //H2O + hai_[2][celli] = data_ptr5[6*celli+1]; //CH4 + hai_[3][celli] = data_ptr5[6*celli+2]; //CO + hai_[4][celli] = data_ptr5[6*celli+3]; //CO2 + hai_[5][celli] = data_ptr5[6*celli+5]; //N2 + } + #endif + } - else if(mixture_.heName()=="ea") + else { - scalar ha = thermo_.he()[celli] + p_[celli]/rho_[celli]; - CanteraGas_->setState_HP(ha, p_[celli]); - } + CanteraGas_->setState_PY(p_[celli], yTemp_.begin()); + if(mixture_.heName()=="ha") + { + CanteraGas_->setState_HP(thermo_.he()[celli], p_[celli]); // setState_HP needs (J/kg) + } + else if(mixture_.heName()=="ea") + { + scalar ha = thermo_.he()[celli] + p_[celli]/rho_[celli]; + CanteraGas_->setState_HP(ha, p_[celli]); + } - T_[celli] = CanteraGas_->temperature(); + T_[celli] = CanteraGas_->temperature(); - psi_[celli] = mixture_.psi(p_[celli],T_[celli]); + psi_[celli] = mixture_.psi(p_[celli],T_[celli]); - rho_[celli] = mixture_.rho(p_[celli],T_[celli]); + rho_[celli] = mixture_.rho(p_[celli],T_[celli]); - mu_[celli] = mixture_.CanteraTransport()->viscosity(); // Pa-s + mu_[celli] = mixture_.CanteraTransport()->viscosity(); // Pa-s - if (mixture_.transportModelName() == "UnityLewis") - { - alpha_[celli] = mu_[celli] / 0.7; - forAll(rhoD_, i) + if (mixture_.transportModelName() == "UnityLewis") { - rhoD_[i][celli] = alpha_[celli]; + alpha_[celli] = mu_[celli] / 0.7; + forAll(rhoD_, i) + { + rhoD_[i][celli] = alpha_[celli]; + } } - } - else - { - alpha_[celli] = mixture_.CanteraTransport()->thermalConductivity()/(CanteraGas_->cp_mass()); // kg/(m*s) - // thermalConductivity() W/m/K - // cp_mass() J/kg/K - mixture_.CanteraTransport()->getMixDiffCoeffsMass(dTemp_.begin()); // m2/s - - CanteraGas_->getEnthalpy_RT(hrtTemp_.begin()); //hrtTemp_=m_h0_RT non-dimension - // constant::physicoChemical::R.value() J/(mol·k) - const scalar RT = constant::physicoChemical::R.value()*1e3*T_[celli]; // J/kmol/K - forAll(rhoD_, i) + else { - rhoD_[i][celli] = rho_[celli]*dTemp_[i]; + alpha_[celli] = mixture_.CanteraTransport()->thermalConductivity()/(CanteraGas_->cp_mass()); // kg/(m*s) + // thermalConductivity() W/m/K + // cp_mass() J/kg/K + mixture_.CanteraTransport()->getMixDiffCoeffsMass(dTemp_.begin()); // m2/s + + CanteraGas_->getEnthalpy_RT(hrtTemp_.begin()); //hrtTemp_=m_h0_RT non-dimension + // constant::physicoChemical::R.value() J/(mol·k) + const scalar RT = constant::physicoChemical::R.value()*1e3*T_[celli]; // J/kmol/K + forAll(rhoD_, i) + { + rhoD_[i][celli] = rho_[celli]*dTemp_[i]; - // CanteraGas_->molecularWeight(i) kg/kmol - hai_[i][celli] = hrtTemp_[i]*RT/CanteraGas_->molecularWeight(i); + // CanteraGas_->molecularWeight(i) kg/kmol + hai_[i][celli] = hrtTemp_[i]*RT/CanteraGas_->molecularWeight(i); + } } } } @@ -467,6 +555,7 @@ void Foam::dfChemistryModel::correctThermo() volScalarField::Boundary& muBf = mu_.boundaryFieldRef(); volScalarField::Boundary& alphaBf = alpha_.boundaryFieldRef(); + volScalarField::Boundary mixfracBf = mixfrac_.boundaryField(); forAll(T_.boundaryField(), patchi) { @@ -477,6 +566,7 @@ void Foam::dfChemistryModel::correctThermo() fvPatchScalarField& ph = hBf[patchi]; fvPatchScalarField& pmu = muBf[patchi]; fvPatchScalarField& palpha = alphaBf[patchi]; + fvPatchScalarField pmixfrac = mixfracBf[patchi]; if (pT.fixesValue()) { @@ -535,45 +625,100 @@ void Foam::dfChemistryModel::correctThermo() { yTemp_[i] = Y_[i].boundaryField()[patchi][facei]; } - CanteraGas_->setState_PY(pp[facei], yTemp_.begin()); - if(mixture_.heName()=="ha") + if(useThermoTranNN) { - CanteraGas_->setState_HP(ph[facei], pp[facei]); + #ifdef USE_PYTORCH + CanteraGas_->setMassFractions(yTemp_.begin()); + pybind11::str fuel = call_ThermoTranNN.attr("fuel"); + pybind11::str ox = call_ThermoTranNN.attr("ox"); + Info << CanteraGas_->mixtureFraction(fuel,ox) << endl; + mixfrac_[facei] = CanteraGas_->mixtureFraction(fuel,ox); + scalarField inputZ = mixfrac_.primitiveField(); + pybind11::array_t pvec8 = pybind11::array_t({pmixfrac.size()}, {8}, &pmixfrac[0]); + pybind11::array_t pvec6 = pybind11::array_t({ph.size()}, {8}, &ph[0]); + // pybind11::array_t pvec7 = pybind11::array_t({pp.size()}, {8}, &pp[0]); + pybind11::object presult1 = call_ThermoTranNN.attr("useNet1")(pvec8, pvec6); // for density only + pybind11::array_t presult_array1(presult1); + double* pdata_ptr1 = presult_array1.mutable_data(); + pybind11::object presult2 = call_ThermoTranNN.attr("useNet2")(pvec8, pvec6); // for temperature only + pybind11::array_t presult_array2(presult2); + double* pdata_ptr2 = presult_array2.mutable_data(); + pybind11::object presult3 = call_ThermoTranNN.attr("useNet3")(pvec8, pvec6); + pybind11::array_t presult_array3(presult3); // Get the pointer to the data in the array + double* pdata_ptr3 = presult_array3.mutable_data(); + pybind11::object presult4 = call_ThermoTranNN.attr("useNet4")(pvec8, pvec6); + pybind11::array_t presult_array4(presult4); // Get the pointer to the data in the array + double* pdata_ptr4 = presult_array4.mutable_data(); + pybind11::object presult5 = call_ThermoTranNN.attr("useNet5")(pvec8, pvec6); + pybind11::array_t presult_array5(presult5); // Get the pointer to the data in the array + double* pdata_ptr5 = presult_array5.mutable_data(); + forAll(pT, facei) { + pT[facei] = pdata_ptr2[facei]; + + ppsi[facei] = pdata_ptr3[3*facei+2]; + + prho[facei] = pdata_ptr1[facei]; + pmu[facei] = pdata_ptr3[3*facei]; + palpha[facei] = pdata_ptr3[3*facei+1]; + rhoD_[0].boundaryFieldRef()[patchi][facei] = pdata_ptr4[6*facei]; // O2 + rhoD_[1].boundaryFieldRef()[patchi][facei] = pdata_ptr4[6*facei+4]; //H2O + rhoD_[2].boundaryFieldRef()[patchi][facei] = pdata_ptr4[6*facei+1]; //CH4 + rhoD_[3].boundaryFieldRef()[patchi][facei] = pdata_ptr4[6*facei+2]; //CO + rhoD_[4].boundaryFieldRef()[patchi][facei] = pdata_ptr4[6*facei+3]; //CO2 + rhoD_[5].boundaryFieldRef()[patchi][facei] = pdata_ptr4[6*facei+5]; //N2 + + hai_[0].boundaryFieldRef()[patchi][facei] = pdata_ptr5[6*facei]; // O2 + hai_[1].boundaryFieldRef()[patchi][facei] = pdata_ptr5[6*facei+4]; //H2O + hai_[2].boundaryFieldRef()[patchi][facei] = pdata_ptr5[6*facei+1]; //CH4 + hai_[3].boundaryFieldRef()[patchi][facei] = pdata_ptr5[6*facei+2]; //CO + hai_[4].boundaryFieldRef()[patchi][facei] = pdata_ptr5[6*facei+3]; //CO2 + hai_[5].boundaryFieldRef()[patchi][facei] = pdata_ptr5[6*facei+5]; //N2 + + } + #endif } - else if(mixture_.heName()=="ea") + else { - scalar ha = ph[facei] + pp[facei]/prho[facei]; - CanteraGas_->setState_HP(ha, pp[facei]); - } + CanteraGas_->setState_PY(pp[facei], yTemp_.begin()); + if(mixture_.heName()=="ha") + { + CanteraGas_->setState_HP(ph[facei], pp[facei]); + } + else if(mixture_.heName()=="ea") + { + scalar ha = ph[facei] + pp[facei]/prho[facei]; + CanteraGas_->setState_HP(ha, pp[facei]); + } - pT[facei] = CanteraGas_->temperature(); + pT[facei] = CanteraGas_->temperature(); - ppsi[facei] = mixture_.psi(pp[facei],pT[facei]); + ppsi[facei] = mixture_.psi(pp[facei],pT[facei]); - prho[facei] = mixture_.rho(pp[facei],pT[facei]); + prho[facei] = mixture_.rho(pp[facei],pT[facei]); - pmu[facei] = mixture_.CanteraTransport()->viscosity(); + pmu[facei] = mixture_.CanteraTransport()->viscosity(); - if (mixture_.transportModelName() == "UnityLewis") - { - palpha[facei] = pmu[facei] / 0.7; - forAll(rhoD_, i) + if (mixture_.transportModelName() == "UnityLewis") { - rhoD_[i].boundaryFieldRef()[patchi][facei] = palpha[facei]; + palpha[facei] = pmu[facei] / 0.7; + forAll(rhoD_, i) + { + rhoD_[i].boundaryFieldRef()[patchi][facei] = palpha[facei]; + } } - } - else - { - palpha[facei] = mixture_.CanteraTransport()->thermalConductivity()/(CanteraGas_->cp_mass()); - mixture_.CanteraTransport()->getMixDiffCoeffsMass(dTemp_.begin()); - - CanteraGas_->getEnthalpy_RT(hrtTemp_.begin()); - const scalar RT = constant::physicoChemical::R.value()*1e3*pT[facei]; - forAll(rhoD_, i) + else { - rhoD_[i].boundaryFieldRef()[patchi][facei] = prho[facei]*dTemp_[i]; + palpha[facei] = mixture_.CanteraTransport()->thermalConductivity()/(CanteraGas_->cp_mass()); + mixture_.CanteraTransport()->getMixDiffCoeffsMass(dTemp_.begin()); - hai_[i].boundaryFieldRef()[patchi][facei] = hrtTemp_[i]*RT/CanteraGas_->molecularWeight(i); + CanteraGas_->getEnthalpy_RT(hrtTemp_.begin()); + const scalar RT = constant::physicoChemical::R.value()*1e3*pT[facei]; + forAll(rhoD_, i) + { + rhoD_[i].boundaryFieldRef()[patchi][facei] = prho[facei]*dTemp_[i]; + + hai_[i].boundaryFieldRef()[patchi][facei] = hrtTemp_[i]*RT/CanteraGas_->molecularWeight(i); + } } } } diff --git a/src/dfChemistryModel/dfChemistryModel.H b/src/dfChemistryModel/dfChemistryModel.H index f514f91c2..7705dc77f 100644 --- a/src/dfChemistryModel/dfChemistryModel.H +++ b/src/dfChemistryModel/dfChemistryModel.H @@ -126,12 +126,14 @@ public IOdictionary volScalarField& T_; const volScalarField& p_; volScalarField& rho_; + volScalarField mixfrac_; volScalarField& mu_; volScalarField& psi_; // heat release rate, [J/m^3/s] volScalarField Qdot_; // DNN selection fields volScalarField selectDNN_; + bool useThermoTranNN; #if defined USE_LIBTORCH || defined USE_PYTORCH bool useDNN; @@ -169,6 +171,7 @@ public IOdictionary // profiling double time_vec2ndarray_; double time_python_; + pybind11::module_ call_ThermoTranNN; // to import inference file #endif // Load balancing object @@ -310,7 +313,6 @@ public: const volScalarField& rhoD(const label i) const {return rhoD_[i];} const volScalarField& hai(const label i) {return hai_[i];} - // update T, psi, mu, alpha, rhoD, hai (if needed) void correctThermo(); diff --git a/src/dfCombustionModels/Make/options b/src/dfCombustionModels/Make/options index 14cd987ce..d909e6048 100644 --- a/src/dfCombustionModels/Make/options +++ b/src/dfCombustionModels/Make/options @@ -1,6 +1,6 @@ -include $(GENERAL_RULES)/mplibType -EXE_INC = -std=c++17 \ +EXE_INC = -std=c++14 \ -Wno-old-style-cast \ $(PFLAGS) $(PINC) \ $(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \ diff --git a/src/dynamicFvMesh/Make/options b/src/dynamicFvMesh/Make/options index 15a0e721c..d85b47fe4 100644 --- a/src/dynamicFvMesh/Make/options +++ b/src/dynamicFvMesh/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ diff --git a/src/dynamicMesh/Make/options b/src/dynamicMesh/Make/options index c5b099d8d..7b24eb1ff 100644 --- a/src/dynamicMesh/Make/options +++ b/src/dynamicMesh/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ diff --git a/src/functionObjects/field/Make/options b/src/functionObjects/field/Make/options index 25c5c45a4..577f5ebec 100644 --- a/src/functionObjects/field/Make/options +++ b/src/functionObjects/field/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -I$(SRC_ORIG)/functionObjects/field/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ diff --git a/src/lagrangian/intermediate/Make/options b/src/lagrangian/intermediate/Make/options index 345fc6f00..0dce93384 100644 --- a/src/lagrangian/intermediate/Make/options +++ b/src/lagrangian/intermediate/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -Wno-old-style-cast \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \ diff --git a/src/lagrangian/spray/Make/options b/src/lagrangian/spray/Make/options index 3b668367f..5fd488ea6 100644 --- a/src/lagrangian/spray/Make/options +++ b/src/lagrangian/spray/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -Wno-old-style-cast \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(DF_SRC)/lagrangian/intermediate/lnInclude \ diff --git a/src/lagrangian/turbulence/Make/options b/src/lagrangian/turbulence/Make/options index 2ecdb642d..b90ebb5b4 100644 --- a/src/lagrangian/turbulence/Make/options +++ b/src/lagrangian/turbulence/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -Wno-old-style-cast \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(DF_SRC)/lagrangian/intermediate/lnInclude \ diff --git a/src/regionModels/surfaceFilmModels/Make/options b/src/regionModels/surfaceFilmModels/Make/options index 7a98e7a9c..f6d6bd5e0 100644 --- a/src/regionModels/surfaceFilmModels/Make/options +++ b/src/regionModels/surfaceFilmModels/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -Wno-old-style-cast \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ diff --git a/src/thermophysicalModels/SLGThermo/Make/options b/src/thermophysicalModels/SLGThermo/Make/options index d2e672a91..9c93353cf 100644 --- a/src/thermophysicalModels/SLGThermo/Make/options +++ b/src/thermophysicalModels/SLGThermo/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -Wno-old-style-cast \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ diff --git a/src/thermophysicalModels/basic/Make/options b/src/thermophysicalModels/basic/Make/options index 6d2eb4020..3108f079a 100644 --- a/src/thermophysicalModels/basic/Make/options +++ b/src/thermophysicalModels/basic/Make/options @@ -1,4 +1,4 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(DF_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \ diff --git a/src/thermophysicalModels/thermophysicalProperties/Make/options b/src/thermophysicalModels/thermophysicalProperties/Make/options index 9f90ecbe1..2bea33c2b 100644 --- a/src/thermophysicalModels/thermophysicalProperties/Make/options +++ b/src/thermophysicalModels/thermophysicalProperties/Make/options @@ -1,3 +1,3 @@ -EXE_INC = -std=c++17\ +EXE_INC = -std=c++14\ -I./lnInclude \ -I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude diff --git a/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties index 1fdeff4ce..fa2422dec 100644 --- a/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties +++ b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties @@ -34,7 +34,7 @@ TorchSettings { torch off; GPU off; - log on; + log off; torchModel1 "ESH2-sub1.pt"; torchModel2 "ESH2-sub2.pt"; torchModel3 "ESH2-sub3.pt";