singleStepCombustion: Refactored to include the singleStepReactingMixture functionality

allowing the removal of singleStepReactingMixture which is the first step in
refactoring the instantiation of the reaction scheme.
This commit is contained in:
Henry Weller
2019-08-01 14:24:13 +01:00
parent a8020984f6
commit b8fcd10cf7
17 changed files with 459 additions and 686 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -97,15 +97,15 @@ FSD<ReactionThermo, ThermoType>::~FSD()
template<class ReactionThermo, class ThermoType>
void FSD<ReactionThermo, ThermoType>::calculateSourceNorm()
{
this->singleMixturePtr_->fresCorrect();
this->fresCorrect();
const label fuelI = this->singleMixturePtr_->fuelIndex();
const label fuelI = this->fuelIndex();
const volScalarField& YFuel = this->thermo().composition().Y()[fuelI];
const volScalarField& YO2 = this->thermo().composition().Y("O2");
const dimensionedScalar s = this->singleMixturePtr_->s();
const dimensionedScalar s = this->s();
ft_ =
(s*YFuel - (YO2 - YO2OxiStream_))/(s*YFuelFuelStream_ + YO2OxiStream_);
@ -247,9 +247,9 @@ void FSD<ReactionThermo, ThermoType>::calculateSourceNorm()
List<label> productsIndex(2, label(-1));
{
label i = 0;
forAll(this->singleMixturePtr_->specieProd(), specieI)
forAll(this->specieProd(), specieI)
{
if (this->singleMixturePtr_->specieProd()[specieI] < 0)
if (this->specieProd()[specieI] < 0)
{
productsIndex[i] = specieI;
i++;
@ -262,7 +262,7 @@ void FSD<ReactionThermo, ThermoType>::calculateSourceNorm()
scalar YprodTotal = 0;
forAll(productsIndex, j)
{
YprodTotal += this->singleMixturePtr_->Yprod0()[productsIndex[j]];
YprodTotal += this->Yprod0()[productsIndex[j]];
}
forAll(ft_, celli)
@ -303,7 +303,7 @@ void FSD<ReactionThermo, ThermoType>::calculateSourceNorm()
pc = min(C_*c, scalar(1));
const volScalarField fres(this->singleMixturePtr_->fres(fuelI));
const volScalarField fres(this->fres(fuelI));
this->wFuel_ == mgft*pc*omegaFuelBar;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,9 +69,9 @@ void diffusion<ReactionThermo, ThermoType>::correct()
this->wFuel_ ==
dimensionedScalar(dimMass/pow3(dimLength)/dimTime, 0);
this->singleMixturePtr_->fresCorrect();
this->fresCorrect();
const label fuelI = this->singleMixturePtr_->fuelIndex();
const label fuelI = this->fuelIndex();
const volScalarField& YFuel = this->thermo().composition().Y()[fuelI];

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -67,13 +67,13 @@ void infinitelyFastChemistry<ReactionThermo, ThermoType>::correct()
this->wFuel_ ==
dimensionedScalar(dimMass/pow3(dimLength)/dimTime, 0);
this->singleMixturePtr_->fresCorrect();
this->fresCorrect();
const label fuelI = this->singleMixturePtr_->fuelIndex();
const label fuelI = this->fuelIndex();
const volScalarField& YFuel = this->thermo().composition().Y()[fuelI];
const dimensionedScalar s = this->singleMixturePtr_->s();
const dimensionedScalar s = this->s();
if (this->thermo().composition().contains("O2"))
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,11 +26,115 @@ License
#include "singleStepCombustion.H"
#include "fvmSup.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace combustionModels
{
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class ReactionThermo, class ThermoType>
void singleStepCombustion<ReactionThermo, ThermoType>::calculateqFuel()
{
const Reaction<ThermoType>& reaction = reactions_[0];
const scalar Wu = mixture_.speciesData()[fuelIndex_].W();
forAll(reaction.lhs(), i)
{
const label speciei = reaction.lhs()[i].index;
const scalar stoichCoeff = reaction.lhs()[i].stoichCoeff;
specieStoichCoeffs_[speciei] = -stoichCoeff;
qFuel_.value() += mixture_.speciesData()[speciei].hc()*stoichCoeff/Wu;
}
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
const scalar stoichCoeff = reaction.rhs()[i].stoichCoeff;
specieStoichCoeffs_[speciei] = stoichCoeff;
qFuel_.value() -= mixture_.speciesData()[speciei].hc()*stoichCoeff/Wu;
specieProd_[speciei] = -1;
}
Info << "Fuel heat of combustion :" << qFuel_.value() << endl;
}
template<class ReactionThermo, class ThermoType>
void singleStepCombustion<ReactionThermo, ThermoType>:: massAndAirStoichRatios()
{
const label O2Index = mixture_.species()["O2"];
const scalar Wu = mixture_.speciesData()[fuelIndex_].W();
stoicRatio_ =
(mixture_.speciesData()[inertIndex_].W()
* specieStoichCoeffs_[inertIndex_]
+ mixture_.speciesData()[O2Index].W()
* mag(specieStoichCoeffs_[O2Index]))
/ (Wu*mag(specieStoichCoeffs_[fuelIndex_]));
s_ =
(mixture_.speciesData()[O2Index].W()
* mag(specieStoichCoeffs_[O2Index]))
/ (Wu*mag(specieStoichCoeffs_[fuelIndex_]));
Info << "stoichiometric air-fuel ratio :" << stoicRatio_.value() << endl;
Info << "stoichiometric oxygen-fuel ratio :" << s_.value() << endl;
}
template<class ReactionThermo, class ThermoType>
void singleStepCombustion<ReactionThermo, ThermoType>:: calculateMaxProducts()
{
const Reaction<ThermoType>& reaction = reactions_[0];
scalar Wm = 0.0;
scalar totalMol = 0.0;
forAll(reaction.rhs(), i)
{
label speciei = reaction.rhs()[i].index;
totalMol += mag(specieStoichCoeffs_[speciei]);
}
scalarList Xi(reaction.rhs().size());
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
Xi[i] = mag(specieStoichCoeffs_[speciei])/totalMol;
Wm += Xi[i]*mixture_.speciesData()[speciei].W();
}
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
Yprod0_[speciei] = mixture_.speciesData()[speciei].W()/Wm*Xi[i];
}
Info << "Maximum products mass concentrations:" << nl;
forAll(Yprod0_, i)
{
if (Yprod0_[i] > 0)
{
Info<< " " << mixture_.species()[i] << ": " << Yprod0_[i] << nl;
}
}
// Normalize the stoichiometric coeff to mass
forAll(specieStoichCoeffs_, i)
{
specieStoichCoeffs_[i] =
specieStoichCoeffs_[i]
* mixture_.speciesData()[i].W()
/ (mixture_.speciesData()[fuelIndex_].W()
* mag(specieStoichCoeffs_[fuelIndex_]));
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ReactionThermo, class ThermoType>
@ -43,7 +147,17 @@ singleStepCombustion<ReactionThermo, ThermoType>::singleStepCombustion
)
:
ThermoCombustion<ReactionThermo>(modelType, thermo, turb),
singleMixturePtr_(nullptr),
mixture_(dynamic_cast<const reactingMixture<ThermoType>&>(this->thermo())),
reactions_(mixture_),
stoicRatio_(dimensionedScalar("stoicRatio", dimless, 0)),
s_(dimensionedScalar("s", dimless, 0)),
qFuel_(dimensionedScalar("qFuel", sqr(dimVelocity), 0)),
specieStoichCoeffs_(mixture_.species().size(), 0.0),
Yprod0_(mixture_.species().size(), 0.0),
fres_(Yprod0_.size()),
inertIndex_(mixture_.species()[thermo.lookup("inertSpecie")]),
fuelIndex_(mixture_.species()[thermo.lookup("fuel")]),
specieProd_(Yprod0_.size(), 1),
wFuel_
(
IOobject
@ -59,30 +173,49 @@ singleStepCombustion<ReactionThermo, ThermoType>::singleStepCombustion
),
semiImplicit_(readBool(this->coeffs_.lookup("semiImplicit")))
{
if (isA<singleStepReactingMixture<ThermoType>>(this->thermo()))
if (reactions_.size() == 1)
{
singleMixturePtr_ =
&dynamic_cast<singleStepReactingMixture<ThermoType>&>
forAll(fres_, fresI)
{
IOobject header
(
this->thermo()
"fres_" + mixture_.species()[fresI],
this->mesh().time().timeName(),
this->mesh()
);
fres_.set
(
fresI,
new volScalarField
(
header,
this->mesh(),
dimensionedScalar("fres" + name(fresI), dimless, 0)
)
);
}
calculateqFuel();
massAndAirStoichRatios();
calculateMaxProducts();
if (semiImplicit_)
{
Info<< "Combustion mode: semi-implicit" << endl;
}
else
{
Info<< "Combustion mode: explicit" << endl;
}
}
else
{
FatalErrorInFunction
<< "Inconsistent thermo package for " << this->type() << " model:\n"
<< " " << this->thermo().type() << nl << nl
<< "Please select a thermo package based on "
<< "singleStepReactingMixture" << exit(FatalError);
}
if (semiImplicit_)
{
Info<< "Combustion mode: semi-implicit" << endl;
}
else
{
Info<< "Combustion mode: explicit" << endl;
<< "Only one reaction required for single step reaction"
<< exit(FatalError);
}
}
@ -102,18 +235,17 @@ tmp<fvScalarMatrix> singleStepCombustion<ReactionThermo, ThermoType>::R
volScalarField& Y
) const
{
const label specieI =
this->thermo().composition().species()[Y.member()];
const label specieI = mixture_.species()[Y.member()];
volScalarField wSpecie
(
wFuel_*singleMixturePtr_->specieStoichCoeffs()[specieI]
wFuel_*specieStoichCoeffs()[specieI]
);
if (semiImplicit_)
{
const label fNorm = singleMixturePtr_->specieProd()[specieI];
const volScalarField fres(singleMixturePtr_->fres(specieI));
const label fNorm = specieProd()[specieI];
const volScalarField fres(this->fres(specieI));
wSpecie /= max(fNorm*(Y - fres), scalar(1e-2));
return -fNorm*wSpecie*fres + fNorm*fvm::Sp(wSpecie, Y);
@ -129,11 +261,11 @@ template<class ReactionThermo, class ThermoType>
tmp<volScalarField>
singleStepCombustion<ReactionThermo, ThermoType>::Qdot() const
{
const label fuelI = singleMixturePtr_->fuelIndex();
const label fuelI = fuelIndex();
volScalarField& YFuel =
const_cast<volScalarField&>(this->thermo().composition().Y(fuelI));
return -singleMixturePtr_->qFuel()*(R(YFuel) & YFuel);
return -qFuel()*(R(YFuel) & YFuel);
}
@ -151,6 +283,61 @@ bool singleStepCombustion<ReactionThermo, ThermoType>::read()
}
template<class ReactionThermo, class ThermoType>
void singleStepCombustion<ReactionThermo, ThermoType>::fresCorrect()
{
const Reaction<ThermoType>& reaction = reactions_[0];
const label O2Index = mixture_.species()["O2"];
const volScalarField& YFuel = mixture_.Y()[fuelIndex_];
const volScalarField& YO2 = mixture_.Y()[O2Index];
// reactants
forAll(reaction.lhs(), i)
{
const label speciei = reaction.lhs()[i].index;
if (speciei == fuelIndex_)
{
fres_[speciei] = max(YFuel - YO2/s_, scalar(0));
}
else if (speciei == O2Index)
{
fres_[speciei] = max(YO2 - YFuel*s_, scalar(0));
}
}
// products
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
if (speciei != inertIndex_)
{
forAll(fres_[speciei], celli)
{
if (fres_[fuelIndex_][celli] > 0.0)
{
// rich mixture
fres_[speciei][celli] =
Yprod0_[speciei]
* (1.0 + YO2[celli]/s_.value() - YFuel[celli]);
}
else
{
// lean mixture
fres_[speciei][celli] =
Yprod0_[speciei]
* (
1.0
- YO2[celli]/s_.value()*stoicRatio_.value()
+ YFuel[celli]*stoicRatio_.value()
);
}
}
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace combustionModels

View File

@ -25,7 +25,7 @@ Class
Foam::combustionModels::singleStepCombustion
Description
Base class for combustion models using singleStepReactingMixture.
Base class for combustion models using reactingMixture.
SourceFiles
singleStepCombustion.C
@ -35,7 +35,7 @@ SourceFiles
#ifndef singleStepCombustion_H
#define singleStepCombustion_H
#include "singleStepReactingMixture.H"
#include "reactingMixture.H"
#include "ThermoCombustion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,8 +58,37 @@ protected:
// Protected data
//- Pointer to singleStepReactingMixture mixture
singleStepReactingMixture<ThermoType>* singleMixturePtr_;
const reactingMixture<ThermoType>& mixture_;
//- Reactions
const PtrList<Reaction<ThermoType>>& reactions_;
//- Stoichiometric air-fuel mass ratio
dimensionedScalar stoicRatio_;
//- Stoichiometric oxygen-fuel mass ratio
dimensionedScalar s_;
//- Heat of combustion [J/Kg]
dimensionedScalar qFuel_;
//- Stoichiometric coefficient for the reaction.
scalarList specieStoichCoeffs_;
//- Mass concentrations at stoichiometric mixture for fres.
scalarList Yprod0_;
//- List of components residual
PtrList<volScalarField> fres_;
//- Inert specie index
label inertIndex_;
//- Fuel specie index
label fuelIndex_;
//- List to indicate if specie is produced/consumed
List<int> specieProd_;
//- Fuel consumption rate
volScalarField wFuel_;
@ -68,6 +97,18 @@ protected:
bool semiImplicit_;
// Protected member functions
//- Calculate qFuel
void calculateqFuel();
//- Calculate air/fuel and oxygen/fuel ratio
void massAndAirStoichRatios();
//- Calculate maximum products at stoichiometric mixture
void calculateMaxProducts();
public:
// Constructors
@ -91,6 +132,36 @@ public:
// Member Functions
// Access functions
//- Return the stoichiometric air-fuel mass ratio
inline const dimensionedScalar stoicRatio() const;
//- Return the Stoichiometric oxygen-fuel mass ratio
inline const dimensionedScalar s() const;
//- Return the heat of combustion [J/Kg]
inline const dimensionedScalar qFuel() const;
//- Return the stoichiometric coefficient for the reaction
inline const List<scalar>& specieStoichCoeffs() const;
//- Return the list of components residual
inline tmp<volScalarField> fres(const label index) const;
//- Return the inert specie index
inline label inertIndex() const;
//- Return the fuel specie index
inline label fuelIndex() const;
//- Return the list to indicate if specie is produced/consumed
inline const List<int>& specieProd() const;
//- Return the list of products mass concentrations
inline const scalarList& Yprod0() const;
//- Fuel consumption rate matrix
virtual tmp<fvScalarMatrix> R(volScalarField& Y) const;
@ -100,6 +171,9 @@ public:
//- Update properties from given dictionary
virtual bool read();
//- Calculates the residual for all components
void fresCorrect();
// Member Operators
@ -115,6 +189,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "singleStepCombustionI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "singleStepCombustion.C"
#endif

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "singleStepCombustion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace combustionModels
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class ReactionThermo, class ThermoType>
inline const dimensionedScalar
singleStepCombustion<ReactionThermo, ThermoType>::stoicRatio() const
{
return stoicRatio_;
}
template<class ReactionThermo, class ThermoType>
inline const dimensionedScalar
singleStepCombustion<ReactionThermo, ThermoType>::s() const
{
return s_;
}
template<class ReactionThermo, class ThermoType>
inline const dimensionedScalar
singleStepCombustion<ReactionThermo, ThermoType>::qFuel() const
{
return qFuel_;
}
template<class ReactionThermo, class ThermoType>
inline const List<scalar>&
singleStepCombustion<ReactionThermo, ThermoType>::specieStoichCoeffs() const
{
return specieStoichCoeffs_;
}
template<class ReactionThermo, class ThermoType>
inline tmp<volScalarField>
singleStepCombustion<ReactionThermo, ThermoType>::fres
(
const label index
) const
{
return fres_[index];
}
template<class ReactionThermo, class ThermoType>
inline label
singleStepCombustion<ReactionThermo, ThermoType>::inertIndex() const
{
return inertIndex_;
}
template<class ReactionThermo, class ThermoType>
inline label
singleStepCombustion<ReactionThermo, ThermoType>::fuelIndex() const
{
return fuelIndex_;
}
template<class ReactionThermo, class ThermoType>
inline const List<int>&
singleStepCombustion<ReactionThermo, ThermoType>::specieProd() const
{
return specieProd_;
}
template<class ReactionThermo, class ThermoType>
inline const scalarList&
singleStepCombustion<ReactionThermo, ThermoType>::Yprod0() const
{
return Yprod0_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace combustionModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -24,21 +24,20 @@ License
\*---------------------------------------------------------------------------*/
#include "mixtureFraction.H"
#include "singleStepReactingMixture.H"
#include "reactingMixture.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class ThermoType>
const Foam::singleStepReactingMixture<ThermoType>&
const Foam::reactingMixture<ThermoType>&
Foam::radiationModels::sootModels::mixtureFraction<ThermoType>::checkThermo
(
const fluidThermo& thermo
)
{
if (isA<singleStepReactingMixture<ThermoType>>(thermo))
if (isA<reactingMixture<ThermoType>>(thermo))
{
return dynamic_cast<const singleStepReactingMixture<ThermoType>& >
return dynamic_cast<const reactingMixture<ThermoType>& >
(
thermo
);
@ -48,9 +47,9 @@ Foam::radiationModels::sootModels::mixtureFraction<ThermoType>::checkThermo
FatalErrorInFunction
<< "Inconsistent thermo package for " << thermo.type()
<< "Please select a thermo package based on "
<< "singleStepReactingMixture" << exit(FatalError);
<< "reactingMixture" << exit(FatalError);
return dynamic_cast<const singleStepReactingMixture<ThermoType>& >
return dynamic_cast<const reactingMixture<ThermoType>& >
(
thermo
);
@ -94,29 +93,36 @@ Foam::radiationModels::sootModels::mixtureFraction<ThermoType>::mixtureFraction
thermo_(mesh.lookupObject<fluidThermo>(basicThermo::dictName)),
mixture_(checkThermo(thermo_))
{
const Reaction<ThermoType>& reaction = mixture_.operator[](0);
const Reaction<ThermoType>& reaction = mixture_[0];
const scalarList& specieStoichCoeffs(mixture_.specieStoichCoeffs());
scalar totalMol = 0.0;
scalar totalMol = 0;
forAll(reaction.rhs(), i)
{
label speciei = reaction.rhs()[i].index;
totalMol += mag(specieStoichCoeffs[speciei]);
const scalar stoichCoeff = reaction.rhs()[i].stoichCoeff;
totalMol += mag(stoichCoeff);
}
totalMol += nuSoot_;
scalarList Xi(reaction.rhs().size());
scalar Wm = 0.0;
scalar Wm = 0;
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
Xi[i] = mag(specieStoichCoeffs[speciei])/totalMol;
const scalar stoichCoeff = reaction.rhs()[i].stoichCoeff;
Xi[i] = mag(stoichCoeff)/totalMol;
Wm += Xi[i]*mixture_.speciesData()[speciei].W();
}
scalarList Yprod0(mixture_.species().size(), 0.0);
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
Yprod0[speciei] = mixture_.speciesData()[speciei].W()/Wm*Xi[i];
}
const scalar XSoot = nuSoot_/totalMol;
Wm += XSoot*Wsoot_;
@ -132,8 +138,7 @@ Foam::radiationModels::sootModels::mixtureFraction<ThermoType>::mixtureFraction
const label mapFieldIndex = mixture_.species()[mappingFieldName_];
mapFieldMax_ = mixture_.Yprod0()[mapFieldIndex];
mapFieldMax_ = Yprod0[mapFieldIndex];
}

View File

@ -63,7 +63,7 @@ SourceFiles
#include "HashTable.H"
#include "fluidThermo.H"
#include "singleStepReactingMixture.H"
#include "reactingMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -86,7 +86,7 @@ class mixtureFraction
// Static functions
//- Check mixture in thermo
static const singleStepReactingMixture<ThermoType>& checkThermo
static const reactingMixture<ThermoType>& checkThermo
(
const fluidThermo&
);
@ -118,8 +118,8 @@ class mixtureFraction
//- Thermo package
const fluidThermo& thermo_;
//- Auto Ptr to singleStepReactingMixture
const singleStepReactingMixture<ThermoType>& mixture_;
//- Auto Ptr to reactingMixture
const reactingMixture<ThermoType>& mixture_;
public:

View File

@ -1,261 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "singleStepReactingMixture.H"
#include "fvMesh.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class ThermoType>
void Foam::singleStepReactingMixture<ThermoType>::calculateqFuel()
{
const Reaction<ThermoType>& reaction = this->operator[](0);
const scalar Wu = this->speciesData()[fuelIndex_].W();
forAll(reaction.lhs(), i)
{
const label speciei = reaction.lhs()[i].index;
const scalar stoichCoeff = reaction.lhs()[i].stoichCoeff;
specieStoichCoeffs_[speciei] = -stoichCoeff;
qFuel_.value() += this->speciesData()[speciei].hc()*stoichCoeff/Wu;
}
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
const scalar stoichCoeff = reaction.rhs()[i].stoichCoeff;
specieStoichCoeffs_[speciei] = stoichCoeff;
qFuel_.value() -= this->speciesData()[speciei].hc()*stoichCoeff/Wu;
specieProd_[speciei] = -1;
}
Info << "Fuel heat of combustion :" << qFuel_.value() << endl;
}
template<class ThermoType>
void Foam::singleStepReactingMixture<ThermoType>::massAndAirStoichRatios()
{
const label O2Index = this->species()["O2"];
const scalar Wu = this->speciesData()[fuelIndex_].W();
stoicRatio_ =
(this->speciesData()[inertIndex_].W()
* specieStoichCoeffs_[inertIndex_]
+ this->speciesData()[O2Index].W()
* mag(specieStoichCoeffs_[O2Index]))
/ (Wu*mag(specieStoichCoeffs_[fuelIndex_]));
s_ =
(this->speciesData()[O2Index].W()
* mag(specieStoichCoeffs_[O2Index]))
/ (Wu*mag(specieStoichCoeffs_[fuelIndex_]));
Info << "stoichiometric air-fuel ratio :" << stoicRatio_.value() << endl;
Info << "stoichiometric oxygen-fuel ratio :" << s_.value() << endl;
}
template<class ThermoType>
void Foam::singleStepReactingMixture<ThermoType>::calculateMaxProducts()
{
const Reaction<ThermoType>& reaction = this->operator[](0);
scalar Wm = 0.0;
scalar totalMol = 0.0;
forAll(reaction.rhs(), i)
{
label speciei = reaction.rhs()[i].index;
totalMol += mag(specieStoichCoeffs_[speciei]);
}
scalarList Xi(reaction.rhs().size());
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
Xi[i] = mag(specieStoichCoeffs_[speciei])/totalMol;
Wm += Xi[i]*this->speciesData()[speciei].W();
}
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
Yprod0_[speciei] = this->speciesData()[speciei].W()/Wm*Xi[i];
}
Info << "Maximum products mass concentrations:" << nl;
forAll(Yprod0_, i)
{
if (Yprod0_[i] > 0)
{
Info<< " " << this->species()[i] << ": " << Yprod0_[i] << nl;
}
}
// Normalize the stoichiometric coeff to mass
forAll(specieStoichCoeffs_, i)
{
specieStoichCoeffs_[i] =
specieStoichCoeffs_[i]
* this->speciesData()[i].W()
/ (this->speciesData()[fuelIndex_].W()
* mag(specieStoichCoeffs_[fuelIndex_]));
}
}
template<class ThermoType>
void Foam::singleStepReactingMixture<ThermoType>::fresCorrect()
{
const Reaction<ThermoType>& reaction = this->operator[](0);
label O2Index = this->species()["O2"];
const volScalarField& YFuel = this->Y()[fuelIndex_];
const volScalarField& YO2 = this->Y()[O2Index];
// reactants
forAll(reaction.lhs(), i)
{
const label speciei = reaction.lhs()[i].index;
if (speciei == fuelIndex_)
{
fres_[speciei] = max(YFuel - YO2/s_, scalar(0));
}
else if (speciei == O2Index)
{
fres_[speciei] = max(YO2 - YFuel*s_, scalar(0));
}
}
// products
forAll(reaction.rhs(), i)
{
const label speciei = reaction.rhs()[i].index;
if (speciei != inertIndex_)
{
forAll(fres_[speciei], celli)
{
if (fres_[fuelIndex_][celli] > 0.0)
{
// rich mixture
fres_[speciei][celli] =
Yprod0_[speciei]
* (1.0 + YO2[celli]/s_.value() - YFuel[celli]);
}
else
{
// lean mixture
fres_[speciei][celli] =
Yprod0_[speciei]
* (
1.0
- YO2[celli]/s_.value()*stoicRatio_.value()
+ YFuel[celli]*stoicRatio_.value()
);
}
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ThermoType>
Foam::singleStepReactingMixture<ThermoType>::singleStepReactingMixture
(
const dictionary& thermoDict,
const fvMesh& mesh,
const word& phaseName
)
:
reactingMixture<ThermoType>(thermoDict, mesh, phaseName),
stoicRatio_(dimensionedScalar("stoicRatio", dimless, 0)),
s_(dimensionedScalar("s", dimless, 0)),
qFuel_(dimensionedScalar("qFuel", sqr(dimVelocity), 0)),
specieStoichCoeffs_(this->species_.size(), 0.0),
Yprod0_(this->species_.size(), 0.0),
fres_(Yprod0_.size()),
inertIndex_(this->species()[thermoDict.lookup("inertSpecie")]),
fuelIndex_(this->species()[thermoDict.lookup("fuel")]),
specieProd_(Yprod0_.size(), 1)
{
if (this->size() == 1)
{
forAll(fres_, fresI)
{
IOobject header
(
"fres_" + this->species()[fresI],
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
);
fres_.set
(
fresI,
new volScalarField
(
header,
mesh,
dimensionedScalar("fres" + name(fresI), dimless, 0)
)
);
}
calculateqFuel();
massAndAirStoichRatios();
calculateMaxProducts();
autoPtr<chemistryReader<ThermoType>>::clear();
}
else
{
FatalErrorInFunction
<< "Only one reaction required for single step reaction"
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ThermoType>
void Foam::singleStepReactingMixture<ThermoType>::read
(
const dictionary& thermoDict
)
{}
// ************************************************************************* //

View File

@ -1,198 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
Class
Foam::singleStepReactingMixture
Description
Single step reacting mixture
SourceFiles
singleStepReactingMixture.C
\*---------------------------------------------------------------------------*/
#ifndef singleStepReactingMixture_H
#define singleStepReactingMixture_H
#include "chemistryReader.H"
#include "reactingMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class singleStepReactingMixture Declaration
\*---------------------------------------------------------------------------*/
template<class ThermoType>
class singleStepReactingMixture
:
public reactingMixture<ThermoType>
{
protected:
// Protected data
//- Stoichiometric air-fuel mass ratio
dimensionedScalar stoicRatio_;
//- Stoichiometric oxygen-fuel mass ratio
dimensionedScalar s_;
//- Heat of combustion [J/Kg]
dimensionedScalar qFuel_;
//- Stoichiometric coefficient for the reaction.
scalarList specieStoichCoeffs_;
//- Mass concentrations at stoichiometric mixture for fres.
scalarList Yprod0_;
//- List of components residual
PtrList<volScalarField> fres_;
//- Inert specie index
label inertIndex_;
//- Fuel specie index
label fuelIndex_;
//- List to indicate if specie is produced/consumed
List<int> specieProd_;
// Protected member functions
//- Calculate qFuel
void calculateqFuel();
//- Calculate air/fuel and oxygen/fuel ratio
void massAndAirStoichRatios();
//- Calculate maximum products at stoichiometric mixture
void calculateMaxProducts();
public:
//- The type of thermo package this mixture is instantiated for
typedef ThermoType thermoType;
// Constructors
//- Construct from dictionary, mesh and phase name
singleStepReactingMixture
(
const dictionary&,
const fvMesh&,
const word&
);
//- Disallow default bitwise copy construction
singleStepReactingMixture(const singleStepReactingMixture&) = delete;
//- Destructor
virtual ~singleStepReactingMixture()
{}
// Member Functions
//- Return the instantiated type name
static word typeName()
{
return "singleStepReactingMixture<" + ThermoType::typeName() + '>';
}
//- Calculates the residual for all components
void fresCorrect();
// Access functions
//- Return the stoichiometric air-fuel mass ratio
inline const dimensionedScalar stoicRatio() const;
//- Return the Stoichiometric oxygen-fuel mass ratio
inline const dimensionedScalar s() const;
//- Return the heat of combustion [J/Kg]
inline const dimensionedScalar qFuel() const;
//- Return the stoichiometric coefficient for the reaction
inline const List<scalar>& specieStoichCoeffs() const;
//- Return the list of components residual
inline tmp<volScalarField> fres(const label index) const;
//- Return the inert specie index
inline label inertIndex() const;
//- Return the fuel specie index
inline label fuelIndex() const;
//- Return the list to indicate if specie is produced/consumed
inline const List<int>& specieProd() const;
//- Return the list of products mass concentrations
inline const scalarList& Yprod0() const;
// I-O
//- Read dictionary
void read(const dictionary&);
// Member Operators
//- Disallow default bitwise assignment
void operator=(const singleStepReactingMixture&) = delete;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "singleStepReactingMixtureI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "singleStepReactingMixture.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,105 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "singleStepReactingMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class ThermoType>
inline const Foam::dimensionedScalar
Foam::singleStepReactingMixture<ThermoType>::stoicRatio() const
{
return stoicRatio_;
}
template<class ThermoType>
inline const Foam::dimensionedScalar
Foam::singleStepReactingMixture<ThermoType>::s() const
{
return s_;
}
template<class ThermoType>
inline const Foam::dimensionedScalar
Foam::singleStepReactingMixture<ThermoType>::qFuel() const
{
return qFuel_;
}
template<class ThermoType>
inline const Foam::List<Foam::scalar>&
Foam::singleStepReactingMixture<ThermoType>::specieStoichCoeffs() const
{
return specieStoichCoeffs_;
}
template<class ThermoType>
inline Foam::tmp<Foam::volScalarField>
Foam::singleStepReactingMixture<ThermoType>::fres
(
const label index
) const
{
return fres_[index];
}
template<class ThermoType>
inline Foam::label
Foam::singleStepReactingMixture<ThermoType>::inertIndex() const
{
return inertIndex_;
}
template<class ThermoType>
inline Foam::label
Foam::singleStepReactingMixture<ThermoType>::fuelIndex() const
{
return fuelIndex_;
}
template<class ThermoType>
inline const Foam::List<int>&
Foam::singleStepReactingMixture<ThermoType>::specieProd() const
{
return specieProd_;
}
template<class ThermoType>
inline const Foam::scalarList&
Foam::singleStepReactingMixture<ThermoType>::Yprod0() const
{
return Yprod0_;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,7 +42,6 @@ License
#include "veryInhomogeneousMixture.H"
#include "multiComponentMixture.H"
#include "reactingMixture.H"
#include "singleStepReactingMixture.H"
#include "singleComponentMixture.H"
#include "thermoPhysicsTypes.H"
@ -244,18 +243,6 @@ makeThermoPhysicsReactionThermos
);
// Single-step reaction thermo for sensible enthalpy
makeThermoPhysicsReactionThermos
(
psiThermo,
psiReactionThermo,
hePsiThermo,
singleStepReactingMixture,
gasHThermoPhysics
);
// Reaction thermo for internal energy
makeThermoPhysicsReactionThermos
@ -277,18 +264,6 @@ makeThermoPhysicsReactionThermos
);
// Single-step reaction thermo for internal energy
makeThermoPhysicsReactionThermos
(
psiThermo,
psiReactionThermo,
hePsiThermo,
singleStepReactingMixture,
gasEThermoPhysics
);
// Single-component thermo for sensible enthalpy
makeThermoPhysicsReactionThermo

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,7 +49,6 @@ License
#include "veryInhomogeneousMixture.H"
#include "multiComponentMixture.H"
#include "reactingMixture.H"
#include "singleStepReactingMixture.H"
#include "singleComponentMixture.H"
#include "thermoPhysicsTypes.H"
@ -370,18 +369,6 @@ makeThermoPhysicsReactionThermos
);
// Single-step reaction thermo for internal energy
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
singleStepReactingMixture,
gasEThermoPhysics
);
// Single-component thermo for internal energy
makeThermoPhysicsReactionThermo
@ -636,18 +623,6 @@ makeThermoPhysicsReactionThermos
);
// Single-step reaction thermo for sensible enthalpy
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
singleStepReactingMixture,
gasHThermoPhysics
);
// Single-component thermo for sensible enthalpy
makeThermoPhysicsReactionThermo

View File

@ -18,7 +18,7 @@ FoamFile
thermoType
{
type hePsiThermo;
mixture singleStepReactingMixture;
mixture reactingMixture;
transport sutherland;
thermo janaf;
energy sensibleEnthalpy;

View File

@ -18,7 +18,7 @@ FoamFile
thermoType
{
type hePsiThermo;
mixture singleStepReactingMixture;
mixture reactingMixture;
transport sutherland;
thermo janaf;
energy sensibleEnthalpy;

View File

@ -18,7 +18,7 @@ FoamFile
thermoType
{
type hePsiThermo;
mixture singleStepReactingMixture;
mixture reactingMixture;
transport sutherland;
thermo janaf;
energy sensibleEnthalpy;

View File

@ -18,7 +18,7 @@ FoamFile
thermoType
{
type hePsiThermo;
mixture singleStepReactingMixture;
mixture reactingMixture;
transport sutherland;
thermo janaf;
energy sensibleEnthalpy;