Commit f2c263b9 authored by Henry Weller's avatar Henry Weller
Browse files

TDACChemistryModel: New chemistry model providing Tabulation of Dynamic Adaptive Chemistry

Provides efficient integration of complex laminar reaction chemistry,
combining the advantages of automatic dynamic specie and reaction
reduction with ISAT (in situ adaptive tabulation).  The advantages grow
as the complexity of the chemistry increases.

References:
    Contino, F., Jeanmart, H., Lucchini, T., & D’Errico, G. (2011).
    Coupling of in situ adaptive tabulation and dynamic adaptive chemistry:
    An effective method for solving combustion in engine simulations.
    Proceedings of the Combustion Institute, 33(2), 3057-3064.

    Contino, F., Lucchini, T., D'Errico, G., Duynslaegher, C.,
    Dias, V., & Jeanmart, H. (2012).
    Simulations of advanced combustion modes using detailed chemistry
    combined with tabulation and mechanism reduction techniques.
    SAE International Journal of Engines,
    5(2012-01-0145), 185-196.

    Contino, F., Foucher, F., Dagaut, P., Lucchini, T., D’Errico, G., &
    Mounaïm-Rousselle, C. (2013).
    Experimental and numerical analysis of nitric oxide effect on the
    ignition of iso-octane in a single cylinder HCCI engine.
    Combustion and Flame, 160(8), 1476-1483.

    Contino, F., Masurier, J. B., Foucher, F., Lucchini, T., D’Errico, G., &
    Dagaut, P. (2014).
    CFD simulations using the TDAC method to model iso-octane combustion
    for a large range of ozone seeding and temperature conditions
    in a single cylinder HCCI engine.
    Fuel, 137, 179-184.

Two tutorial cases are currently provided:
    + tutorials/combustion/chemFoam/ic8h18_TDAC
    + tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D_GRI_TDAC

the first of which clearly demonstrates the advantage of dynamic
adaptive chemistry providing ~10x speedup,

the second demonstrates ISAT on the modest complex GRI mechanisms for
methane combustion, providing a speedup of ~4x.

More tutorials demonstrating TDAC on more complex mechanisms and cases
will be provided soon in addition to documentation for the operation and
settings of TDAC.  Also further updates to the TDAC code to improve
consistency and integration with the rest of OpenFOAM and further
optimize operation can be expected.

Original code providing all algorithms for chemistry reduction and
tabulation contributed by Francesco Contino, Tommaso Lucchini, Gianluca
D’Errico, Hervé Jeanmart, Nicolas Bourgeois and Stéphane Backaert.

Implementation updated, optimized and integrated into OpenFOAM-dev by
Henry G. Weller, CFD Direct Ltd with the help of Francesco Contino.
parent 8b8270fb
......@@ -16,7 +16,7 @@ tmp<fv::convectionScheme<scalar>> mvConvection
forAll(Y, i)
{
if (i != inertIndex)
if (i != inertIndex && composition.active(i))
{
volScalarField& Yi = Y[i];
......
......@@ -16,7 +16,7 @@ tmp<fv::convectionScheme<scalar>> mvConvection
forAll(Y, i)
{
if (i != inertIndex)
if (i != inertIndex && composition.active(i))
{
volScalarField& Yi = Y[i];
......
......@@ -17,7 +17,7 @@ tmp<fv::convectionScheme<scalar>> mvConvection
forAll(Y, i)
{
if (i != inertIndex)
if (i != inertIndex && composition.active(i))
{
volScalarField& Yi = Y[i];
......
......@@ -17,7 +17,7 @@ tmp<fv::convectionScheme<scalar>> mvConvection
forAll(Y, i)
{
if (i != inertIndex)
if (i != inertIndex && composition.active(i))
{
volScalarField& Yi = Y[i];
......
......@@ -16,7 +16,7 @@ tmp<fv::convectionScheme<scalar>> mvConvection
forAll(Y, i)
{
if (i != inertIndex)
if (i != inertIndex && composition.active(i))
{
volScalarField& Yi = Y[i];
......
......@@ -16,7 +16,7 @@ tmp<fv::convectionScheme<scalar>> mvConvection
forAll(Y, i)
{
if (i != inertIndex)
if (i != inertIndex && composition.active(i))
{
volScalarField& Yi = Y[i];
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -142,6 +142,12 @@ Foam::MultiComponentPhaseModel<BasePhaseModel>::YiEqn
this->name()
)
)
|| (
!this->thermo_->composition().active
(
this->thermo_->composition().species()[Yi.member()]
)
)
)
{
return tmp<fvScalarMatrix>();
......
......@@ -57,6 +57,7 @@ cleanCase()
rm -rf processor* > /dev/null 2>&1
rm -rf postProcessing > /dev/null 2>&1
rm -rf TDAC > /dev/null 2>&1
rm -rf probes* > /dev/null 2>&1
rm -rf forces* > /dev/null 2>&1
rm -rf graphs* > /dev/null 2>&1
......
......@@ -6,6 +6,9 @@ chemistryModel/psiChemistryModel/psiChemistryModels.C
chemistryModel/rhoChemistryModel/rhoChemistryModel.C
chemistryModel/rhoChemistryModel/rhoChemistryModels.C
chemistryModel/TDACChemistryModel/reduction/makeChemistryReductionMethods.C
chemistryModel/TDACChemistryModel/tabulation/makeChemistryTabulationMethods.C
chemistrySolver/chemistrySolver/makeChemistrySolvers.C
LIB = $(FOAM_LIBBIN)/libchemistryModel
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
Class
Foam::TDACChemistryModel
Description
Extends chemistryModel by adding the TDAC method.
References:
\verbatim
Contino, F., Jeanmart, H., Lucchini, T., & D’Errico, G. (2011).
Coupling of in situ adaptive tabulation and dynamic adaptive chemistry:
An effective method for solving combustion in engine simulations.
Proceedings of the Combustion Institute, 33(2), 3057-3064.
Contino, F., Lucchini, T., D'Errico, G., Duynslaegher, C.,
Dias, V., & Jeanmart, H. (2012).
Simulations of advanced combustion modes using detailed chemistry
combined with tabulation and mechanism reduction techniques.
SAE International Journal of Engines,
5(2012-01-0145), 185-196.
Contino, F., Foucher, F., Dagaut, P., Lucchini, T., D’Errico, G., &
Mounaïm-Rousselle, C. (2013).
Experimental and numerical analysis of nitric oxide effect on the
ignition of iso-octane in a single cylinder HCCI engine.
Combustion and Flame, 160(8), 1476-1483.
Contino, F., Masurier, J. B., Foucher, F., Lucchini, T., D’Errico, G., &
Dagaut, P. (2014).
CFD simulations using the TDAC method to model iso-octane combustion
for a large range of ozone seeding and temperature conditions
in a single cylinder HCCI engine.
Fuel, 137, 179-184.
\endverbatim
SourceFiles
TDACChemistryModelI.H
TDACChemistryModel.C
\*---------------------------------------------------------------------------*/
#ifndef TDACChemistryModel_H
#define TDACChemistryModel_H
#include "chemistryModel.H"
#include "chemistryReductionMethod.H"
#include "chemistryTabulationMethod.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class TDACChemistryModel Declaration
\*---------------------------------------------------------------------------*/
template<class CompType, class ThermoType>
class TDACChemistryModel
:
public chemistryModel<CompType, ThermoType>
{
// Private member data
// Mechanism reduction
label NsDAC_;
scalarField completeC_;
scalarField simplifiedC_;
Field<bool> reactionsDisabled_;
Field<label> completeToSimplifiedIndex_;
DynamicList<label> simplifiedToCompleteIndex_;
List<List<specieElement>> specieComp_;
autoPtr<chemistryReductionMethod<CompType, ThermoType>> mechRed_;
// Tabulation
autoPtr<chemistryTabulationMethod<CompType, ThermoType>> tabulation_;
// Log file for the average time spent reducing the chemistry
autoPtr<OFstream> cpuReduceFile_;
// Write average number of species
autoPtr<OFstream> nActiveSpeciesFile_;
//- Log file for the average time spent adding tabulated data
autoPtr<OFstream> cpuAddFile_;
//- Log file for the average time spent retrieving tabulated data
autoPtr<OFstream> cpuRetrieveFile_;
//- Log file for average time spent solving the chemistry
autoPtr<OFstream> cpuSolveFile_;
// Private Member Functions
//- Disallow copy constructor
TDACChemistryModel(const TDACChemistryModel&);
//- Disallow default bitwise assignment
void operator=(const TDACChemistryModel&);
//- Solve the reaction system for the given time step
// of given type and return the characteristic time
// Variable number of species added
template<class DeltaTType>
scalar solve(const DeltaTType& deltaT);
public:
//- Runtime type information
TypeName("TDACChemistryModel");
// Constructors
//- Construct from mesh
TDACChemistryModel
(
const fvMesh& mesh,
const word& phaseName
);
//- Destructor
virtual ~TDACChemistryModel();
// Member Functions
//- Create and return a TDAC log file of the given name
inline autoPtr<OFstream> logFile(const word& name) const;
inline PtrList<volScalarField>& Y();
//- dc/dt = omega, rate of change in concentration, for each species
virtual void omega
(
const scalarField& c,
const scalar T,
const scalar p,
scalarField& dcdt
) const;
//- Return the reaction rate for reaction r and the reference
// species and charateristic times
virtual scalar omega
(
const Reaction<ThermoType>& r,
const scalarField& c,
const scalar T,
const scalar p,
scalar& pf,
scalar& cf,
label& lRef,
scalar& pr,
scalar& cr,
label& rRef
) const;
// Chemistry model functions (overriding functions in
// chemistryModel to use the private solve function)
//- Solve the reaction system for the given time step
// and return the characteristic time
virtual scalar solve(const scalar deltaT);
//- Solve the reaction system for the given time step
// and return the characteristic time
virtual scalar solve(const scalarField& deltaT);
// ODE functions (overriding functions in chemistryModel to take into
// account the variable number of species)
virtual void derivatives
(
const scalar t,
const scalarField& c,
scalarField& dcdt
) const;
//- Pure jacobian function for tabulation
void jacobian
(
const scalar t,
const scalarField& c,
scalarSquareMatrix& dfdc
) const;
virtual void jacobian
(
const scalar t,
const scalarField& c,
scalarField& dcdt,
scalarSquareMatrix& dfdc
) const;
virtual void solve
(
scalarField& c,
scalar& T,
scalar& p,
scalar& deltaT,
scalar& subDeltaT
) const = 0;
// Mechanism reduction access functions
inline void setNsDAC(const label newNsDAC);
inline void setNSpecie(const label newNs);
inline scalarField& completeC();
inline scalarField& simplifiedC();
inline Field<bool>& reactionsDisabled();
inline bool active(const label i) const;
inline void setActive(const label i);
inline DynamicList<label>& simplifiedToCompleteIndex();
inline Field<label>& completeToSimplifiedIndex();
inline const Field<label>& completeToSimplifiedIndex() const;
inline List<List<specieElement>>& specieComp();
inline autoPtr<chemistryReductionMethod<CompType, ThermoType>>&
mechRed();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "TDACChemistryModelI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "TDACChemistryModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CompType, class ThermoType>
inline Foam::autoPtr<Foam::OFstream>
Foam::TDACChemistryModel<CompType, ThermoType>::logFile(const word& name) const
{
mkDir(this->mesh().time().path()/"TDAC");
return autoPtr<OFstream>
(
new OFstream
(
this->mesh().time().path()/"TDAC"/name
)
);
}
template<class CompType, class ThermoType>
inline Foam::PtrList<Foam::volScalarField>&
Foam::TDACChemistryModel<CompType, ThermoType>::Y()
{
return this->Y_;
}
template<class CompType, class ThermoType>
inline Foam::autoPtr<Foam::chemistryReductionMethod<CompType, ThermoType>>&
Foam::TDACChemistryModel<CompType, ThermoType>::mechRed()
{
return mechRed_;
}
template<class CompType, class ThermoType>
inline void Foam::TDACChemistryModel<CompType, ThermoType>::setActive
(
const label i
)
{
this->thermo().composition().setActive(i);
}
template<class CompType, class ThermoType>
inline bool Foam::TDACChemistryModel<CompType, ThermoType>::active
(
const label i
) const
{
return this->thermo().composition().active(i);
}
template<class CompType, class ThermoType>
inline void
Foam::TDACChemistryModel<CompType, ThermoType>::setNsDAC(const label newNsDAC)
{
NsDAC_ = newNsDAC;
}
template<class CompType, class ThermoType>
inline void
Foam::TDACChemistryModel<CompType, ThermoType>::setNSpecie(const label newNs)
{
this->nSpecie_ = newNs;
}
template<class CompType, class ThermoType>
inline Foam::DynamicList<Foam::label>&
Foam::TDACChemistryModel<CompType, ThermoType>::simplifiedToCompleteIndex()
{
return simplifiedToCompleteIndex_;
}
template<class CompType, class ThermoType>
inline Foam::Field<Foam::label>&
Foam::TDACChemistryModel<CompType, ThermoType>::completeToSimplifiedIndex()
{
return completeToSimplifiedIndex_;
}
template<class CompType, class ThermoType>
inline const Foam::Field<Foam::label>&
Foam::TDACChemistryModel<CompType, ThermoType>::
completeToSimplifiedIndex() const
{
return completeToSimplifiedIndex_;
}
template<class CompType, class ThermoType>
inline Foam::Field<bool>&
Foam::TDACChemistryModel<CompType, ThermoType>::reactionsDisabled()
{
return reactionsDisabled_;
}
template<class CompType, class ThermoType>
inline Foam::scalarField&
Foam::TDACChemistryModel<CompType, ThermoType>::completeC()
{
return completeC_;
}
template<class CompType, class ThermoType>
inline Foam::scalarField&
Foam::TDACChemistryModel<CompType, ThermoType>::simplifiedC()
{
return simplifiedC_;
}
template<class CompType, class ThermoType>
inline Foam::List<Foam::List<Foam::specieElement>>&
Foam::TDACChemistryModel<CompType, ThermoType>::specieComp()
{
return specieComp_;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
Class
Foam::chemistryReductionMethods::DAC
Description
The Dynamic Adaptive Chemistry (DAC) method [1] simplify the chemistry
using the matrix rAB defined by (DRGEP algorithm [2])
|sum_i=1->Nr vAi wi dBi|
rAB = --------------------------- ,
max(PA, CA)