Commit d185f8b9 authored by Sergio Ferraris's avatar Sergio Ferraris
Browse files

ENH: Adding useChemistrySolver in reactingOneDim solid region to avoid using...

ENH: Adding useChemistrySolver in reactingOneDim solid region to avoid using chemistry solvers in reacting solids
     Adding non const access function to chemistryModel.H for combustion models that calculates RR externally
     Removing EulerImplicit from options in solidReactions.
BUG: Correcting function used by sequential solver in pyrolysisChemistryModel.C
parent 94c4d37f
......@@ -61,6 +61,9 @@ void reactingOneDim::readReactingOneDimControls()
coeffs().lookup("gasHSource") >> gasHSource_;
coeffs().lookup("QrHSource") >> QrHSource_;
useChemistrySolvers_ =
coeffs().lookupOrDefault<bool>("useChemistrySolvers", true);
}
......@@ -462,7 +465,8 @@ reactingOneDim::reactingOneDim(const word& modelType, const fvMesh& mesh)
totalGasMassFlux_(0.0),
totalHeatRR_(dimensionedScalar("zero", dimEnergy/dimTime, 0.0)),
gasHSource_(false),
QrHSource_(false)
QrHSource_(false),
useChemistrySolvers_(true)
{
if (active_)
{
......@@ -560,7 +564,8 @@ reactingOneDim::reactingOneDim
totalGasMassFlux_(0.0),
totalHeatRR_(dimensionedScalar("zero", dimEnergy/dimTime, 0.0)),
gasHSource_(false),
QrHSource_(false)
QrHSource_(false),
useChemistrySolvers_(true)
{
if (active_)
{
......@@ -681,11 +686,18 @@ void reactingOneDim::evolveRegion()
{
Info<< "\nEvolving pyrolysis in region: " << regionMesh().name() << endl;
solidChemistry_->solve
(
time().value() - time().deltaTValue(),
time().deltaTValue()
);
if (useChemistrySolvers_)
{
solidChemistry_->solve
(
time().value() - time().deltaTValue(),
time().deltaTValue()
);
}
else
{
solidChemistry_->calculate();
}
solveContinuity();
......
......@@ -154,6 +154,9 @@ protected:
//- Add in depth radiation source term
bool QrHSource_;
//- Use chemistry solvers (ode or sequential)
bool useChemistrySolvers_;
// Protected member functions
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -140,6 +140,12 @@ public:
const label i
) const = 0;
//- Return access to chemical source terms [kg/m3/s]
virtual DimensionedField<scalar, volMesh>& RR
(
const label i
) = 0;
// Chemistry solution
......
......@@ -211,6 +211,12 @@ public:
const label i
) const;
//- Return non const access to chemical source terms [kg/m3/s]
virtual DimensionedField<scalar, volMesh>& RR
(
const label i
);
//- Solve the reaction system for the given start time and time
// step and return the characteristic time
virtual scalar solve(const scalar t0, const scalar deltaT);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -78,5 +78,15 @@ Foam::chemistryModel<CompType, ThermoType>::RR
return RR_[i];
}
template<class CompType, class ThermoType>
Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::chemistryModel<CompType, ThermoType>::RR
(
const label i
)
{
return RR_[i];
}
// ************************************************************************* //
......@@ -53,4 +53,35 @@ Foam::basicSolidChemistryModel::~basicSolidChemistryModel()
{}
const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::basicSolidChemistryModel::RR(const label i) const
{
notImplemented
(
"const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&"
"basicSolidChemistryModel::RR(const label)"
);
return (DimensionedField<scalar, volMesh>::null());
}
Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::basicSolidChemistryModel::RR(const label i)
{
notImplemented
(
"Foam::DimensionedField<Foam::scalar, Foam::volMesh>&"
"basicSolidChemistryModel::RR(const label)"
);
return dynamic_cast<DimensionedField<scalar, volMesh>&>
(
const_cast<DimensionedField<scalar, volMesh>& >
(
DimensionedField<scalar, volMesh>::null()
)
);
}
// ************************************************************************* //
......@@ -149,6 +149,15 @@ public:
//- Calculates the reaction rates
virtual void calculate() = 0;
//- Return const access to the total source terms
virtual const DimensionedField<scalar, volMesh>& RR
(
const label i
) const;
//- Return non-const access to the total source terms
virtual DimensionedField<scalar, volMesh>& RR(const label i);
};
......
......@@ -535,14 +535,21 @@ updateConcsInReactionI
c[si] = max(0.0, c[si]);
}
scalar sr = 0.0;
forAll(R.rhs(), s)
{
label si = R.rhs()[s].index;
const scalar rhoR = this->solidThermo_[si].rho(p, T);
const scalar sr = rhoR/rhoL;
sr = rhoR/rhoL;
c[si] += dt*sr*omeg;
c[si] = max(0.0, c[si]);
}
forAll(R.grhs(), g)
{
label gi = R.grhs()[g].index;
c[gi + this->nSolids_] += (1.0 - sr)*omeg*dt;
}
}
......@@ -561,24 +568,11 @@ updateRRInReactionI
simpleMatrix<scalar>& RR
) const
{
const Reaction<SolidThermo>& R = this->reactions_[index];
scalar rhoL = 0.0;
forAll(R.lhs(), s)
{
label si = R.lhs()[s].index;
rhoL = this->solidThermo_[si].rho(p, T);
RR[si][rRef] -= pr*corr;
RR[si][lRef] += pf*corr;
}
forAll(R.rhs(), s)
{
label si = R.rhs()[s].index;
const scalar rhoR = this->solidThermo_[si].rho(p, T);
const scalar sr = rhoR/rhoL;
RR[si][lRef] -= sr*pf*corr;
RR[si][rRef] += sr*pr*corr;
}
notImplemented
(
"void Foam::pyrolysisChemistryModel<CompType, SolidThermo,GasThermo>::"
"updateRRInReactionI"
);
}
......@@ -666,7 +660,6 @@ Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::solve
scalar newCp = 0.0;
scalar newhi = 0.0;
scalar invRho = 0.0;
scalarList dcdt = (c - c0)/dt;
for (label i=0; i<this->nSolids_; i++)
......@@ -675,7 +668,6 @@ Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::solve
scalar Yi = c[i]/cTot;
newCp += Yi*this->solidThermo_[i].Cp(pi, Ti);
newhi -= dYi*this->solidThermo_[i].Hc();
invRho += Yi/this->solidThermo_[i].rho(pi, Ti);
}
scalar dTi = (newhi/newCp)*dt;
......
......@@ -137,8 +137,9 @@ public:
const bool updateC0 = false
) const;
//- Return the reaction rate for reaction r and the reference
// species and charateristic times
//- Return the reaction rate for reaction r
// NOTE: Currently does not calculate reference specie and
// characteristic times (pf, cf,l Ref, etc.)
virtual scalar omega
(
const Reaction<SolidThermo>& r,
......@@ -153,8 +154,10 @@ public:
label& rRef
) const;
//- Return the reaction rate for iReaction and the reference
// species and charateristic times
//- Return the reaction rate for iReaction
// NOTE: Currently does not calculate reference specie and
// characteristic times (pf, cf,l Ref, etc.)
virtual scalar omegaI
(
label iReaction,
......@@ -169,6 +172,7 @@ public:
label& rRef
) const;
//- Calculates the reaction rates
virtual void calculate();
......@@ -186,6 +190,7 @@ public:
//- Update matrix RR for reaction i. Used by EulerImplicit
// (Not implemented)
virtual void updateRRInReactionI
(
const label i,
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -65,6 +65,9 @@ class solidChemistryModel
{
// Private Member Functions
//- Disallow copy constructor
solidChemistryModel(const solidChemistryModel&);
//- Disallow default bitwise assignment
void operator=(const solidChemistryModel&);
......@@ -151,6 +154,7 @@ public:
label& rRef
) const = 0;
//- Return the reaction rate for iReaction and the reference
// species and charateristic times
virtual scalar omegaI
......@@ -167,6 +171,10 @@ public:
label& rRef
) const = 0;
//- Calculates the reaction rates
virtual void calculate() = 0;
//- Update concentrations in reaction i given dt and reaction rate
// omega used by sequential solver
virtual void updateConcsInReactionI
......@@ -194,11 +202,8 @@ public:
simpleMatrix<scalar>& RR
) const = 0;
//- Calculates the reaction rates
virtual void calculate() = 0;
// Chemistry model functions
// Solid Chemistry model functions
//- Return const access to the chemical source terms for solids
inline const DimensionedField<scalar, volMesh>& RRs
......@@ -209,13 +214,6 @@ public:
//- Return total solid source term
inline tmp<DimensionedField<scalar, volMesh> > RRs() const;
//- Return const access to the total source terms
inline const DimensionedField<scalar, volMesh>& RR
(
const label i
) const;
//- Solve the reaction system for the given start time and time
// step and return the characteristic time
virtual scalar solve(const scalar t0, const scalar deltaT) = 0;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -95,16 +95,4 @@ Foam::solidChemistryModel<CompType, SolidThermo>::RRs() const
}
template<class CompType, class SolidThermo>
inline const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::solidChemistryModel<CompType, SolidThermo>::RR
(
const label i
) const
{
notImplemented("solidChemistryModel::RR(const label)");
return (DimensionedField<scalar, volMesh>::null());
}
// ************************************************************************* //
......@@ -52,9 +52,8 @@ namespace Foam
defineTemplateTypeNameAndDebugWithName \
( \
SS##Schem##Comp##SThermo##GThermo, \
(#SS"<" + word(Schem::typeName_()) \
+ "<"#Comp"," + SThermo::typeName() \
+ "," + GThermo::typeName() + ">>").c_str(), \
(#SS"<"#Schem"<"#Comp"," + SThermo::typeName() + "," \
+ GThermo::typeName() + ">>").c_str(), \
0 \
); \
\
......@@ -77,14 +76,6 @@ namespace Foam
GThermo \
); \
\
makeSolidChemistrySolverType \
( \
EulerImplicit, \
SolidChem, \
Comp, \
SThermo, \
GThermo \
); \
\
makeSolidChemistrySolverType \
( \
......@@ -104,7 +95,6 @@ namespace Foam
GThermo \
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
......@@ -30,7 +30,7 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef makeSolidThermo_H
#define makesolidThermo_H
#define makeSolidThermo_H
#include "addToRunTimeSelectionTable.H"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment