ENH: Changing name from ODESolidChemistryModel to solidChemistryModel,

adding a base class basicSolidChemistryModel and deriving
pyrolysisSolidChemistry  model for solid
This commit is contained in:
sergio
2013-02-21 15:05:11 +00:00
parent 63cc7b534a
commit a6948a1c12
21 changed files with 812 additions and 507 deletions

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,7 +49,7 @@ void noPyrolysis::constructThermoChemistry()
{
solidChemistry_.reset
(
solidChemistryModel::New(regionMesh()).ptr()
basicSolidChemistryModel::New(regionMesh()).ptr()
);
solidThermo_.reset(&solidChemistry_->solidThermo());

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,7 +37,7 @@ SourceFiles
#include "pyrolysisModel.H"
#include "volFieldsFwd.H"
#include "solidChemistryModel.H"
#include "basicSolidChemistryModel.H"
#include "radiationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -82,7 +82,7 @@ protected:
void constructThermoChemistry();
//- Reference to the solid chemistry model
autoPtr<solidChemistryModel> solidChemistry_;
autoPtr<basicSolidChemistryModel> solidChemistry_;
//- Reference to solid thermo
autoPtr<solidReactionThermo> solidThermo_;

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -303,7 +303,7 @@ void reactingOneDim::calculateMassTransfer()
reactingOneDim::reactingOneDim(const word& modelType, const fvMesh& mesh)
:
pyrolysisModel(modelType, mesh),
solidChemistry_(solidChemistryModel::New(regionMesh())),
solidChemistry_(basicSolidChemistryModel::New(regionMesh())),
solidThermo_(solidChemistry_->solidThermo()),
radiation_(radiation::radiationModel::New(solidThermo_.T())),
rho_
@ -386,7 +386,7 @@ reactingOneDim::reactingOneDim
)
:
pyrolysisModel(modelType, mesh, dict),
solidChemistry_(solidChemistryModel::New(regionMesh())),
solidChemistry_(basicSolidChemistryModel::New(regionMesh())),
solidThermo_(solidChemistry_->solidThermo()),
radiation_(radiation::radiationModel::New(solidThermo_.T())),
rho_

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,7 @@ SourceFiles
#define reactingOneDim_H
#include "pyrolysisModel.H"
#include "solidChemistryModel.H"
#include "basicSolidChemistryModel.H"
#include "radiationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -76,7 +76,7 @@ protected:
// Protected data
//- Reference to the solid chemistry model
autoPtr<solidChemistryModel> solidChemistry_;
autoPtr<basicSolidChemistryModel> solidChemistry_;
//- Reference to solid thermo
solidReactionThermo& solidThermo_;

View File

@ -1,7 +1,7 @@
solidChemistryModel/solidChemistryModel.C
solidChemistryModel/solidChemistryModelNew.C
solidChemistryModel/solidChemistryModels.C
basicSolidChemistryModel/basicSolidChemistryModel.C
basicSolidChemistryModel/basicSolidChemistryModelNew.C
basicSolidChemistryModel/basicSolidChemistryModels.C
solidChemistrySolver/makeSolidChemistrySolvers.C

View File

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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 "basicSolidChemistryModel.H"
#include "fvMesh.H"
#include "Time.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
namespace Foam
{
defineTypeNameAndDebug(basicSolidChemistryModel, 0);
defineRunTimeSelectionTable(basicSolidChemistryModel, fvMesh);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicSolidChemistryModel::basicSolidChemistryModel
(
const fvMesh& mesh
)
:
basicChemistryModel(mesh),
solidThermo_(solidReactionThermo::New(mesh))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::basicSolidChemistryModel::~basicSolidChemistryModel()
{}
// ************************************************************************* //

View File

@ -0,0 +1,167 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2013 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::basicSolidChemistryModel
Description
Chemistry model for solid thermodynamics
SourceFiles
basicSolidChemistryModelI.H
basicSolidChemistryModel.C
newChemistrySolidModel.C
\*---------------------------------------------------------------------------*/
#ifndef basicSolidChemistryModel_H
#define basicSolidChemistryModel_H
#include "basicChemistryModel.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "solidReactionThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class fvMesh;
/*---------------------------------------------------------------------------*\
class basicSolidChemistryModel Declaration
\*---------------------------------------------------------------------------*/
class basicSolidChemistryModel
:
public basicChemistryModel
{
// Private Member Functions
//- Construct as copy (not implemented)
basicSolidChemistryModel(const basicSolidChemistryModel&);
//- Disallow default bitwise assignment
void operator=(const basicSolidChemistryModel&);
protected:
// Protected data
//- Solid thermo package
autoPtr<solidReactionThermo> solidThermo_;
public:
//- Runtime type information
TypeName("basicSolidChemistryModel");
//- Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
basicSolidChemistryModel,
fvMesh,
(const fvMesh& mesh),
(mesh)
);
// Constructors
//- Construct from mesh
basicSolidChemistryModel(const fvMesh& mesh);
//- Selector
static autoPtr<basicSolidChemistryModel> New(const fvMesh& mesh);
//- Destructor
virtual ~basicSolidChemistryModel();
// Member Functions
//- Return access to the solid thermo package
inline solidReactionThermo& solidThermo();
//- Return const access to the solid thermo package
inline const solidReactionThermo& solidThermo() const;
//- Return total gases mass source term [kg/m3/s]
virtual tmp<DimensionedField<scalar, volMesh> > RRg() const = 0;
//- Return total solids mass source term [kg/m3/s]
virtual tmp<DimensionedField<scalar, volMesh> > RRs() const = 0;
//- Return chemical source terms for solids [kg/m3/s]
virtual const DimensionedField<scalar, volMesh>& RRs
(
const label i
) const = 0;
//- Return chemical source terms for gases [kg/m3/s]
virtual const DimensionedField<scalar, volMesh>& RRg
(
const label i
) const = 0;
//- Return sensible enthalpy for gas i [J/Kg]
virtual tmp<volScalarField> gasHs
(
const volScalarField& p,
const volScalarField& T,
const label i
) const = 0;
//- Return specie Table for gases
virtual const speciesTable& gasTable() const = 0;
//- Set reacting status of cell, cellI
virtual void setCellReacting(const label cellI, const bool active) = 0;
//- Calculates the reaction rates
virtual void calculate() = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "basicSolidChemistryModelI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,41 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2013 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 * * * * * * * * * * * * * //
inline Foam::solidReactionThermo& Foam::basicSolidChemistryModel::solidThermo()
{
return solidThermo_();
}
inline const Foam::solidReactionThermo&
Foam::basicSolidChemistryModel::solidThermo() const
{
return solidThermo_();
}
// ************************************************************************* //

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,11 +23,12 @@ License
\*---------------------------------------------------------------------------*/
#include "solidChemistryModel.H"
#include "basicSolidChemistryModel.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::solidChemistryModel> Foam::solidChemistryModel::New
Foam::autoPtr<Foam::basicSolidChemistryModel> Foam::basicSolidChemistryModel::
New
(
const fvMesh& mesh
)
@ -160,7 +161,7 @@ Foam::autoPtr<Foam::solidChemistryModel> Foam::solidChemistryModel::New
FatalError<< exit(FatalError);
}
return autoPtr<solidChemistryModel>(cstrIter()(mesh));
return autoPtr<basicSolidChemistryModel>(cstrIter()(mesh));
}

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
Foam::solidChemistryModel
Foam::basicSolidChemistryModel
Description
Creates solid chemistry model instances templated on the type of
@ -32,7 +32,8 @@ Description
#include "makeSolidChemistryModel.H"
#include "ODESolidChemistryModel.H"
#include "pyrolysisChemistryModel.H"
#include "basicSolidChemistryModel.H"
#include "solidChemistryModel.H"
#include "solidThermoPhysicsTypes.H"
#include "thermoPhysicsTypes.H"
@ -43,16 +44,18 @@ namespace Foam
{
makeSolidChemistryModel
(
ODESolidChemistryModel,
solidChemistryModel,
pyrolysisChemistryModel,
basicSolidChemistryModel,
hConstSolidThermoPhysics,
gasHThermoPhysics
);
makeSolidChemistryModel
(
ODESolidChemistryModel,
solidChemistryModel,
pyrolysisChemistryModel,
basicSolidChemistryModel,
hExponentialSolidThermoPhysics,
gasHThermoPhysics
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,6 +30,7 @@ Description
#define makeSolidChemistryModel_H
#include "addToRunTimeSelectionTable.H"
#include "solidChemistryModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -38,10 +39,19 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeSolidChemistryModel(SS, Comp, SThermo, GThermo) \
#define makeSolidChemistryModel(sChemistry, SS, Comp, SThermo, GThermo) \
\
typedef SS<Comp, SThermo, GThermo> SS##Comp##SThermo##GThermo; \
\
typedef sChemistry<Comp, SThermo> sChemistryl##Comp##SThermo; \
\
defineTemplateTypeNameAndDebugWithName \
( \
sChemistryl##Comp##SThermo, \
(#sChemistry"<"#Comp"," + SThermo::typeName() + ">").c_str(), \
0 \
); \
\
defineTemplateTypeNameAndDebugWithName \
( \
SS##Comp##SThermo##GThermo, \

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,73 +23,33 @@ License
\*---------------------------------------------------------------------------*/
#include "ODESolidChemistryModel.H"
#include "reactingMixture.H"
#include "pyrolysisChemistryModel.H"
#include "solidReaction.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CompType, class SolidThermo, class GasThermo>
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
ODESolidChemistryModel
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
pyrolysisChemistryModel
(
const fvMesh& mesh
)
:
CompType(mesh),
ODE(),
Ys_(this->solidThermo().composition().Y()),
reactions_
(
dynamic_cast<const reactingMixture<SolidThermo>& >
(
this->solidThermo()
)
),
pyrolisisGases_(reactions_[0].gasSpecies()),
solidThermo_
(
dynamic_cast<const reactingMixture<SolidThermo>& >
(
this->solidThermo()
).speciesData()
),
solidChemistryModel<CompType, SolidThermo>(mesh),
pyrolisisGases_(this->reactions_[0].gasSpecies()),
gasThermo_(pyrolisisGases_.size()),
nGases_(pyrolisisGases_.size()),
nSpecie_(Ys_.size() + nGases_),
nSolids_(Ys_.size()),
nReaction_(reactions_.size()),
RRs_(nSolids_),
nSpecie_(this->Ys_.size() + nGases_),
RRg_(nGases_),
Ys0_(nSolids_),
cellCounter_(0),
reactingCells_(mesh.nCells(), true)
Ys0_(this->nSolids_),
cellCounter_(0)
{
// create the fields for the chemistry sources
forAll(RRs_, fieldI)
forAll(this->RRs_, fieldI)
{
RRs_.set
(
fieldI,
new DimensionedField<scalar, volMesh>
(
IOobject
(
"RRs." + Ys_[fieldI].name(),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0)
)
);
IOobject header
(
Ys_[fieldI].name() + "0",
this->Ys_[fieldI].name() + "0",
mesh.time().timeName(),
mesh,
IOobject::NO_READ
@ -105,7 +65,7 @@ ODESolidChemistryModel
(
IOobject
(
Ys_[fieldI].name() + "0",
this->Ys_[fieldI].name() + "0",
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
@ -137,7 +97,7 @@ ODESolidChemistryModel
(
IOobject
(
Ys_[fieldI].name() + "0",
this->Ys_[fieldI].name() + "0",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
@ -150,7 +110,7 @@ ODESolidChemistryModel
// Calculate inital values of Ysi0 = rho*delta*Yi
Ys0_[fieldI].internalField() =
this->solidThermo().rho()
*max(Ys_[fieldI], scalar(0.001))*mesh.V();
*max(this->Ys_[fieldI], scalar(0.001))*mesh.V();
}
}
@ -190,23 +150,24 @@ ODESolidChemistryModel
);
}
Info<< "solidChemistryModel: Number of solids = " << nSolids_ << endl;
Info<< "solidChemistryModel: Number of gases = " << nGases_ << endl;
forAll(reactions_, i)
Info<< "pyrolysisChemistryModel: " << nl;
Info<< indent << "Number of solids = " << this->nSolids_ << nl;
Info<< indent << "Number of gases = " << nGases_ << nl;
forAll(this->reactions_, i)
{
Info<< indent << reactions_[i] << nl;
Info<< dynamic_cast<const solidReaction<SolidThermo>& >
(
this->reactions_[i]
) << nl;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CompType, class SolidThermo, class GasThermo>
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
~ODESolidChemistryModel()
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
~pyrolysisChemistryModel()
{}
@ -214,7 +175,7 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
template<class CompType, class SolidThermo, class GasThermo>
Foam::scalarField Foam::
ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::omega
(
const scalarField& c,
const scalar T,
@ -229,9 +190,9 @@ ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
scalarField om(nEqns(), 0.0);
forAll(reactions_, i)
forAll(this->reactions_, i)
{
const Reaction<SolidThermo>& R = reactions_[i];
const Reaction<SolidThermo>& R = this->reactions_[i];
scalar omegai = omega
(
@ -242,13 +203,13 @@ ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
{
label si = R.lhs()[s].index;
om[si] -= omegai;
rhoL = solidThermo_[si].rho(p, T);
rhoL = this->solidThermo_[si].rho(p, T);
}
scalar sr = 0.0;
forAll(R.rhs(), s)
{
label si = R.rhs()[s].index;
scalar rhoR = solidThermo_[si].rho(p, T);
scalar rhoR = this->solidThermo_[si].rho(p, T);
sr = rhoR/rhoL;
om[si] += sr*omegai;
@ -260,7 +221,7 @@ ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
forAll(R.grhs(), g)
{
label gi = R.grhs()[g].index;
om[gi + nSolids_] += (1.0 - sr)*omegai;
om[gi + this->nSolids_] += (1.0 - sr)*omegai;
}
}
@ -270,7 +231,7 @@ ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
template<class CompType, class SolidThermo, class GasThermo>
Foam::scalar
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::omega
(
const Reaction<SolidThermo>& R,
const scalarField& c,
@ -314,7 +275,7 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega
template<class CompType, class SolidThermo, class GasThermo>
void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
void Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
derivatives
(
const scalar time,
@ -331,19 +292,19 @@ derivatives
//Total mass concentration
scalar cTot = 0.0;
for (label i=0; i<nSolids_; i++)
for (label i=0; i<this->nSolids_; i++)
{
cTot += c[i];
}
scalar newCp = 0.0;
scalar newhi = 0.0;
for (label i=0; i<nSolids_; i++)
for (label i=0; i<this->nSolids_; i++)
{
scalar dYidt = dcdt[i]/cTot;
scalar Yi = c[i]/cTot;
newCp += Yi*solidThermo_[i].Cp(p, T);
newhi -= dYidt*solidThermo_[i].Hc();
newCp += Yi*this->solidThermo_[i].Cp(p, T);
newhi -= dYidt*this->solidThermo_[i].Hc();
}
scalar dTdt = newhi/newCp;
@ -356,7 +317,8 @@ derivatives
template<class CompType, class SolidThermo, class GasThermo>
void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::jacobian
void Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
jacobian
(
const scalar t,
const scalarField& c,
@ -369,7 +331,7 @@ void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::jacobian
scalarField c2(nSpecie_, 0.0);
for (label i=0; i<nSolids_; i++)
for (label i=0; i<this->nSolids_; i++)
{
c2[i] = max(c[i], 0.0);
}
@ -385,9 +347,9 @@ void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::jacobian
// length of the first argument must be nSolids
dcdt = omega(c2, T, p);
for (label ri=0; ri<reactions_.size(); ri++)
for (label ri=0; ri<this->reactions_.size(); ri++)
{
const Reaction<SolidThermo>& R = reactions_[ri];
const Reaction<SolidThermo>& R = this->reactions_[ri];
scalar kf0 = R.kf(p, T, c2);
@ -451,96 +413,9 @@ void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::jacobian
}
template<class CompType, class SolidThermo, class GasThermo>
Foam::tmp<Foam::volScalarField>
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::tc() const
{
notImplemented
(
"ODESolidChemistryModel::tc()"
);
return volScalarField::null();
}
template<class CompType, class SolidThermo, class GasThermo>
Foam::tmp<Foam::volScalarField>
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::Sh() const
{
tmp<volScalarField> tSh
(
new volScalarField
(
IOobject
(
"Sh",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
false
),
this->mesh_,
dimensionedScalar("zero", dimEnergy/dimTime/dimVolume, 0.0),
zeroGradientFvPatchScalarField::typeName
)
);
if (this->chemistry_)
{
scalarField& Sh = tSh();
forAll(Ys_, i)
{
forAll(Sh, cellI)
{
scalar hf = solidThermo_[i].Hc();
Sh[cellI] -= hf*RRs_[i][cellI];
}
}
}
return tSh;
}
template<class CompType, class SolidThermo, class GasThermo>
Foam::tmp<Foam::volScalarField>
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::dQ() const
{
tmp<volScalarField> tdQ
(
new volScalarField
(
IOobject
(
"dQ",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
this->mesh_,
dimensionedScalar("dQ", dimEnergy/dimTime, 0.0),
zeroGradientFvPatchScalarField::typeName
)
);
if (this->chemistry_)
{
volScalarField& dQ = tdQ();
dQ.dimensionedInternalField() = this->mesh_.V()*Sh()();
}
return tdQ;
}
template<class CompType, class SolidThermo, class GasThermo>
Foam::label Foam::
ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::nEqns() const
pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::nEqns() const
{
// nEqns = number of solids + gases + temperature + pressure
return (nSpecie_ + 2);
@ -548,7 +423,7 @@ ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::nEqns() const
template<class CompType, class SolidThermo, class GasThermo>
void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
void Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
calculate()
{
if (!this->chemistry_)
@ -570,10 +445,11 @@ calculate()
this->solidThermo().rho()
);
forAll(RRs_, i)
forAll(this->RRs_, i)
{
RRs_[i].field() = 0.0;
this->RRs_[i].field() = 0.0;
}
forAll(RRg_, i)
{
RRg_[i].field() = 0.0;
@ -585,28 +461,28 @@ calculate()
const scalar delta = this->mesh().V()[celli];
if (reactingCells_[celli])
if (this->reactingCells_[celli])
{
scalar rhoi = rho[celli];
scalar Ti = this->solidThermo().T()[celli];
scalar pi = this->solidThermo().p()[celli];
scalarField c(nSpecie_, 0.0);
for (label i=0; i<nSolids_; i++)
for (label i=0; i<this->nSolids_; i++)
{
c[i] = rhoi*Ys_[i][celli]*delta;
c[i] = rhoi*this->Ys_[i][celli]*delta;
}
const scalarField dcdt = omega(c, Ti, pi, true);
forAll(RRs_, i)
forAll(this->RRs_, i)
{
RRs_[i][celli] = dcdt[i]/delta;
this->RRs_[i][celli] = dcdt[i]/delta;
}
forAll(RRg_, i)
{
RRg_[i][celli] = dcdt[nSolids_ + i]/delta;
RRg_[i][celli] = dcdt[this->nSolids_ + i]/delta;
}
}
}
@ -615,7 +491,7 @@ calculate()
template<class CompType, class SolidThermo, class GasThermo>
Foam::scalar
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::solve
(
const scalar t0,
const scalar deltaT
@ -642,9 +518,9 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
this->solidThermo().rho()
);
forAll(RRs_, i)
forAll(this->RRs_, i)
{
RRs_[i].field() = 0.0;
this->RRs_[i].field() = 0.0;
}
forAll(RRg_, i)
{
@ -654,7 +530,7 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
forAll(rho, celli)
{
if (reactingCells_[celli])
if (this->reactingCells_[celli])
{
cellCounter_ = celli;
@ -668,9 +544,9 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
scalar delta = this->mesh().V()[celli];
for (label i=0; i<nSolids_; i++)
for (label i=0; i<this->nSolids_; i++)
{
c[i] = rhoi*Ys_[i][celli]*delta;
c[i] = rhoi*this->Ys_[i][celli]*delta;
}
c0 = c;
@ -690,7 +566,7 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
scalar cTot = 0.0;
//Total mass concentration
for (label i=0; i<nSolids_; i++)
for (label i=0; i<this->nSolids_; i++)
{
cTot += c[i];
}
@ -700,13 +576,13 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
scalar invRho = 0.0;
scalarList dcdt = (c - c0)/dt;
for (label i=0; i<nSolids_; i++)
for (label i=0; i<this->nSolids_; i++)
{
scalar dYi = dcdt[i]/cTot;
scalar Yi = c[i]/cTot;
newCp += Yi*solidThermo_[i].Cp(pi, Ti);
newhi -= dYi*solidThermo_[i].Hc();
invRho += Yi/solidThermo_[i].rho(pi, Ti);
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;
@ -722,14 +598,14 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
deltaTMin = min(tauC, deltaTMin);
dc = c - c0;
forAll(RRs_, i)
forAll(this->RRs_, i)
{
RRs_[i][celli] = dc[i]/(deltaT*delta);
this->RRs_[i][celli] = dc[i]/(deltaT*delta);
}
forAll(RRg_, i)
{
RRg_[i][celli] = dc[nSolids_ + i]/(deltaT*delta);
RRg_[i][celli] = dc[this->nSolids_ + i]/(deltaT*delta);
}
// Update Ys0_
@ -746,7 +622,7 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
template<class CompType, class SolidThermo,class GasThermo>
Foam::tmp<Foam::volScalarField>
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::gasHs
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::gasHs
(
const volScalarField& p,
const volScalarField& T,
@ -787,7 +663,7 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::gasHs
template<class CompType, class SolidThermo, class GasThermo>
Foam::scalar
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::solve
(
scalarField &c,
const scalar T,
@ -798,7 +674,7 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
{
notImplemented
(
"ODESolidChemistryModel::solve"
"pyrolysisChemistryModel::solve"
"("
"scalarField&, "
"const scalar, "
@ -809,14 +685,4 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve
);
return (0);
}
template<class CompType, class SolidThermo,class GasThermo>
void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
setCellReacting(const label cellI, const bool active)
{
reactingCells_[cellI] = active;
}
// ************************************************************************* //

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,26 +22,24 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::ODESolidChemistryModel
Foam::pyrolysisChemistryModel
Description
Extends base chemistry model by adding a thermo package, and ODE functions.
Introduces chemistry equation system and evaluation of chemical source
terms.
Pyrolysis chemistry model. It includes gas phase in the solid
reaction.
SourceFiles
ODESolidChemistryModelI.H
ODESolidChemistryModel.C
pyrolysisChemistryModelI.H
pyrolysisChemistryModel.C
\*---------------------------------------------------------------------------*/
#ifndef ODESolidChemistryModel_H
#define ODESolidChemistryModel_H
#ifndef pyrolysisChemistryModel_H
#define pyrolysisChemistryModel_H
#include "Reaction.H"
#include "ODE.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "solidChemistryModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,35 +50,25 @@ namespace Foam
class fvMesh;
/*---------------------------------------------------------------------------*\
Class ODESolidChemistryModel Declaration
Class pyrolysisChemistryModel Declaration
\*---------------------------------------------------------------------------*/
template<class CompType, class SolidThermo, class GasThermo>
class ODESolidChemistryModel
class pyrolysisChemistryModel
:
public CompType,
public ODE
public solidChemistryModel<CompType, SolidThermo>
{
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const ODESolidChemistryModel&);
void operator=(const pyrolysisChemistryModel&);
protected:
//- Reference to solid mass fractions
PtrList<volScalarField>& Ys_;
//- Reactions
const PtrList<Reaction<SolidThermo> >& reactions_;
//- List of gas species present in reaction system
speciesTable pyrolisisGases_;
//- Thermodynamic data of solids
const PtrList<SolidThermo>& solidThermo_;
//- Thermodynamic data of gases
PtrList<GasThermo> gasThermo_;
@ -90,24 +78,12 @@ protected:
//- Number of components being solved by ODE
label nSpecie_;
//- Number of solid components
label nSolids_;
//- Number of solid reactions
label nReaction_;
//- List of reaction rate per solid [kg/m3/s]
PtrList<DimensionedField<scalar, volMesh> > RRs_;
//- List of reaction rate per gas [kg/m3/s]
PtrList<DimensionedField<scalar, volMesh> > RRg_;
// Protected Member Functions
//- Write access to source terms for solids
inline PtrList<DimensionedField<scalar, volMesh> >& RRs();
//- Write access to source terms for gases
inline PtrList<DimensionedField<scalar, volMesh> >& RRg();
@ -120,37 +96,25 @@ private:
//- Cell counter
label cellCounter_;
//- List of active reacting cells
List<bool> reactingCells_;
// Private members
//- Set reacting status of cell, cellI
void setCellReacting(const label cellI, const bool active);
public:
//- Runtime type information
TypeName("ODESolidChemistryModel");
TypeName("pyrolysis");
// Constructors
//- Construct from mesh
ODESolidChemistryModel(const fvMesh& mesh);
pyrolysisChemistryModel(const fvMesh& mesh);
//- Destructor
virtual ~ODESolidChemistryModel();
virtual ~pyrolysisChemistryModel();
// Member Functions
//- The reactions
inline const PtrList<Reaction<SolidThermo> >& reactions() const;
//- Thermodynamic data of gases
inline const PtrList<GasThermo>& gasThermo() const;
@ -163,9 +127,6 @@ public:
//- The number of solids
inline label nGases() const;
//- The number of reactions
inline label nReaction() const;
//- dc/dt = omega, rate of change in concentration, for each species
virtual scalarField omega
@ -198,12 +159,6 @@ public:
// Chemistry model functions
//- Return const access to the chemical source terms for solids
inline const DimensionedField<scalar, volMesh>& RRs
(
const label i
) const;
//- Return const access to the chemical source terms for gases
inline const DimensionedField<scalar, volMesh>& RRg
(
@ -213,15 +168,6 @@ public:
//- Return total gas source term
inline tmp<DimensionedField<scalar, volMesh> > RRg() const;
//- 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;
//- Return sensible enthalpy for gas i [J/Kg]
virtual tmp<volScalarField> gasHs
(
@ -234,15 +180,6 @@ public:
// step and return the characteristic time
virtual scalar solve(const scalar t0, const scalar deltaT) ;
//- Return the chemical time scale
virtual tmp<volScalarField> tc() const;
//- Return source for enthalpy equation [kg/m/s3]
virtual tmp<volScalarField> Sh() const;
//- Return the heat release, i.e. enthalpy/sec [m2/s3]
virtual tmp<volScalarField> dQ() const;
// ODE functions (overriding abstract functions in ODE.H)
@ -281,12 +218,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
# include "ODESolidChemistryModelI.H"
# include "pyrolysisChemistryModelI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "ODESolidChemistryModel.C"
# include "pyrolysisChemistryModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,37 +24,21 @@ License
\*---------------------------------------------------------------------------*/
#include "volFields.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CompType, class SolidThermo, class GasThermo>
inline Foam::PtrList<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >&
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRs()
{
return RRs_;
}
template<class CompType, class SolidThermo, class GasThermo>
inline Foam::PtrList<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >&
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg()
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::RRg()
{
return RRg_;
}
template<class CompType, class SolidThermo, class GasThermo>
inline const Foam::PtrList<Foam::Reaction<SolidThermo> >&
Foam::ODESolidChemistryModel<CompType, SolidThermo,GasThermo>::reactions() const
{
return reactions_;
}
template<class CompType, class SolidThermo, class GasThermo>
inline const Foam::PtrList<GasThermo>&
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
gasThermo() const
{
return gasThermo_;
@ -63,7 +47,8 @@ gasThermo() const
template<class CompType, class SolidThermo, class GasThermo>
inline const Foam::speciesTable&
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::gasTable() const
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
gasTable() const
{
return pyrolisisGases_;
}
@ -71,35 +56,16 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::gasTable() const
template<class CompType, class SolidThermo, class GasThermo>
inline Foam::label
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::nSpecie() const
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
nSpecie() const
{
return nSpecie_;
}
template<class CompType, class SolidThermo, class GasThermo>
inline Foam::label
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::
nReaction() const
{
return nReaction_;
}
template<class CompType, class SolidThermo, class GasThermo>
inline const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRs
(
const label i
) const
{
return RRs_[i];
}
template<class CompType, class SolidThermo, class GasThermo>
inline const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::RRg
(
const label i
) const
@ -110,7 +76,8 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg
template<class CompType, class SolidThermo, class GasThermo>
inline Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg() const
Foam::pyrolysisChemistryModel<CompType, SolidThermo, GasThermo>::
RRg() const
{
tmp<DimensionedField<scalar, volMesh> > tRRg
(
@ -139,51 +106,4 @@ Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg() const
}
return tRRg;
}
template<class CompType, class SolidThermo, class GasThermo>
inline Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRs() const
{
tmp<DimensionedField<scalar, volMesh> > tRRs
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
"RRs",
this->time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
this->mesh(),
dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0)
)
);
if (this->chemistry_)
{
DimensionedField<scalar, volMesh>& RRs = tRRs();
for (label i=0; i < nSolids_; i++)
{
RRs += RRs_[i];
}
}
return tRRs;
}
template<class CompType, class SolidThermo, class GasThermo>
inline const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RR
(
const label i
) const
{
notImplemented("ODESolidChemistryModel::RR(const label)");
return (DimensionedField<scalar, volMesh>::null());
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,33 +24,193 @@ License
\*---------------------------------------------------------------------------*/
#include "solidChemistryModel.H"
#include "fvMesh.H"
#include "Time.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
namespace Foam
{
defineTypeNameAndDebug(solidChemistryModel, 0);
defineRunTimeSelectionTable(solidChemistryModel, fvMesh);
}
#include "reactingMixture.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidChemistryModel::solidChemistryModel
template<class CompType, class SolidThermo>
Foam::solidChemistryModel<CompType, SolidThermo>::
solidChemistryModel
(
const fvMesh& mesh
)
:
basicChemistryModel(mesh),
solidThermo_(solidReactionThermo::New(mesh))
{}
CompType(mesh),
ODE(),
Ys_(this->solidThermo().composition().Y()),
reactions_
(
dynamic_cast<const reactingMixture<SolidThermo>& >
(
this->solidThermo()
)
),
solidThermo_
(
dynamic_cast<const reactingMixture<SolidThermo>& >
(
this->solidThermo()
).speciesData()
),
nSolids_(Ys_.size()),
nReaction_(reactions_.size()),
RRs_(nSolids_),
reactingCells_(mesh.nCells(), true)
{
// create the fields for the chemistry sources
forAll(RRs_, fieldI)
{
RRs_.set
(
fieldI,
new DimensionedField<scalar, volMesh>
(
IOobject
(
"RRs." + Ys_[fieldI].name(),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0)
)
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::solidChemistryModel::~solidChemistryModel()
template<class CompType, class SolidThermo>
Foam::solidChemistryModel<CompType, SolidThermo>::
~solidChemistryModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CompType, class SolidThermo>
Foam::tmp<Foam::volScalarField>
Foam::solidChemistryModel<CompType, SolidThermo>::tc() const
{
notImplemented
(
"solidChemistryModel::tc()"
);
return volScalarField::null();
}
template<class CompType, class SolidThermo>
Foam::tmp<Foam::volScalarField>
Foam::solidChemistryModel<CompType, SolidThermo>::Sh() const
{
tmp<volScalarField> tSh
(
new volScalarField
(
IOobject
(
"Sh",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
false
),
this->mesh_,
dimensionedScalar("zero", dimEnergy/dimTime/dimVolume, 0.0),
zeroGradientFvPatchScalarField::typeName
)
);
if (this->chemistry_)
{
scalarField& Sh = tSh();
forAll(Ys_, i)
{
forAll(Sh, cellI)
{
scalar hf = solidThermo_[i].Hc();
Sh[cellI] -= hf*RRs_[i][cellI];
}
}
}
return tSh;
}
template<class CompType, class SolidThermo>
Foam::tmp<Foam::volScalarField>
Foam::solidChemistryModel<CompType, SolidThermo>::dQ() const
{
tmp<volScalarField> tdQ
(
new volScalarField
(
IOobject
(
"dQ",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
this->mesh_,
dimensionedScalar("dQ", dimEnergy/dimTime, 0.0),
zeroGradientFvPatchScalarField::typeName
)
);
if (this->chemistry_)
{
volScalarField& dQ = tdQ();
dQ.dimensionedInternalField() = this->mesh_.V()*Sh()();
}
return tdQ;
}
template<class CompType, class SolidThermo>
Foam::scalar Foam::solidChemistryModel<CompType, SolidThermo>::solve
(
scalarField &c,
const scalar T,
const scalar p,
const scalar t0,
const scalar dt
) const
{
notImplemented
(
"solidChemistryModel::solve"
"("
"scalarField&, "
"const scalar, "
"const scalar, "
"const scalar, "
"const scalar"
") const"
);
return (0);
}
template<class CompType, class SolidThermo>
void Foam::solidChemistryModel<CompType, SolidThermo>::setCellReacting
(
const label cellI,
const bool active
)
{
reactingCells_[cellI] = active;
}
// ************************************************************************* //

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,23 +25,24 @@ Class
Foam::solidChemistryModel
Description
Chemistry model for solid thermodynamics
Extends base solid chemistry model by adding a thermo package, and ODE
functions.
Introduces chemistry equation system and evaluation of chemical source
terms.
SourceFiles
solidChemistryModelI.H
solidChemistryModel.C
newChemistrySolidModel.C
\*---------------------------------------------------------------------------*/
#ifndef solidChemistryModel_H
#define solidChemistryModel_H
#include "basicChemistryModel.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "solidReactionThermo.H"
#include "Reaction.H"
#include "ODE.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,45 +53,57 @@ namespace Foam
class fvMesh;
/*---------------------------------------------------------------------------*\
class solidChemistryModel Declaration
Class solidChemistryModel Declaration
\*---------------------------------------------------------------------------*/
template<class CompType, class SolidThermo>
class solidChemistryModel
:
public basicChemistryModel
public CompType,
public ODE
{
// Private Member Functions
//- Construct as copy (not implemented)
solidChemistryModel(const solidChemistryModel&);
//- Disallow default bitwise assignment
void operator=(const solidChemistryModel&);
protected:
// Protected data
//- Reference to solid mass fractions
PtrList<volScalarField>& Ys_;
//- Solid thermo package
autoPtr<solidReactionThermo> solidThermo_;
//- Reactions
const PtrList<Reaction<SolidThermo> >& reactions_;
//- Thermodynamic data of solids
const PtrList<SolidThermo>& solidThermo_;
//- Number of solid components
label nSolids_;
//- Number of solid reactions
label nReaction_;
//- List of reaction rate per solid [kg/m3/s]
PtrList<DimensionedField<scalar, volMesh> > RRs_;
//- List of active reacting cells
List<bool> reactingCells_;
// Protected Member Functions
//- Write access to source terms for solids
inline PtrList<DimensionedField<scalar, volMesh> >& RRs();
//- Set reacting status of cell, cellI
void setCellReacting(const label cellI, const bool active);
public:
//- Runtime type information
TypeName("solid");
//- Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
solidChemistryModel,
fvMesh,
(const fvMesh& mesh),
(mesh)
);
TypeName("solidChemistryModel");
// Constructors
@ -99,56 +112,108 @@ public:
solidChemistryModel(const fvMesh& mesh);
//- Selector
static autoPtr<solidChemistryModel> New(const fvMesh& mesh);
//- Destructor
virtual ~solidChemistryModel();
// Member Functions
//- Return access to the solid thermo package
inline solidReactionThermo& solidThermo();
//- The reactions
inline const PtrList<Reaction<SolidThermo> >& reactions() const;
//- Return const access to the solid thermo package
inline const solidReactionThermo& solidThermo() const;
//- The number of reactions
inline label nReaction() const;
//- Return total gases mass source term [kg/m3/s]
virtual tmp<DimensionedField<scalar, volMesh> > RRg() const = 0;
//- Return total solids mass source term [kg/m3/s]
virtual tmp<DimensionedField<scalar, volMesh> > RRs() const = 0;
//- Return chemical source terms for solids [kg/m3/s]
virtual const DimensionedField<scalar, volMesh>& RRs
//- dc/dt = omega, rate of change in concentration, for each species
virtual scalarField omega
(
const label i
const scalarField& c,
const scalar T,
const scalar p,
const bool updateC0 = false
) const = 0;
//- Return chemical source terms for gases [kg/m3/s]
virtual const DimensionedField<scalar, volMesh>& RRg
//- Return the reaction rate for reaction r and the reference
// species and charateristic times
virtual scalar omega
(
const label i
const Reaction<SolidThermo>& r,
const scalarField& c,
const scalar T,
const scalar p,
scalar& pf,
scalar& cf,
label& lRef,
scalar& pr,
scalar& cr,
label& rRef
) const = 0;
//- Return sensible enthalpy for gas i [J/Kg]
virtual tmp<volScalarField> gasHs
(
const volScalarField& p,
const volScalarField& T,
const label i
) const = 0;
//- Return specie Table for gases
virtual const speciesTable& gasTable() const = 0;
//- Set reacting status of cell, cellI
virtual void setCellReacting(const label cellI, const bool active) = 0;
//- Calculates the reaction rates
virtual void calculate() = 0;
// Chemistry model functions
//- Return const access to the chemical source terms for solids
inline const DimensionedField<scalar, volMesh>& RRs
(
const label i
) const;
//- 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;
//- Return the chemical time scale
virtual tmp<volScalarField> tc() const;
//- Return source for enthalpy equation [kg/m/s3]
virtual tmp<volScalarField> Sh() const;
//- Return the heat release, i.e. enthalpy/sec [m2/s3]
virtual tmp<volScalarField> dQ() const;
// ODE functions (overriding abstract functions in ODE.H)
//- Number of ODE's to solve
virtual label nEqns() const = 0;
virtual void derivatives
(
const scalar t,
const scalarField& c,
scalarField& dcdt
) const = 0;
virtual void jacobian
(
const scalar t,
const scalarField& c,
scalarField& dcdt,
scalarSquareMatrix& dfdc
) const = 0;
virtual scalar solve
(
scalarField &c,
const scalar T,
const scalar p,
const scalar t0,
const scalar dt
) const = 0;
};
@ -162,6 +227,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "solidChemistryModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,18 +23,87 @@ License
\*---------------------------------------------------------------------------*/
#include "volFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::solidReactionThermo& Foam::solidChemistryModel::solidThermo()
template<class CompType, class SolidThermo>
inline Foam::PtrList<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >&
Foam::solidChemistryModel<CompType, SolidThermo>::RRs()
{
return solidThermo_();
return RRs_;
}
template<class CompType, class SolidThermo>
inline const Foam::PtrList<Foam::Reaction<SolidThermo> >&
Foam::solidChemistryModel<CompType, SolidThermo>::reactions() const
{
return reactions_;
}
inline const Foam::solidReactionThermo&
Foam::solidChemistryModel::solidThermo() const
template<class CompType, class SolidThermo>
inline Foam::label
Foam::solidChemistryModel<CompType, SolidThermo>::
nReaction() const
{
return solidThermo_();
return nReaction_;
}
template<class CompType, class SolidThermo>
inline const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::solidChemistryModel<CompType, SolidThermo>::RRs
(
const label i
) const
{
return RRs_[i];
}
template<class CompType, class SolidThermo>
inline Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::solidChemistryModel<CompType, SolidThermo>::RRs() const
{
tmp<DimensionedField<scalar, volMesh> > tRRs
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
"RRs",
this->time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
this->mesh(),
dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0)
)
);
if (this->chemistry_)
{
DimensionedField<scalar, volMesh>& RRs = tRRs();
for (label i=0; i < nSolids_; i++)
{
RRs += RRs_[i];
}
}
return tRRs;
}
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());
}

View File

@ -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
@ -39,15 +39,15 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeSolidChemistrySolverType(SS, Comp, SThermo, GThermo) \
#define makeSolidChemistrySolverType(SS, Schem, Comp, SThermo, GThermo) \
\
typedef SS<ODESolidChemistryModel<Comp, SThermo, GThermo> > \
SS##Comp##SThermo##GThermo; \
typedef SS<Schem<Comp, SThermo, GThermo> > \
SS##Schem##Comp##SThermo##GThermo; \
\
defineTemplateTypeNameAndDebugWithName \
( \
SS##Comp##SThermo##GThermo, \
(#SS"<" + word(Comp::typeName_()) \
SS##Schem##Comp##SThermo##GThermo, \
(#SS"<" + word(Schem::typeName_()) \
+ "," + SThermo::typeName() + "," + GThermo::typeName() + ">").c_str(), \
0 \
); \
@ -55,7 +55,7 @@ namespace Foam
addToRunTimeSelectionTable \
( \
Comp, \
SS##Comp##SThermo##GThermo, \
SS##Schem##Comp##SThermo##GThermo, \
fvMesh \
);

View File

@ -27,8 +27,8 @@ License
#include "solidThermoPhysicsTypes.H"
#include "thermoPhysicsTypes.H"
#include "ODESolidChemistryModel.H"
#include "solidChemistryModel.H"
#include "pyrolysisChemistryModel.H"
#include "basicSolidChemistryModel.H"
#include "ode.H"
@ -39,7 +39,8 @@ namespace Foam
makeSolidChemistrySolverType
(
ode,
solidChemistryModel,
pyrolysisChemistryModel,
basicSolidChemistryModel,
hConstSolidThermoPhysics,
gasHThermoPhysics
)
@ -47,7 +48,8 @@ namespace Foam
makeSolidChemistrySolverType
(
ode,
solidChemistryModel,
pyrolysisChemistryModel,
basicSolidChemistryModel,
hExponentialSolidThermoPhysics,
gasHThermoPhysics
)

View File

@ -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) 2013-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -150,12 +150,18 @@ Foam::string Foam::solidReaction<ReactionThermo>::solidReactionStr
) const
{
this->reactionStrLeft(reaction);
if (glhs().size() > 0)
{
reaction << " + ";
solidReactionStrLeft(reaction);
}
reaction << " = ";
this->reactionStrRight(reaction);
if (grhs().size() > 0)
{
reaction << " + ";
solidReactionStrRight(reaction);
}
return reaction.str();
}
@ -169,8 +175,6 @@ void Foam::solidReaction<ReactionThermo>::solidReactionStrLeft
{
for (label i = 0; i < glhs().size(); ++i)
{
reaction << " + ";
if (i > 0)
{
reaction << " + ";
@ -197,8 +201,6 @@ void Foam::solidReaction<ReactionThermo>::solidReactionStrRight
for (label i = 0; i < grhs().size(); ++i)
{
reaction << " + ";
if (i > 0)
{
reaction << " + ";

View File

@ -18,7 +18,7 @@ FoamFile
chemistryType
{
chemistrySolver ode;
chemistryThermo solid;
chemistryThermo pyrolysis;
}
chemistry on;