ENH: solidIsothermalReactionRate: new solid reaction rate model

STYLE: solidArrheniusReactionRate: modernise code
This commit is contained in:
Kutalmis Bercin
2021-08-02 12:02:40 +01:00
parent bdb437ab10
commit 8bfbda8c71
5 changed files with 260 additions and 18 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef solidArrheniusReactionRate_H
#define solidArrheniusReactionRate_H
#ifndef Foam_solidArrheniusReactionRate_H
#define Foam_solidArrheniusReactionRate_H
#include "scalarField.H"
#include "typeInfo.H"
@ -46,23 +46,27 @@ SourceFiles
namespace Foam
{
// Forward declaration of friend functions and operators
// Forward Declarations
class solidArrheniusReactionRate;
Ostream& operator<<(Ostream&, const solidArrheniusReactionRate&);
/*---------------------------------------------------------------------------*\
Class solidArrheniusReactionRate Declaration
Class solidArrheniusReactionRate Declaration
\*---------------------------------------------------------------------------*/
class solidArrheniusReactionRate
{
// Private data
// Private Data
//- Pre-exponential factor
scalar A_;
//- Activation temperature
scalar Ta_;
//- Critical temperature
scalar Tcrit_;
@ -99,6 +103,8 @@ public:
return "Arrhenius";
}
//- Return reaction rate constant
// frequency of collisions resulting in a reaction
inline scalar operator()
(
const scalar p,
@ -107,7 +113,7 @@ public:
) const;
//- Write to stream
//- Write to stream
inline void write(Ostream& os) const;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,7 +33,6 @@ inline Foam::solidArrheniusReactionRate::solidArrheniusReactionRate
const scalar A,
const scalar Ta,
const scalar Tcrit
//const scalar nReact
)
:
A_(A),
@ -62,18 +62,12 @@ inline Foam::scalar Foam::solidArrheniusReactionRate::operator()
const scalarField&
) const
{
scalar ak = A_;
if (T < Tcrit_)
{
ak *= 0.0;
}
else
{
ak *= exp(-Ta_/T);
return 0;
}
return ak;
return A_*exp(-Ta_/T);
}

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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::solidIsothermalReactionRate
Description
Isothermal reaction rate for solids
SourceFiles
solidIsothermalReactionRateI.H
\*---------------------------------------------------------------------------*/
#ifndef Foam_solidIsothermalReactionRate_H
#define Foam_solidIsothermalReactionRate_H
#include "scalarField.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class solidIsothermalReactionRate;
Ostream& operator<<(Ostream&, const solidIsothermalReactionRate&);
/*---------------------------------------------------------------------------*\
Class solidIsothermalReactionRate Declaration
\*---------------------------------------------------------------------------*/
class solidIsothermalReactionRate
{
// Private Data
//- Model constant
scalar C_;
//- Specific heat of solid material (assumed constant)
scalar Cp_;
//- Phase change temperature
scalar Tpc_;
//- Latent heat of phase change
scalar Elat_;
public:
// Constructors
//- Construct from components
inline solidIsothermalReactionRate
(
const scalar C,
const scalar Cp,
const scalar Tpc,
const scalar Elat
);
//- Construct from dictionary
inline solidIsothermalReactionRate
(
const speciesTable& species,
const dictionary& dict
);
//- Destructor
virtual ~solidIsothermalReactionRate() = default;
// Member Functions
//- Return the type name
static word type()
{
return "Isothermal";
}
//- Return reaction rate constant
// frequency of collisions resulting in a reaction
inline scalar operator()
(
const scalar p,
const scalar T,
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator
inline friend Ostream& operator<<
(
Ostream&,
const solidIsothermalReactionRate&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "solidIsothermalReactionRateI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::solidIsothermalReactionRate::solidIsothermalReactionRate
(
const scalar C,
const scalar Cp,
const scalar Tpc,
const scalar Elat
)
:
C_(C),
Cp_(Cp),
Tpc_(Tpc),
Elat_(Elat)
{}
inline Foam::solidIsothermalReactionRate::solidIsothermalReactionRate
(
const speciesTable&,
const dictionary& dict
)
:
C_(dict.get<scalar>("C")),
Cp_(dict.get<scalar>("Cp")),
Tpc_(dict.get<scalar>("Tpc")),
Elat_(dict.getCheck<scalar>("Elat", scalarMinMax::ge(SMALL)))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::solidIsothermalReactionRate::operator()
(
const scalar,
const scalar T,
const scalarField&
) const
{
if (T < Tpc_)
{
return 0;
}
return -C_*Cp_*(T - Tpc_)/Elat_;
}
inline void Foam::solidIsothermalReactionRate::write(Ostream& os) const
{
os.writeEntry("C", C_);
os.writeEntry("Cp", Cp_);
os.writeEntry("Tpc", Tpc_);
os.writeEntry("Elat", Elat_);
}
inline Foam::Ostream& Foam::operator<<
(
Ostream& os,
const solidIsothermalReactionRate& iso
)
{
iso.write(os);
return os;
}
// ************************************************************************* //

View File

@ -29,6 +29,7 @@ License
#include "makeSolidReaction.H"
#include "solidArrheniusReactionRate.H"
#include "solidIsothermalReactionRate.H"
#include "solidThermoPhysicsTypes.H"
@ -45,7 +46,8 @@ License
defineTemplateTypeNameAndDebug(solidReaction##Thermo, 0); \
defineTemplateTypeNameAndDebug(Reaction##Thermo, 0); \
\
makeSolidIRReactions(Thermo, solidArrheniusReactionRate)
makeSolidIRReactions(Thermo, solidArrheniusReactionRate) \
makeSolidIRReactions(Thermo, solidIsothermalReactionRate)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //