diff --git a/Allwmake b/Allwmake index c225a4e6..cbed1083 100755 --- a/Allwmake +++ b/Allwmake @@ -14,6 +14,7 @@ wmake src/TurbulenceModels/compressible wmake src/TurbulenceModels/turbulenceModels wmake src/regionModels/surfaceFilmModels src/lagrangian/Allwmake $targetType $* +wmake src/dfCombustionModels wmake src/dynamicMesh wmake src/dynamicFvMesh diff --git a/README.md b/README.md index b4b8be97..3a1048e5 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ -# DeepFlame v0.3.0 -DeepFlame is a computational fluid dynamics suite for single or multiphase, laminar or turbulent reacting flows at all speeds with machine learning capabilities. It aims to provide an open-source platform bringing together the individual strengths of [OpenFOAM](https://openfoam.org), [Cantera](https://cantera.org) and [pyTorch](https://pytorch.org/) libraries for machine learning assisted reacting flow simulations. It is also has the scope to incorporate next-generation heterogenous supercomputing and AI acceleration infrustructures such as GPU and FPGAs. +# DeepFlame v0.4.0 +DeepFlame is a computational fluid dynamics suite for single or multiphase, laminar or turbulent reacting flows at all speeds with machine learning capabilities. It aims to provide an open-source platform bringing together the individual strengths of [OpenFOAM](https://openfoam.org), [Cantera](https://cantera.org) and [pyTorch](https://pytorch.org/) libraries for machine learning assisted reacting flow simulations. It is also has the scope to incorporate next-generation heterogenous supercomputing and AI acceleration infrustructures such as GPU and FPGAs. ## Dependencies [OpenFOAM-7](https://openfoam.org/version/7), [Cantera C++ lib 2.6.0](https://anaconda.org/conda-forge/libcantera-devel), [Torch C++ lib 1.11.0](https://pytorch.org/) ## Features +New in v0.4.0 (2022/09/26): +- Adapt combustion library from OpenFOAM into DeepFlame +- laminar; EDC; PaSR combustion models + New in v0.3.0: - 1/2/3D adaptive mesh refinement - Add Sigma/dynSmag LES turbulence models @@ -23,7 +27,7 @@ From v0.1.0: - Two-phase Lagrangian/Euler spray reacting flow solver `dfSprayFoam` - Cantera's native SUNDIALS CVODE solver for chemical reaction rate evaluation - Torch's tensor operation functionality for neutral network I/O and calculation -- Interface for DNN model to obtain chemical reaction rates +- Interface for DNN model to obtain chemical reaction rates - Multiple example and tutorial cases with `Allrun` and `Allclean` scripts - 0D Perfectly Stirred Reactor - 1D Freely Propagating Premixed Flame @@ -33,11 +37,11 @@ From v0.1.0: - 3D Aachen Bomb Spray Flame ## How to install -The installation of DeepFlame is simple and requires [OpenFOAM-7](https://openfoam.org/version/7), [LibCantera](https://anaconda.org/conda-forge/libcantera-devel) and [LibTorch](https://pytorch.org/) . +The installation of DeepFlame is simple and requires [OpenFOAM-7](https://openfoam.org/version/7), [LibCantera](https://anaconda.org/conda-forge/libcantera-devel) and [LibTorch](https://pytorch.org/) . ### 1. Install [OpenFOAM-7](https://openfoam.org/version/7) (if not already installed) - - Quick install (for Ubuntu no later than 20.04): + + Quick install (for Ubuntu no later than 20.04): ``` sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu @@ -48,7 +52,7 @@ sudo apt-get -y install openfoam7 ### 2. Source your OpenFOAM via the default path below (or your own path for OpenFOAM bashrc) ``` -source $HOME/OpenFOAM/OpenFOAM-7/etc/bashrc +source $HOME/OpenFOAM/OpenFOAM-7/etc/bashrc ``` ### 3. Install [LibCantera](https://anaconda.org/conda-forge/libcantera-devel) via [conda](https://docs.conda.io/en/latest/miniconda.html#linux-installers) ``` @@ -66,7 +70,7 @@ git clone https://github.com/deepmodeling/deepflame-dev.git cd deepflame-dev ``` -### 5. Install precompiled [LibTorch](https://pytorch.org/) +### 5. Install precompiled [LibTorch](https://pytorch.org/) ``` wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.11.0%2Bcpu.zip @@ -81,7 +85,7 @@ Note: Some compiling issues may happen due to system compatability. Instead of u ## Running DeepFlame examples 1. Source your OpenFOAM, for example (depends on your OpenFOAM path): ``` -source $HOME/OpenFOAM/OpenFOAM-7/etc/bashrc +source $HOME/OpenFOAM/OpenFOAM-7/etc/bashrc ``` 2. Source deepflame-dev/bashrc, for example (depends on your DeepFlame path): ``` @@ -94,11 +98,11 @@ cd $HOME/deepflame-dev/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver ./Allrun ``` -Note: For the example cases with torchSolver, an additional DNN model file in the `.pt` format is required. Please contact the developers if you would like a test run. +Note: For the example cases with torchSolver, an additional DNN model file in the `.pt` format is required. Please contact the developers if you would like a test run. ## Citing DeepFlame -If you use DeepFlame for a publication, please use the citation: +If you use DeepFlame for a publication, please use the citation: DeepFlame: A computational fluid dynamics suite for multiphase turbulent reacting flows at all speeds with machine learning. URL:https://github.com/deepmodeling/deepflame-dev, 2022. diff --git a/applications/solvers/df0DFoam/Make/options b/applications/solvers/df0DFoam/Make/options index 7edf9048..a3fc8987 100644 --- a/applications/solvers/df0DFoam/Make/options +++ b/applications/solvers/df0DFoam/Make/options @@ -9,7 +9,7 @@ EXE_INC = -std=c++14 \ -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(DF_SRC)/CanteraMixture/lnInclude \ - -I$(DF_SRC)/dfChemistryModel \ + -I$(DF_SRC)/dfChemistryModel/lnInclude \ -I$(CANTERA_ROOT)/include \ -I$(TORCH_ROOT)/include \ -I$(TORCH_ROOT)/include/torch/csrc/api/include diff --git a/applications/solvers/df0DFoam/YEqn.H b/applications/solvers/df0DFoam/YEqn.H index 2c0370d0..f7c8f1de 100644 --- a/applications/solvers/df0DFoam/YEqn.H +++ b/applications/solvers/df0DFoam/YEqn.H @@ -43,4 +43,4 @@ tmp> mvConvection Y[inertIndex] = scalar(1) - Yt; Y[inertIndex].max(0.0); -} +} \ No newline at end of file diff --git a/applications/solvers/df0DFoam/df0DFoam.C b/applications/solvers/df0DFoam/df0DFoam.C index a0ef43b2..ac3df5c8 100644 --- a/applications/solvers/df0DFoam/df0DFoam.C +++ b/applications/solvers/df0DFoam/df0DFoam.C @@ -7,30 +7,23 @@ ------------------------------------------------------------------------------- License This file is part of OpenFOAM. - OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . - Application rhoPimpleFoam - Description Transient solver for turbulent flow of compressible fluids for HVAC and similar applications, with optional mesh motion and mesh topology changes. - Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and pseudo-transient simulations. - \*---------------------------------------------------------------------------*/ #include "dfChemistryModel.H" #include "CanteraMixture.H" @@ -106,4 +99,4 @@ int main(int argc, char *argv[]) } -// ************************************************************************* // +// ************************************************************************* // \ No newline at end of file diff --git a/applications/solvers/dfHighSpeedFoam/Make/options b/applications/solvers/dfHighSpeedFoam/Make/options index e8d6d66c..7b156a6b 100644 --- a/applications/solvers/dfHighSpeedFoam/Make/options +++ b/applications/solvers/dfHighSpeedFoam/Make/options @@ -14,7 +14,7 @@ EXE_INC = -std=c++14 \ -I$(LIB_SRC)/Pstream/mpi \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(DF_SRC)/CanteraMixture/lnInclude \ - -I$(DF_SRC)/dfChemistryModel \ + -I$(DF_SRC)/dfChemistryModel/lnInclude \ -I$(CANTERA_ROOT)/include \ -I$(TORCH_ROOT)/include \ -I$(TORCH_ROOT)/include/torch/csrc/api/include diff --git a/applications/solvers/dfLowMachFoam/Make/options b/applications/solvers/dfLowMachFoam/Make/options index 18cf9317..042d652c 100644 --- a/applications/solvers/dfLowMachFoam/Make/options +++ b/applications/solvers/dfLowMachFoam/Make/options @@ -13,7 +13,8 @@ EXE_INC = -std=c++14 \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/Pstream/mpi \ -I$(DF_SRC)/CanteraMixture/lnInclude \ - -I$(DF_SRC)/dfChemistryModel \ + -I$(DF_SRC)/dfChemistryModel/lnInclude \ + -I$(DF_SRC)/dfCombustionModels/lnInclude \ -I$(CANTERA_ROOT)/include \ -I$(TORCH_ROOT)/include \ -I$(TORCH_ROOT)/include/torch/csrc/api/include @@ -29,6 +30,7 @@ EXE_LIBS = \ -ldfCompressibleTurbulenceModels \ -lCanteraMixture \ -ldfChemistryModel \ + -ldfCombustionModels \ $(CANTERA_ROOT)/lib/libcantera.so \ $(TORCH_ROOT)/lib/libtorch.so \ $(TORCH_ROOT)/lib/libc10.so \ diff --git a/applications/solvers/dfLowMachFoam/YEqn.H b/applications/solvers/dfLowMachFoam/YEqn.H index 6d6f33dd..ff9e6937 100644 --- a/applications/solvers/dfLowMachFoam/YEqn.H +++ b/applications/solvers/dfLowMachFoam/YEqn.H @@ -15,13 +15,13 @@ tmp> mvConvection forAll(Y, i) { - sumYDiffError += chemistry.rhoD(i)*fvc::grad(Y[i]); + sumYDiffError += chemistry->rhoD(i)*fvc::grad(Y[i]); } const surfaceScalarField phiUc = linearInterpolate(sumYDiffError) & mesh.Sf(); { start = std::clock(); - chemistry.solve(mesh.time().deltaTValue()); + combustion->correct(); label flag_mpi_init; MPI_Initialized(&flag_mpi_init); if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM); @@ -34,12 +34,12 @@ const surfaceScalarField phiUc = linearInterpolate(sumYDiffError) & mesh.Sf(); forAll(Y, i) { volScalarField& Yi = Y[i]; - hDiffCorrFlux += chemistry.hai(i)*(chemistry.rhoD(i)*fvc::grad(Yi) - Yi*sumYDiffError); - diffAlphaD += fvc::laplacian(thermo.alpha()*chemistry.hai(i), Yi); + hDiffCorrFlux += chemistry->hai(i)*(chemistry->rhoD(i)*fvc::grad(Yi) - Yi*sumYDiffError); + diffAlphaD += fvc::laplacian(thermo.alpha()*chemistry->hai(i), Yi); if (i != inertIndex) { - tmp DEff = chemistry.rhoD(i) + turbulence->mut()/Sct; + tmp DEff = chemistry->rhoD(i) + turbulence->mut()/Sct; fvScalarMatrix YiEqn ( fvm::ddt(rho, Yi) @@ -47,7 +47,7 @@ const surfaceScalarField phiUc = linearInterpolate(sumYDiffError) & mesh.Sf(); - fvm::laplacian(DEff(), Yi) + mvConvection->fvmDiv(phiUc, Yi) == - chemistry.RR(i) + combustion->R(Yi) ); YiEqn.relax(); diff --git a/applications/solvers/dfLowMachFoam/createFields.H b/applications/solvers/dfLowMachFoam/createFields.H index 492aa8cb..63a09232 100644 --- a/applications/solvers/dfLowMachFoam/createFields.H +++ b/applications/solvers/dfLowMachFoam/createFields.H @@ -22,14 +22,6 @@ volScalarField rho thermo.rho() ); -dfChemistryModel chemistry(thermo); -PtrList& Y = chemistry.Y(); -const word inertSpecie(chemistry.lookup("inertSpecie")); -const label inertIndex(chemistry.species()[inertSpecie]); - -chemistry.correctThermo(); -Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; - Info<< "Reading field U\n" << endl; volVectorField U ( @@ -62,6 +54,21 @@ autoPtr turbulence ) ); +Info<< "Creating reaction model\n" << endl; +autoPtr> combustion +( + CombustionModel::New(thermo, turbulence()) +); +Info<< "end Creating reaction model\n" << endl; +dfChemistryModel* chemistry = combustion->chemistry(); +PtrList& Y = chemistry->Y(); +const word inertSpecie(chemistry->lookup("inertSpecie")); +const label inertIndex(chemistry->species()[inertSpecie]); + + +chemistry->correctThermo(); +Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; + Info<< "Creating field dpdt\n" << endl; volScalarField dpdt ( @@ -85,7 +92,7 @@ forAll(Y, i) } fields.add(thermo.he()); -const scalar Sct = chemistry.lookupOrDefault("Sct", 1.); +const scalar Sct = chemistry->lookupOrDefault("Sct", 1.); volScalarField diffAlphaD ( IOobject diff --git a/applications/solvers/dfLowMachFoam/dfLowMachFoam.C b/applications/solvers/dfLowMachFoam/dfLowMachFoam.C index 51df0dfd..e41d671e 100644 --- a/applications/solvers/dfLowMachFoam/dfLowMachFoam.C +++ b/applications/solvers/dfLowMachFoam/dfLowMachFoam.C @@ -45,6 +45,8 @@ Description #include "localEulerDdtScheme.H" #include "fvcSmooth.H" #include "PstreamGlobals.H" +#include "basicThermo.H" +#include "CombustionModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -128,7 +130,7 @@ int main(int argc, char *argv[]) time_monitor_E += double(end - start) / double(CLOCKS_PER_SEC); start = std::clock(); - chemistry.correctThermo(); + chemistry->correctThermo(); end = std::clock(); time_monitor_corrThermo += double(end - start) / double(CLOCKS_PER_SEC); diff --git a/applications/solvers/dfSprayFoam/Make/options b/applications/solvers/dfSprayFoam/Make/options index 436a4f69..0329a0fe 100644 --- a/applications/solvers/dfSprayFoam/Make/options +++ b/applications/solvers/dfSprayFoam/Make/options @@ -23,7 +23,8 @@ EXE_INC = -std=c++14 \ -I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \ -I$(DF_SRC)/thermophysicalModels/SLGThermo/lnInclude \ -I$(DF_SRC)/CanteraMixture/lnInclude \ - -I$(DF_SRC)/dfChemistryModel \ + -I$(DF_SRC)/dfChemistryModel/lnInclude \ + -I$(DF_SRC)/dfCombustionModels/lnInclude \ -I$(CANTERA_ROOT)/include \ -I$(TORCH_ROOT)/include \ -I$(TORCH_ROOT)/include/torch/csrc/api/include @@ -49,6 +50,7 @@ EXE_LIBS = \ -ldfLagrangianSpray \ -lCanteraMixture \ -ldfChemistryModel \ + -ldfCombustionModels \ $(CANTERA_ROOT)/lib/libcantera.so \ $(TORCH_ROOT)/lib/libtorch.so \ $(TORCH_ROOT)/lib/libc10.so \ diff --git a/applications/solvers/dfSprayFoam/YEqn.H b/applications/solvers/dfSprayFoam/YEqn.H index 63e8efdc..7027adfe 100644 --- a/applications/solvers/dfSprayFoam/YEqn.H +++ b/applications/solvers/dfSprayFoam/YEqn.H @@ -15,24 +15,23 @@ tmp> mvConvection forAll(Y, i) { - sumYDiffError += chemistry.rhoD(i)*fvc::grad(Y[i]); + sumYDiffError += chemistry->rhoD(i)*fvc::grad(Y[i]); } const surfaceScalarField phiUc = linearInterpolate(sumYDiffError) & mesh.Sf(); { - //combustion->correct(); - chemistry.solve(mesh.time().deltaTValue()); + combustion->correct(); volScalarField Yt(0.0*Y[0]); forAll(Y, i) { volScalarField& Yi = Y[i]; - hDiffCorrFlux += chemistry.hai(i)*(chemistry.rhoD(i)*fvc::grad(Yi) - Yi*sumYDiffError); - diffAlphaD += fvc::laplacian(thermo.alpha()*chemistry.hai(i), Yi); + hDiffCorrFlux += chemistry->hai(i)*(chemistry->rhoD(i)*fvc::grad(Yi) - Yi*sumYDiffError); + diffAlphaD += fvc::laplacian(thermo.alpha()*chemistry->hai(i), Yi); if (i != inertIndex) { - tmp DEff = chemistry.rhoD(i) + turbulence->mut()/Sct; + tmp DEff = chemistry->rhoD(i) + turbulence->mut()/Sct; fvScalarMatrix YEqn ( fvm::ddt(rho, Yi) @@ -41,7 +40,7 @@ const surfaceScalarField phiUc = linearInterpolate(sumYDiffError) & mesh.Sf(); + mvConvection->fvmDiv(phiUc, Yi) == parcels.SYi(i, Yi) - + chemistry.RR(i) + + combustion->R(Yi) //+ fvOptions(rho, Yi) ); diff --git a/applications/solvers/dfSprayFoam/createFields.H b/applications/solvers/dfSprayFoam/createFields.H index 09e80077..04786bf8 100644 --- a/applications/solvers/dfSprayFoam/createFields.H +++ b/applications/solvers/dfSprayFoam/createFields.H @@ -23,14 +23,6 @@ volScalarField rho thermo.rho() ); -dfChemistryModel chemistry(thermo); -PtrList& Y = chemistry.Y(); -const word inertSpecie(chemistry.lookup("inertSpecie")); -const label inertIndex(chemistry.species()[inertSpecie]); - -chemistry.correctThermo(); -Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; - Info<< "\nReading field U\n" << endl; volVectorField U ( @@ -83,6 +75,22 @@ autoPtr turbulence ) ); +Info<< "Creating reaction model\n" << endl; +autoPtr> combustion +( + CombustionModel::New(thermo, turbulence()) +); +Info<< "end Creating reaction model\n" << endl; +dfChemistryModel* chemistry = combustion->chemistry(); +PtrList& Y = chemistry->Y(); +const word inertSpecie(chemistry->lookup("inertSpecie")); +const label inertIndex(chemistry->species()[inertSpecie]); + + +chemistry->correctThermo(); +Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; + + Info<< "Creating field dpdt\n" << endl; volScalarField dpdt ( @@ -113,7 +121,7 @@ fields.add(thermo.he()); // for diffusion velocity correction -const scalar Sct = chemistry.lookupOrDefault("Sct", 1.); +const scalar Sct = chemistry->lookupOrDefault("Sct", 1.); volScalarField diffAlphaD ( IOobject diff --git a/applications/solvers/dfSprayFoam/dfSprayFoam.C b/applications/solvers/dfSprayFoam/dfSprayFoam.C index cf033c4d..e3b6206a 100644 --- a/applications/solvers/dfSprayFoam/dfSprayFoam.C +++ b/applications/solvers/dfSprayFoam/dfSprayFoam.C @@ -43,6 +43,8 @@ Description #include "pimpleControl.H" #include "CorrectPhi.H" //#include "fvOptions.H" +#include "basicThermo.H" +#include "CombustionModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -134,7 +136,7 @@ int main(int argc, char *argv[]) #include "UEqn.H" #include "YEqn.H" #include "EEqn.H" - chemistry.correctThermo(); + chemistry->correctThermo(); Info<< "T gas min/max " << min(T).value() << ", " << max(T).value() << endl; diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeSolver/constant/combustionProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeSolver/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeSolver/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchSolver/constant/combustionProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchSolver/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchSolver/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeSolver/constant/combustionProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeSolver/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeSolver/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/torchSolver/constant/combustionProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/torchSolver/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/torchSolver/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/cvodeSolver/constant/combustionProperties b/examples/dfLowMachFoam/threeD_reactingTGV/H2/cvodeSolver/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfLowMachFoam/threeD_reactingTGV/H2/cvodeSolver/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/torchSolver/constant/combustionProperties b/examples/dfLowMachFoam/threeD_reactingTGV/H2/torchSolver/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfLowMachFoam/threeD_reactingTGV/H2/torchSolver/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/cvodeSolver/constant/combustionProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/cvodeSolver/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfLowMachFoam/twoD_tripleFlame/H2/cvodeSolver/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/torchSolver/constant/combustionProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/torchSolver/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfLowMachFoam/twoD_tripleFlame/H2/torchSolver/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/examples/dfSprayFoam/aachenBomb/constant/combustionProperties b/examples/dfSprayFoam/aachenBomb/constant/combustionProperties new file mode 100644 index 00000000..7418500d --- /dev/null +++ b/examples/dfSprayFoam/aachenBomb/constant/combustionProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel laminar; + +// ************************************************************************* // diff --git a/install.sh b/install.sh index fb283220..5158d135 100755 --- a/install.sh +++ b/install.sh @@ -1,13 +1,16 @@ #!/bin/sh -if [ -e libtorch-cxx11-abi-shared-with-deps-1.11.0+cpu.zip ] -then - echo "libtorch.zip exist." -else - wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.11.0%2Bcpu.zip -fi + if [ -d "thirdParty/libtorch" ]; then echo "libtorch exist." else + + if [ -e libtorch-cxx11-abi-shared-with-deps-1.11.0+cpu.zip ] + then + echo "libtorch.zip exist." + else + wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.11.0%2Bcpu.zip + fi + unzip libtorch-cxx11-abi-shared-with-deps-1.11.0+cpu.zip -d thirdParty fi diff --git a/src/dfChemistryModel/dfChemistryModel.C b/src/dfChemistryModel/dfChemistryModel.C index e85a24b6..e80e1a7d 100644 --- a/src/dfChemistryModel/dfChemistryModel.C +++ b/src/dfChemistryModel/dfChemistryModel.C @@ -26,7 +26,7 @@ License #include "dfChemistryModel.H" #include "UniformField.H" #include "clockTime.H" -#include "loadBalancing/runtime_assert.H" +#include "runtime_assert.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -84,7 +84,7 @@ Foam::dfChemistryModel::dfChemistryModel dimensionedScalar(dimEnergy/dimVolume/dimTime, 0) ), torchSwitch_(lookupOrDefault("torch", false)), - balancer_(createBalancer()), + balancer_(createBalancer()), cpuTimes_ ( IOobject @@ -180,7 +180,7 @@ Foam::dfChemistryModel::dfChemistryModel { cpuSolveFile_ = logFile("cpu_solve.out"); cpuSolveFile_() << " time" << tab - << " getProblems" << tab + << " getProblems" << tab << " updateState" << tab << " balance" << tab << " solveBuffer" << tab @@ -441,13 +441,13 @@ Foam::scalar Foam::dfChemistryModel::torchSolve Cantera::ReactorNet sim; sim.addReactor(react); setNumerics(sim); - sim.advance(deltaT); + sim.advance(deltaT[cellI]); CanteraGas_->getMassFractions(yTemp_.begin()); for (size_t i=0; inSpecies(); ++i) { - RR_[i][cellI] = (yTemp_[i] - yPre_[i])*rhoi/deltaT; + RR_[i][cellI] = (yTemp_[i] - yPre_[i])*rhoi/deltaT[cellI]; Qdot_[cellI] -= hc_[i]*RR_[i][cellI]; } } @@ -470,13 +470,13 @@ Foam::scalar Foam::dfChemistryModel::torchSolve for (size_t i=0; i<(CanteraGas_->nSpecies()); ++i)// { u_[i+2] = outputs[cellI][i+2].item().to()*Ystd_[i+2]+Ymu_[i+2]; - yTemp_[i] = pow((yBCT_[i] + u_[i+2]*deltaT)*lambda+1,1/lambda); + yTemp_[i] = pow((yBCT_[i] + u_[i+2]*deltaT[cellI])*lambda+1,1/lambda); Yt += yTemp_[i]; } for (size_t i=0; inSpecies(); ++i) { yTemp_[i] = yTemp_[i] / Yt; - RR_[i][torch_cell[cellI]] = (yTemp_[i] - Y_[i][torch_cell[cellI]])*rho_[torch_cell[cellI]]/deltaT; + RR_[i][torch_cell[cellI]] = (yTemp_[i] - Y_[i][torch_cell[cellI]])*rho_[torch_cell[cellI]]/deltaT[cellI]; Qdot_[torch_cell[cellI]] -= hc_[i]*RR_[i][torch_cell[cellI]]; } } @@ -722,7 +722,7 @@ Foam::dfChemistryModel::getProblems solved_problems[celli] = problem; } - + } return solved_problems; diff --git a/src/dfChemistryModel/dfChemistryModel.H b/src/dfChemistryModel/dfChemistryModel.H index e7c35495..f4d68477 100644 --- a/src/dfChemistryModel/dfChemistryModel.H +++ b/src/dfChemistryModel/dfChemistryModel.H @@ -47,11 +47,11 @@ SourceFiles #include "hashedWordList.H" #include "psiThermo.H" #include "physicoChemicalConstants.H" // for R -#include "loadBalancing/ChemistryProblem.H" -#include "loadBalancing/ChemistrySolution.H" -#include "loadBalancing/RecvBuffer.H" -#include "loadBalancing/SendBuffer.H" -#include "loadBalancing/LoadBalancer.H" +#include "ChemistryProblem.H" +#include "ChemistrySolution.H" +#include "RecvBuffer.H" +#include "SendBuffer.H" +#include "LoadBalancer.H" #include "OFstream.H" #include "IOmanip.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -227,6 +227,7 @@ public: // update T, psi, mu, alpha, rhoD, hai (if needed) void correctThermo(); + ThermoType& thermo() {return thermo_;} }; diff --git a/src/dfCombustionModels/CombustionModel/ChemistryCombustion/ChemistryCombustion.C b/src/dfCombustionModels/CombustionModel/ChemistryCombustion/ChemistryCombustion.C new file mode 100644 index 00000000..c6f1fb18 --- /dev/null +++ b/src/dfCombustionModels/CombustionModel/ChemistryCombustion/ChemistryCombustion.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "ChemistryCombustion.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::ChemistryCombustion::ChemistryCombustion +( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +: + CombustionModel + ( + modelType, + thermo, + turb, + combustionProperties + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::ChemistryCombustion:: +~ChemistryCombustion() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +ReactionThermo& +Foam::ChemistryCombustion::thermo() +{ + return this->chemistryPtr_->thermo(); +} + + +template +const ReactionThermo& +Foam::ChemistryCombustion::thermo() const +{ + return this->chemistryPtr_->thermo(); +} + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/CombustionModel/ChemistryCombustion/ChemistryCombustion.H b/src/dfCombustionModels/CombustionModel/ChemistryCombustion/ChemistryCombustion.H new file mode 100644 index 00000000..1f023fb4 --- /dev/null +++ b/src/dfCombustionModels/CombustionModel/ChemistryCombustion/ChemistryCombustion.H @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::ChemistryCombustion + +Description + Chemistry model wrapper for combustion models + +SourceFiles + ChemistryCombustion.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ChemistryCombustion_H +#define ChemistryCombustion_H + +#include "dfChemistryModel.H" +#include "autoPtr.H" +#include "CombustionModel.H" +//#include "BasicChemistryModel.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + class ChemistryCombustion Declaration +\*---------------------------------------------------------------------------*/ + +template +class ChemistryCombustion +: + public CombustionModel +{ +protected: + + // Protected data + + +public: + + // Constructors + + //- Construct from components and thermo + ChemistryCombustion + ( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties + ); + + + //- Destructor + virtual ~ChemistryCombustion(); + + + // Member Functions + + //- Return access to the thermo package + virtual ReactionThermo& thermo(); + + //- Return const access to the thermo package + virtual const ReactionThermo& thermo() const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "ChemistryCombustion.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModel.C b/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModel.C new file mode 100644 index 00000000..13208553 --- /dev/null +++ b/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModel.C @@ -0,0 +1,90 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "CombustionModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::CombustionModel::CombustionModel +( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +: + combustionModel(modelType, thermo, turb, combustionProperties), + chemistryPtr_(new dfChemistryModel(thermo)) +{} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +template +Foam::autoPtr> +Foam::CombustionModel::New +( + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +{ + return + combustionModel::New> + ( + thermo, + turb, + combustionProperties + ); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::CombustionModel::~CombustionModel() +{ + delete chemistryPtr_; +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +bool Foam::CombustionModel::read() +{ + if (combustionModel::read()) + { + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModel.H b/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModel.H new file mode 100644 index 00000000..4e48c0f7 --- /dev/null +++ b/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModel.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::CombustionModel + +Description + Combustion models for templated thermodynamics + +SourceFiles + CombustionModelI.H + CombustionModel.C + CombustionModelNew.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CombustionModel_H +#define CombustionModel_H + +#include "dfChemistryModel.H" +#include "combustionModel.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + class CombustionModel Declaration +\*---------------------------------------------------------------------------*/ + +template +class CombustionModel +: + public combustionModel +{ +protected: + + dfChemistryModel* chemistryPtr_; + +public: + + //- Thermo type + typedef ReactionThermo reactionThermo; + + + //- Runtime type information + TypeName("CombustionModel"); + + + //- Declare run-time constructor selection tables + declareRunTimeSelectionTable + ( + autoPtr, + CombustionModel, + dictionary, + ( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties + ), + (modelType, thermo, turb, combustionProperties) + ); + + + // Constructors + + //- Construct from components + CombustionModel + ( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties + ); + + + //- Selector + static autoPtr New + ( + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties=combustionPropertiesName + ); + + + //- Destructor + virtual ~CombustionModel(); + + + // Member Functions + + //- Return access to the thermo package + virtual ReactionThermo& thermo() = 0; + + //- Return const access to the thermo package + virtual const ReactionThermo& thermo() const = 0; + + void correctThermo(); + dfChemistryModel* chemistry() { return chemistryPtr_;} + + + // IO + + //- Update properties from given dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "CombustionModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // \ No newline at end of file diff --git a/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModels.C b/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModels.C new file mode 100644 index 00000000..d5bb1813 --- /dev/null +++ b/src/dfCombustionModels/CombustionModel/CombustionModel/CombustionModels.C @@ -0,0 +1,40 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "makeCombustionTypes.H" +#include "CombustionModel.H" +#include "basicThermo.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +makeCombustion(basicThermo); + +} + +// ************************************************************************* // diff --git a/src/dfCombustionModels/EDC/EDC.C b/src/dfCombustionModels/EDC/EDC.C new file mode 100644 index 00000000..ff544485 --- /dev/null +++ b/src/dfCombustionModels/EDC/EDC.C @@ -0,0 +1,226 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "EDC.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::combustionModels::EDC::EDC +( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +: + laminar(modelType, thermo, turb, combustionProperties), + version_ + ( + EDCversionNames + [ + this->coeffs().lookupOrDefault + ( + "version", + word(EDCversionNames[EDCdefaultVersion]) + ) + ] + ), + C1_(this->coeffs().lookupOrDefault("C1", 0.05774)), + C2_(this->coeffs().lookupOrDefault("C2", 0.5)), + Cgamma_(this->coeffs().lookupOrDefault("Cgamma", 2.1377)), + Ctau_(this->coeffs().lookupOrDefault("Ctau", 0.4083)), + exp1_(this->coeffs().lookupOrDefault("exp1", EDCexp1[int(version_)])), + exp2_(this->coeffs().lookupOrDefault("exp2", EDCexp2[int(version_)])), + kappa_ + ( + IOobject + ( + "EDC_kappa", + this->mesh().time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + this->mesh(), + dimensionedScalar(dimless, 0) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::combustionModels::EDC::~EDC() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +void Foam::combustionModels::EDC::correct() +{ + tmp tepsilon(this->turbulence().epsilon()); + const volScalarField& epsilon = tepsilon(); + + tmp tmu(this->turbulence().mu()); + const volScalarField& mu = tmu(); + + tmp tk(this->turbulence().k()); + const volScalarField& k = tk(); + + tmp trho(this->rho()); + const volScalarField& rho = trho(); + + scalarField tauStar(epsilon.size(), 0); + + if (version_ == EDCversions::v2016) + { + tmp ttc(this->tc()); + const volScalarField& tc = ttc(); + + forAll(tauStar, i) + { + const scalar nu = mu[i]/(rho[i] + small); + + const scalar Da = + max(min(sqrt(nu/(epsilon[i] + small))/tc[i], 10), 1e-10); + + const scalar ReT = sqr(k[i])/(nu*epsilon[i] + small); + const scalar CtauI = min(C1_/(Da*sqrt(ReT + 1)), 2.1377); + + const scalar CgammaI = + max(min(C2_*sqrt(Da*(ReT + 1)), 5), 0.4082); + + const scalar gammaL = + CgammaI*pow025(nu*epsilon[i]/(sqr(k[i]) + small)); + + tauStar[i] = CtauI*sqrt(nu/(epsilon[i] + small)); + + if (gammaL >= 1) + { + kappa_[i] = 1; + } + else + { + kappa_[i] = + max + ( + min + ( + pow(gammaL, exp1_)/(1 - pow(gammaL, exp2_)), + 1 + ), + 0 + ); + } + } + } + else + { + forAll(tauStar, i) + { + const scalar nu = mu[i]/(rho[i] + small); + const scalar gammaL = + Cgamma_*pow025(nu*epsilon[i]/(sqr(k[i]) + small)); + + tauStar[i] = Ctau_*sqrt(nu/(epsilon[i] + small)); + if (gammaL >= 1) + { + kappa_[i] = 1; + } + else + { + kappa_[i] = + max + ( + min + ( + pow(gammaL, exp1_)/(1 - pow(gammaL, exp2_)), + 1 + ), + 0 + ); + } + } + } + + this->chemistryPtr_->solve(tauStar); +} + + +template +Foam::tmp +Foam::combustionModels::EDC::R(volScalarField& Y) const +{ + return kappa_*laminar::R(Y); +} + + +template +Foam::tmp +Foam::combustionModels::EDC::Qdot() const +{ + return volScalarField::New + ( + "EDC_Qdot", + kappa_*this->chemistryPtr_->Qdot() + ); +} + + +template +bool Foam::combustionModels::EDC::read() +{ + if (laminar::read()) + { + version_ = + ( + EDCversionNames + [ + this->coeffs().lookupOrDefault + ( + "version", + word(EDCversionNames[EDCdefaultVersion]) + ) + ] + ); + C1_ = this->coeffs().lookupOrDefault("C1", 0.05774); + C2_ = this->coeffs().lookupOrDefault("C2", 0.5); + Cgamma_ = this->coeffs().lookupOrDefault("Cgamma", 2.1377); + Ctau_ = this->coeffs().lookupOrDefault("Ctau", 0.4083); + exp1_ = this->coeffs().lookupOrDefault("exp1", EDCexp1[int(version_)]); + exp2_ = this->coeffs().lookupOrDefault("exp2", EDCexp2[int(version_)]); + + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/EDC/EDC.H b/src/dfCombustionModels/EDC/EDC.H new file mode 100644 index 00000000..74b24509 --- /dev/null +++ b/src/dfCombustionModels/EDC/EDC.H @@ -0,0 +1,214 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::combustionModels::EDC + +Description + Eddy Dissipation Concept (EDC) turbulent combustion model. + + This model considers that the reaction occurs in the regions of the flow + where the dissipation of turbulence kinetic energy takes place (fine + structures). The mass fraction of the fine structures and the mean residence + time are provided by an energy cascade model. + + There are many versions and developments of the EDC model, 4 of which are + currently supported in this implementation: v1981, v1996, v2005 and + v2016. The model variant is selected using the optional \c version entry in + the \c EDCCoeffs dictionary, \eg + + \verbatim + EDCCoeffs + { + version v2016; + } + \endverbatim + + The default version is \c v2005 if the \c version entry is not specified. + + Model versions and references: + \verbatim + Version v2005: + + Cgamma = 2.1377 + Ctau = 0.4083 + kappa = gammaL^exp1 / (1 - gammaL^exp2), + + where exp1 = 2, and exp2 = 2. + + Magnussen, B. F. (2005, June). + The Eddy Dissipation Concept - + A Bridge Between Science and Technology. + In ECCOMAS thematic conference on computational combustion + (pp. 21-24). + + Version v1981: + + Changes coefficients exp1 = 3 and exp2 = 3 + + Magnussen, B. (1981, January). + On the structure of turbulence and a generalized + eddy dissipation concept for chemical reaction in turbulent flow. + In 19th Aerospace Sciences Meeting (p. 42). + + Version v1996: + + Changes coefficients exp1 = 2 and exp2 = 3 + + Gran, I. R., & Magnussen, B. F. (1996). + A numerical study of a bluff-body stabilized diffusion flame. + Part 2. Influence of combustion modeling and finite-rate chemistry. + Combustion Science and Technology, 119(1-6), 191-217. + + Version v2016: + + Use local constants computed from the turbulent Da and Re numbers. + + Parente, A., Malik, M. R., Contino, F., Cuoci, A., & Dally, B. B. + (2016). + Extension of the Eddy Dissipation Concept for + turbulence/chemistry interactions to MILD combustion. + Fuel, 163, 98-111. + \endverbatim + +SourceFiles + EDC.C + +\*---------------------------------------------------------------------------*/ + +#ifndef EDC_H +#define EDC_H + +#include "../laminar/laminar.H" +#include "NamedEnum.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + +//- EDC model versions +enum class EDCversions +{ + v1981, + v1996, + v2005, + v2016 +}; + +extern const NamedEnum EDCversionNames; +extern const EDCversions EDCdefaultVersion; + +const scalar EDCexp1[] = {3, 2, 2, 2}; +const scalar EDCexp2[] = {3, 3, 2, 2}; + +/*---------------------------------------------------------------------------*\ + Class EDC Declaration +\*---------------------------------------------------------------------------*/ + +template +class EDC +: + public laminar +{ + // Private Data + + //- The selected model version + EDCversions version_; + + scalar C1_; + scalar C2_; + scalar Cgamma_; + scalar Ctau_; + scalar exp1_; + scalar exp2_; + + //- Mixing parameter + volScalarField kappa_; + + +public: + + //- Runtime type information + TypeName("EDC"); + + + // Constructors + + //- Construct from components + EDC + ( + const word& modelType, + ReactionThermo& type, + const compressibleTurbulenceModel& turb, + const word& combustionProperties + ); + + //- Disallow default bitwise copy construction + EDC(const EDC&); + + + //- Destructor + virtual ~EDC(); + + + // Member Functions + + //- Correct combustion rate + virtual void correct(); + + //- Fuel consumption rate matrix. + virtual tmp R(volScalarField& Y) const; + + //- Heat release rate [kg/m/s^3] + virtual tmp Qdot() const; + + //- Update properties from given dictionary + virtual bool read(); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const EDC&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace combustionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "EDC.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dfCombustionModels/EDC/EDCs.C b/src/dfCombustionModels/EDC/EDCs.C new file mode 100644 index 00000000..cc87df66 --- /dev/null +++ b/src/dfCombustionModels/EDC/EDCs.C @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "EDC.H" +#include "makeCombustionTypes.H" + +#include "basicThermo.H" + +// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * // + +template<> +const char* Foam::NamedEnum +< + Foam::combustionModels::EDCversions, + 4 +>::names[] = +{ + "v1981", + "v1996", + "v2005", + "v2016" +}; + +const Foam::NamedEnum + Foam::combustionModels::EDCversionNames; + +const Foam::combustionModels::EDCversions +Foam::combustionModels::EDCdefaultVersion +( + Foam::combustionModels::EDCversions::v2005 +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +makeCombustionTypes(EDC, basicThermo); + +} + +// ************************************************************************* // diff --git a/src/dfCombustionModels/Make/files b/src/dfCombustionModels/Make/files new file mode 100644 index 00000000..ac084b6f --- /dev/null +++ b/src/dfCombustionModels/Make/files @@ -0,0 +1,31 @@ +combustionModel/combustionModel.C +CombustionModel/CombustionModel/CombustionModels.C + +/*diffusion/diffusions.C*/ +/*infinitelyFastChemistry/infinitelyFastChemistrys.C*/ + +PaSR/PaSRs.C +EDC/EDCs.C + +laminar/laminars.C + +noCombustion/noCombustions.C + +/* +FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C +FSD/reactionRateFlameAreaModels/reactionRateFlameArea/reactionRateFlameArea.C +FSD/reactionRateFlameAreaModels/reactionRateFlameArea/reactionRateFlameAreaNew.C +FSD/reactionRateFlameAreaModels/relaxation/relaxation.C + +FSD/FSDs.C + +zoneCombustion/zoneCombustions.C + + + +functionObjects/Qdot/Qdot.C + +radiationModels/absorptionEmissionModels/greyMeanCombustion/greyMeanCombustion.C +radiationModels/absorptionEmissionModels/wideBandCombustion/wideBandCombustion.C*/ + +LIB = $(FOAM_USER_LIBBIN)/libdfCombustionModels diff --git a/src/dfCombustionModels/Make/options b/src/dfCombustionModels/Make/options new file mode 100644 index 00000000..78b4e8ea --- /dev/null +++ b/src/dfCombustionModels/Make/options @@ -0,0 +1,28 @@ +EXE_INC = -std=c++14 \ + -I$(LIB_SRC)/transportModels/compressible/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(DF_SRC)/CanteraMixture/lnInclude \ + -I$(DF_SRC)/dfChemistryModel/lnInclude \ + -I$(CANTERA_ROOT)/include \ + -I$(TORCH_ROOT)/include \ + -I$(TORCH_ROOT)/include/torch/csrc/api/include + +LIB_LIBS = \ + -lcompressibleTransportModels \ + -lturbulenceModels \ + -lfiniteVolume \ + -lmeshTools \ + -L$(FOAM_USER_LIBBIN) \ + -ldfCompressibleTurbulenceModels \ + -lCanteraMixture \ + -ldfChemistryModel \ + $(CANTERA_ROOT)/lib/libcantera.so \ + $(TORCH_ROOT)/lib/libtorch.so \ + $(TORCH_ROOT)/lib/libc10.so \ + -rdynamic \ + -lpthread + diff --git a/src/dfCombustionModels/PaSR/PaSR.C b/src/dfCombustionModels/PaSR/PaSR.C new file mode 100644 index 00000000..cb993737 --- /dev/null +++ b/src/dfCombustionModels/PaSR/PaSR.C @@ -0,0 +1,135 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "PaSR.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::combustionModels::PaSR::PaSR +( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +: + laminar(modelType, thermo, turb, combustionProperties), + Cmix_(readScalar(this->coeffs().lookup("Cmix"))), + kappa_ + ( + IOobject + ( + thermo.phasePropertyName(typeName + ":kappa"), + this->mesh().time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + this->mesh(), + dimensionedScalar(dimless, 0) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::combustionModels::PaSR::~PaSR() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +void Foam::combustionModels::PaSR::correct() +{ + laminar::correct(); + + tmp tepsilon(this->turbulence().epsilon()); + const scalarField& epsilon = tepsilon(); + + tmp tmuEff(this->turbulence().muEff()); + const scalarField& muEff = tmuEff(); + + tmp ttc(this->tc()); + const scalarField& tc = ttc(); + + tmp trho(this->rho()); + const scalarField& rho = trho(); + + forAll(epsilon, i) + { + const scalar tk = + Cmix_*sqrt(max(muEff[i]/rho[i]/(epsilon[i] + small), 0)); + + if (tk > small) + { + kappa_[i] = tc[i]/(tc[i] + tk); + } + else + { + kappa_[i] = 1.0; + } + } +} + + +template +Foam::tmp +Foam::combustionModels::PaSR::R(volScalarField& Y) const +{ + return kappa_*laminar::R(Y); +} + + +template +Foam::tmp +Foam::combustionModels::PaSR::Qdot() const +{ + return volScalarField::New + ( + this->thermo().phasePropertyName(typeName + ":Qdot"), + kappa_*laminar::Qdot() + ); +} + + +template +bool Foam::combustionModels::PaSR::read() +{ + if (laminar::read()) + { + this->coeffs().lookup("Cmix") >> Cmix_; + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/PaSR/PaSR.H b/src/dfCombustionModels/PaSR/PaSR.H new file mode 100644 index 00000000..a3fa0de1 --- /dev/null +++ b/src/dfCombustionModels/PaSR/PaSR.H @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::combustionModels::PaSR + +Description + Partially stirred reactor turbulent combustion model. + + This model calculates a finite rate, based on both turbulence and chemistry + time scales. Depending on mesh resolution, the Cmix parameter can be used + to scale the turbulence mixing time scale. + +SourceFiles + PaSR.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PaSR_H +#define PaSR_H + +#include "../laminar/laminar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + +/*---------------------------------------------------------------------------*\ + Class PaSR Declaration +\*---------------------------------------------------------------------------*/ + +template +class PaSR +: + public laminar +{ + // Private Data + + //- Mixing constant + scalar Cmix_; + + //- Mixing parameter + volScalarField kappa_; + + +public: + + //- Runtime type information + TypeName("PaSR"); + + + // Constructors + + //- Construct from components + PaSR + ( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties + ); + + //- Disallow default bitwise copy construction + PaSR(const PaSR&); + + + //- Destructor + virtual ~PaSR(); + + + // Member Functions + + //- Correct combustion rate + virtual void correct(); + + //- Fuel consumption rate matrix. + virtual tmp R(volScalarField& Y) const; + + //- Heat release rate [kg/m/s^3] + virtual tmp Qdot() const; + + //- Update properties from given dictionary + virtual bool read(); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const PaSR&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace combustionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "PaSR.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dfCombustionModels/PaSR/PaSRs.C b/src/dfCombustionModels/PaSR/PaSRs.C new file mode 100644 index 00000000..3be4c351 --- /dev/null +++ b/src/dfCombustionModels/PaSR/PaSRs.C @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "PaSR.H" +#include "makeCombustionTypes.H" + +#include "basicThermo.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +makeCombustionTypes(PaSR, basicThermo); + +} + +// ************************************************************************* // diff --git a/src/dfCombustionModels/combustionModel/combustionModel.C b/src/dfCombustionModels/combustionModel/combustionModel.C new file mode 100644 index 00000000..d7b351fd --- /dev/null +++ b/src/dfCombustionModels/combustionModel/combustionModel.C @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "combustionModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(combustionModel, 0); +} + +const Foam::word Foam::combustionModel::combustionPropertiesName +( + "combustionProperties" +); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::IOobject Foam::combustionModel::createIOobject +( + basicThermo& thermo, + const word& combustionProperties +) const +{ + IOobject io + ( + thermo.phasePropertyName(combustionProperties), + thermo.db().time().constant(), + thermo.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (io.typeHeaderOk(true)) + { + io.readOpt() = IOobject::MUST_READ_IF_MODIFIED; + return io; + } + else + { + io.readOpt() = IOobject::NO_READ; + return io; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::combustionModel::combustionModel +( + const word& modelType, + basicThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +: + IOdictionary(createIOobject(thermo, combustionProperties)), + mesh_(thermo.p().mesh()), + turb_(turb), + coeffs_(optionalSubDict(modelType + "Coeffs")), + modelType_(modelType) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::combustionModel::~combustionModel() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::combustionModel::read() +{ + if (regIOobject::read()) + { + coeffs_ = optionalSubDict(modelType_ + "Coeffs"); + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/combustionModel/combustionModel.H b/src/dfCombustionModels/combustionModel/combustionModel.H new file mode 100644 index 00000000..f2f10b79 --- /dev/null +++ b/src/dfCombustionModels/combustionModel/combustionModel.H @@ -0,0 +1,174 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::combustionModel + +Description + Base class for combustion models + +SourceFiles + combustionModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef combustionModel_H +#define combustionModel_H + +#include "IOdictionary.H" +#include "turbulentFluidThermoModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class combustionModel Declaration +\*---------------------------------------------------------------------------*/ + +class combustionModel +: + public IOdictionary +{ + // Private Member Functions + + //- Construct the base IO object + IOobject createIOobject + ( + basicThermo& thermo, + const word& combustionProperties + ) const; + + +protected: + + // Protected data + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Reference to the turbulence model + const compressibleTurbulenceModel& turb_; + + //- Dictionary of the model + dictionary coeffs_; + + //- Model type + const word modelType_; + + +public: + + //- Runtime type information + TypeName("combustionModel"); + + //- Default combustionProperties dictionary name + static const word combustionPropertiesName; + + + // Constructors + + //- Construct from components + combustionModel + ( + const word& modelType, + basicThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties=combustionPropertiesName + ); + + //- Disallow default bitwise copy construction + combustionModel(const combustionModel&); + + + // Selectors + + //- Generic New for each of the related chemistry model + template + static autoPtr New + ( + typename CombustionModel::reactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties + ); + + + //- Destructor + virtual ~combustionModel(); + + + // Member Functions + + //- Return const access to the mesh database + inline const fvMesh& mesh() const; + + //- Return access to turbulence + inline const compressibleTurbulenceModel& turbulence() const; + + //- Return const access to rho + inline const volScalarField& rho() const; + + //- Return const access to phi + inline tmp phi() const; + + //- Return const dictionary of the model + inline const dictionary& coeffs() const; + + //- Correct combustion rate + virtual void correct() = 0; + + //- Fuel consumption rate matrix, i.e. source term for fuel equation + virtual tmp R(volScalarField& Y) const = 0; + + //- Heat release rate [kg/m/s^3] + virtual tmp Qdot() const = 0; + + //- Update properties from given dictionary + virtual bool read(); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const combustionModel&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "combustionModelI.H" + +#ifdef NoRepository + #include "combustionModelTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dfCombustionModels/combustionModel/combustionModelI.H b/src/dfCombustionModels/combustionModel/combustionModelI.H new file mode 100644 index 00000000..a31d3aa3 --- /dev/null +++ b/src/dfCombustionModels/combustionModel/combustionModelI.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::fvMesh& Foam::combustionModel::mesh() const +{ + return mesh_; +} + + +inline const Foam::compressibleTurbulenceModel& +Foam::combustionModel::turbulence() const +{ + return turb_; +} + + +inline const Foam::volScalarField& Foam::combustionModel::rho() const +{ + return turbulence().rho(); +} + + +inline Foam::tmp Foam::combustionModel::phi() const +{ + return turbulence().alphaRhoPhi(); +} + + +inline const Foam::dictionary& Foam::combustionModel::coeffs() const +{ + return coeffs_; +} + +// ************************************************************************* // diff --git a/src/dfCombustionModels/combustionModel/combustionModelTemplates.C b/src/dfCombustionModels/combustionModel/combustionModelTemplates.C new file mode 100644 index 00000000..cb3ed4b7 --- /dev/null +++ b/src/dfCombustionModels/combustionModel/combustionModelTemplates.C @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +template +Foam::autoPtr Foam::combustionModel::New +( + typename CombustionModel::reactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +{ + IOobject combIO + ( + IOobject + ( + thermo.phasePropertyName(combustionProperties), + thermo.db().time().constant(), + thermo.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + word combModelName("none"); + if (combIO.typeHeaderOk(false)) + { + IOdictionary(combIO).lookup("combustionModel") >> combModelName; + } + else + { + Info<< "Combustion model not active: " + << thermo.phasePropertyName(combustionProperties) + << " not found" << endl; + } + + Info<< "Selecting combustion model " << combModelName << endl; + + const wordList cmpts2(basicThermo::splitThermoName(combModelName, 2)); + const wordList cmpts3(basicThermo::splitThermoName(combModelName, 3)); + if (cmpts2.size() == 2 || cmpts3.size() == 3) + { + combModelName = cmpts2.size() ? cmpts2[0] : cmpts3[0]; + + WarningInFunction + << "Template parameters are no longer required when selecting a " + << combustionModel::typeName << ". This information is now " + << "obtained directly from the thermodynamics. Actually selecting " + << "combustion model " << combModelName << "." << endl; + } + + typedef typename CombustionModel::dictionaryConstructorTable cstrTableType; + cstrTableType* cstrTable = CombustionModel::dictionaryConstructorTablePtr_; + + const word compCombModelName = + combModelName + '<' + CombustionModel::reactionThermo::typeName + '>'; + + const word thermoCombModelName = + combModelName + '<' + CombustionModel::reactionThermo::typeName + ',' + + thermo.thermoName() + '>'; + + typename cstrTableType::iterator compCstrIter = + cstrTable->find(compCombModelName); + + typename cstrTableType::iterator thermoCstrIter = + cstrTable->find(thermoCombModelName); + + if (compCstrIter == cstrTable->end() && thermoCstrIter == cstrTable->end()) + { + FatalErrorInFunction + << "Unknown " << combustionModel::typeName << " type " + << combModelName << endl << endl; + + const wordList names(cstrTable->toc()); + + wordList thisCmpts; + thisCmpts.append(word::null); + thisCmpts.append(CombustionModel::reactionThermo::typeName); + thisCmpts.append(basicThermo::splitThermoName(thermo.thermoName(), 5)); + + wordList validNames; + forAll(names, i) + { + wordList cmpts(basicThermo::splitThermoName(names[i], 2)); + if (cmpts.size() != 2) + { + cmpts = basicThermo::splitThermoName(names[i], 7); + } + + bool isValid = true; + for (label i = 1; i < cmpts.size() && isValid; ++ i) + { + isValid = isValid && cmpts[i] == thisCmpts[i]; + } + + if (isValid) + { + validNames.append(cmpts[0]); + } + } + + FatalErrorInFunction + << "Valid " << combustionModel::typeName << " types for this " + << "thermodynamic model are:" << endl << validNames << endl; + + List validCmpts2, validCmpts7; + validCmpts2.append(wordList(2, word::null)); + validCmpts2[0][0] = combustionModel::typeName; + validCmpts2[0][1] = "reactionThermo"; + validCmpts7.append(wordList(7, word::null)); + validCmpts7[0][0] = combustionModel::typeName; + validCmpts7[0][1] = "reactionThermo"; + validCmpts7[0][2] = "transport"; + validCmpts7[0][3] = "thermo"; + validCmpts7[0][4] = "equationOfState"; + validCmpts7[0][5] = "specie"; + validCmpts7[0][6] = "energy"; + forAll(names, i) + { + const wordList cmpts2(basicThermo::splitThermoName(names[i], 2)); + const wordList cmpts7(basicThermo::splitThermoName(names[i], 7)); + if (cmpts2.size() == 2) + { + validCmpts2.append(cmpts2); + } + if (cmpts7.size() == 7) + { + validCmpts7.append(cmpts7); + } + } + + FatalErrorInFunction + << "All " << validCmpts2[0][0] << '/' << validCmpts2[0][1] + << " combinations are:" << endl << endl; + printTable(validCmpts2, FatalErrorInFunction); + + FatalErrorInFunction << endl; + + FatalErrorInFunction + << "All " << validCmpts7[0][0] << '/' << validCmpts7[0][1] + << "/thermoPhysics combinations are:" << endl << endl; + printTable(validCmpts7, FatalErrorInFunction); + + FatalErrorInFunction << exit(FatalError); + } + + return autoPtr + ( + thermoCstrIter != cstrTable->end() + ? thermoCstrIter()(combModelName, thermo, turb, combustionProperties) + : compCstrIter()(combModelName, thermo, turb, combustionProperties) + ); +} + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/combustionModel/makeCombustionTypes.H b/src/dfCombustionModels/combustionModel/makeCombustionTypes.H new file mode 100644 index 00000000..3e989f2d --- /dev/null +++ b/src/dfCombustionModels/combustionModel/makeCombustionTypes.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#ifndef makeCombustionTypes_H +#define makeCombustionTypes_H + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeCombustion(Comp) \ + \ + typedef CombustionModel CombustionModel##Comp; \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + CombustionModel##Comp, \ + ( \ + word(CombustionModel##Comp::typeName_()) + "<" + Comp::typeName \ + + ">" \ + ).c_str(), \ + 0 \ + ); \ + \ + defineTemplateRunTimeSelectionTable \ + ( \ + CombustionModel##Comp, \ + dictionary \ + ); + + +#define makeCombustionTypesThermo(CombModel, Comp, Thermo) \ + \ + typedef combustionModels::CombModel \ + CombModel##Comp##Thermo; \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + CombModel##Comp##Thermo, \ + ( \ + word(CombModel##Comp##Thermo::typeName_()) + "<" + Comp::typeName \ + + "," + Thermo::typeName() + ">" \ + ).c_str(), \ + 0 \ + ); \ + \ + CombustionModel:: \ + add##dictionary##ConstructorToTable \ + add##CombModel##Comp##Thermo##dictionary##ConstructorTo##\ +CombustionModel##Comp##Table_; + + +#define makeCombustionTypes(CombModel, Comp) \ + \ + typedef combustionModels::CombModel CombModel##Comp; \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + CombModel##Comp, \ + ( \ + word(CombModel##Comp::typeName_()) + "<" + Comp::typeName + ">" \ + ).c_str(), \ + 0 \ + ); \ + \ + CombustionModel:: \ + add##dictionary##ConstructorToTable \ + add##CombModel##Comp##dictionary##ConstructorTo##CombustionModel##Comp\ +##Table_; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dfCombustionModels/laminar/laminar.C b/src/dfCombustionModels/laminar/laminar.C new file mode 100644 index 00000000..b8388a2b --- /dev/null +++ b/src/dfCombustionModels/laminar/laminar.C @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "laminar.H" +#include "fvmSup.H" +#include "localEulerDdtScheme.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::combustionModels::laminar::laminar +( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +: + ChemistryCombustion + ( + modelType, + thermo, + turb, + combustionProperties + ), + integrateReactionRate_ + ( + this->coeffs().lookupOrDefault("integrateReactionRate", true) + ) +{ + if (integrateReactionRate_) + { + Info<< " using integrated reaction rate" << endl; + } + else + { + Info<< " using instantaneous reaction rate" << endl; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::combustionModels::laminar::~laminar() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +Foam::tmp +Foam::combustionModels::laminar::tc() const +{ + tmp ttc + ( + volScalarField::New + ( + "tc", + this->mesh_, + dimensionedScalar(dimTime, 0) + ) + ); + scalarField& tc = ttc.ref(); + + const int nCells = this->mesh_.nCells(); + for(int cellI=0; cellI < nCells; ++cellI) + { + PtrList& Y = this->chemistryPtr_->Y(); + forAll(Y, i) + { + scalar tc_i = 0; + const scalar mag_RR = mag(this->chemistryPtr_->RR(i)[cellI]); + if(mag_RR > small) tc_i = Y[i][cellI]/mag_RR; + tc[cellI] = max(tc[cellI], tc_i); + } + } + + return ttc; +} + + +template +void Foam::combustionModels::laminar::correct() +{ + //if (integrateReactionRate_) + //{ + if (fv::localEulerDdt::enabled(this->mesh())) + { + const scalarField& rDeltaT = + fv::localEulerDdt::localRDeltaT(this->mesh()); + + if (this->coeffs().found("maxIntegrationTime")) + { + const scalar maxIntegrationTime + ( + readScalar(this->coeffs().lookup("maxIntegrationTime")) + ); + + this->chemistryPtr_->solve + ( + min(1.0/rDeltaT, maxIntegrationTime)() + ); + } + else + { + this->chemistryPtr_->solve((1.0/rDeltaT)()); + } + } + else + { + this->chemistryPtr_->solve(this->mesh().time().deltaTValue()); + } + // } + // else + // { + // this->chemistryPtr_->calculate(); + // } +} + + +template +Foam::tmp +Foam::combustionModels::laminar::R(volScalarField& Y) const +{ + tmp tSu(new fvScalarMatrix(Y, dimMass/dimTime)); + fvScalarMatrix& Su = tSu.ref(); + + //const label specieI = this->chemistryPtr_->thermo().specieI(Y.member()); + const label specieI = this->chemistryPtr_->species()[Y.member()]; + Su += this->chemistryPtr_->RR(specieI); + + return tSu; +} + + +template +Foam::tmp +Foam::combustionModels::laminar::Qdot() const +{ + return this->chemistryPtr_->Qdot(); +} + + +template +bool Foam::combustionModels::laminar::read() +{ + if (ChemistryCombustion::read()) + { + integrateReactionRate_ = + this->coeffs().lookupOrDefault("integrateReactionRate", true); + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/laminar/laminar.H b/src/dfCombustionModels/laminar/laminar.H new file mode 100644 index 00000000..d4ec595e --- /dev/null +++ b/src/dfCombustionModels/laminar/laminar.H @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::combustionModels::laminar + +Description + Laminar combustion model. + +SourceFiles + laminar.C + +\*---------------------------------------------------------------------------*/ + +#ifndef laminar_H +#define laminar_H + +#include "ChemistryCombustion.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + +/*---------------------------------------------------------------------------*\ + Class laminar Declaration +\*---------------------------------------------------------------------------*/ + +template +class laminar +: + public ChemistryCombustion +{ + // Private Data + + //- Integrate reaction rate over the time-step + // using the selected ODE solver + bool integrateReactionRate_; + + +protected: + + // Protected Member Functions + + //- Return the chemical time scale + tmp tc() const; + + +public: + + //- Runtime type information + TypeName("laminar"); + + + // Constructors + + //- Construct from components + laminar + ( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties + ); + + //- Disallow default bitwise copy construction + laminar(const laminar&); + + + //- Destructor + virtual ~laminar(); + + + // Member Functions + + //- Correct combustion rate + virtual void correct(); + + //- Fuel consumption rate matrix. + virtual tmp R(volScalarField& Y) const; + + //- Heat release rate [kg/m/s^3] + virtual tmp Qdot() const; + + //- Update properties from given dictionary + virtual bool read(); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const laminar&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace combustionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "laminar.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dfCombustionModels/laminar/laminars.C b/src/dfCombustionModels/laminar/laminars.C new file mode 100644 index 00000000..1571eca8 --- /dev/null +++ b/src/dfCombustionModels/laminar/laminars.C @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "laminar.H" +#include "makeCombustionTypes.H" + +//#include "psiReactionThermo.H" +//#include "rhoReactionThermo.H" +#include "basicThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +//makeCombustionTypes(laminar, psiReactionThermo); +//makeCombustionTypes(laminar, rhoReactionThermo); +makeCombustionTypes(laminar, basicThermo); + +} + +// ************************************************************************* // diff --git a/src/dfCombustionModels/noCombustion/noCombustion.C b/src/dfCombustionModels/noCombustion/noCombustion.C new file mode 100644 index 00000000..e4841436 --- /dev/null +++ b/src/dfCombustionModels/noCombustion/noCombustion.C @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "noCombustion.H" +#include "fvmSup.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::combustionModels::noCombustion::noCombustion +( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties +) +: + ChemistryCombustion(modelType, thermo, turb, combustionProperties) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::combustionModels::noCombustion::~noCombustion() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +void Foam::combustionModels::noCombustion::correct() +{} + + +template +Foam::tmp +Foam::combustionModels::noCombustion::R +( + volScalarField& Y +) const +{ + tmp tSu + ( + new fvScalarMatrix(Y, dimMass/dimTime) + ); + + return tSu; +} + + +template +Foam::tmp +Foam::combustionModels::noCombustion::Qdot() const +{ + return volScalarField::New + ( + this->thermo().phasePropertyName(typeName + ":Qdot"), + this->mesh(), + dimensionedScalar(dimEnergy/dimVolume/dimTime, 0) + ); +} + + +template +bool Foam::combustionModels::noCombustion::read() +{ + if (ChemistryCombustion::read()) + { + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/noCombustion/noCombustion.H b/src/dfCombustionModels/noCombustion/noCombustion.H new file mode 100644 index 00000000..9d41e072 --- /dev/null +++ b/src/dfCombustionModels/noCombustion/noCombustion.H @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::combustionModels::noCombustion + +Description + Dummy combustion model for 'no combustion' + +SourceFiles + noCombustion.C + +\*---------------------------------------------------------------------------*/ + +#ifndef noCombustion_H +#define noCombustion_H + +#include "ChemistryCombustion.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + +/*---------------------------------------------------------------------------*\ + Class noCombustion Declaration +\*---------------------------------------------------------------------------*/ + +template +class noCombustion +: + public ChemistryCombustion +{ +public: + + //- Runtime type information + TypeName("none"); + + + // Constructors + + //- Construct from components + noCombustion + ( + const word& modelType, + ReactionThermo& thermo, + const compressibleTurbulenceModel& turb, + const word& combustionProperties + ); + + //- Disallow default bitwise copy construction + noCombustion(const noCombustion&); + + + //- Destructor + virtual ~noCombustion(); + + + // Member Functions + + //- Correct combustion rate + virtual void correct(); + + //- Fuel consumption rate matrix + virtual tmp R(volScalarField& Y) const; + + //- Heat release rate [kg/m/s^3] + virtual tmp Qdot() const; + + //- Update properties from given dictionary + virtual bool read(); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const noCombustion&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace combustionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "noCombustion.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dfCombustionModels/noCombustion/noCombustions.C b/src/dfCombustionModels/noCombustion/noCombustions.C new file mode 100644 index 00000000..1126dfed --- /dev/null +++ b/src/dfCombustionModels/noCombustion/noCombustions.C @@ -0,0 +1,40 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "noCombustion.H" +#include "makeCombustionTypes.H" +#include "basicThermo.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +makeCombustionTypes(noCombustion, basicThermo); + +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //