From 738f93bdf00ac2c5bb90c4d13d46e762b2d6434b Mon Sep 17 00:00:00 2001 From: ignis Date: Mon, 3 Oct 2016 22:58:49 +0900 Subject: [PATCH] ElectronIReaction<> completed a. Separate CSV table lookup to Bolsig reaction rate class b. BolsigFitReactionRate c. Instantiation changed d. Support for hasElectron predicate --- .../ElectronIReaction/ElectronIReaction.C | 9 +- .../ElectronIReaction/ElectronIReaction.H | 6 +- .../reaction/Reactions/Reaction/Reaction.H | 4 + .../BolsigFitReactionRate.H | 137 +++++++++++++++++ .../BolsigFitReactionRateI.H | 139 ++++++++++++++++++ .../BolsigTableReactionRate.H | 134 +++++++++++++++++ .../BolsigTableReactionRateI.H | 95 ++++++++++++ .../specie/reaction/reactions/makeReaction.H | 2 - .../specie/reaction/reactions/makeReactions.C | 11 ++ 9 files changed, 530 insertions(+), 7 deletions(-) create mode 100644 src/thermophysicalModels/specie/reaction/reactionRate/BolsigFitReactionRate/BolsigFitReactionRate.H create mode 100644 src/thermophysicalModels/specie/reaction/reactionRate/BolsigFitReactionRate/BolsigFitReactionRateI.H create mode 100644 src/thermophysicalModels/specie/reaction/reactionRate/BolsigTableReactionRate/BolsigTableReactionRate.H create mode 100644 src/thermophysicalModels/specie/reaction/reactionRate/BolsigTableReactionRate/BolsigTableReactionRateI.H diff --git a/src/thermophysicalModels/specie/reaction/Reactions/ElectronIReaction/ElectronIReaction.C b/src/thermophysicalModels/specie/reaction/Reactions/ElectronIReaction/ElectronIReaction.C index 84726a3e..355b727a 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/ElectronIReaction/ElectronIReaction.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/ElectronIReaction/ElectronIReaction.C @@ -81,8 +81,8 @@ ElectronIReaction ) : ReactionType(species, thermoDatabase, dict), - k_(species, dict), - ke_(new CSV ("k", dict)) + k_(species, dict)// , + // ke_(new CSV ("k", dict)) {} @@ -124,7 +124,10 @@ Foam::scalar Foam::ElectronIReaction const scalarField& c ) const { - return ke_->value(this->En()); + // 1 Vm^2 -> 1e21 Td + // m^3/s -> NA m^3/kmol/s + // return ke_->value(this->En() / 1e-21) * ReactionThermo::NA; + return k_(this->En(), this->Te(), c); } diff --git a/src/thermophysicalModels/specie/reaction/Reactions/ElectronIReaction/ElectronIReaction.H b/src/thermophysicalModels/specie/reaction/Reactions/ElectronIReaction/ElectronIReaction.H index 0908f8c5..3fab6018 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/ElectronIReaction/ElectronIReaction.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/ElectronIReaction/ElectronIReaction.H @@ -63,8 +63,6 @@ class ElectronIReaction ReactionRate k_; - autoPtr > ke_; - // Private Member Functions @@ -179,6 +177,10 @@ public: //- Write virtual void write(Ostream&) const; + + + //- Check whether electron reaction + virtual bool hasElectron() const {return true;} }; diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H index 9489ac31..d3146633 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H @@ -376,6 +376,10 @@ public: virtual void write(Ostream&) const; + //- Check whether electron reaction + virtual bool hasElectron() const {return false;} + + // Ostream Operator friend Ostream& operator<< diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/BolsigFitReactionRate/BolsigFitReactionRate.H b/src/thermophysicalModels/specie/reaction/reactionRate/BolsigFitReactionRate/BolsigFitReactionRate.H new file mode 100644 index 00000000..1e82f32b --- /dev/null +++ b/src/thermophysicalModels/specie/reaction/reactionRate/BolsigFitReactionRate/BolsigFitReactionRate.H @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 . + +Class + Foam::BolsigFitReactionRate + +Description + BolsigFit reaction rate given by: + + k = A * T^beta * exp(-Ta/T) + +SourceFiles + BolsigFitReactionRateI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef BolsigFitReactionRate_H +#define BolsigFitReactionRate_H + +#include "scalarField.H" +#include "typeInfo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class BolsigFitReactionRate Declaration +\*---------------------------------------------------------------------------*/ + +class BolsigFitReactionRate +{ + // Private data + + scalar A_; + scalar B_; + scalar C_; + scalar D_; + scalar E_; + scalar threshold_; + // scalar beta_; + // scalar Ta_; + + +public: + + // Constructors + + //- Construct from components + inline BolsigFitReactionRate + ( + const scalar A, + const scalar B, + const scalar C, + const scalar D, + const scalar E, + const scalar threshold + ); + + //- Construct from Istream + inline BolsigFitReactionRate + ( + const speciesTable& species, + Istream& is + ); + + //- Construct from dictionary + inline BolsigFitReactionRate + ( + const speciesTable& species, + const dictionary& dict + ); + + + // Member Functions + + //- Return the type name + static word type() + { + return "BolsigFit"; + } + + 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 BolsigFitReactionRate& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "BolsigFitReactionRateI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/BolsigFitReactionRate/BolsigFitReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/BolsigFitReactionRate/BolsigFitReactionRateI.H new file mode 100644 index 00000000..318d4bf1 --- /dev/null +++ b/src/thermophysicalModels/specie/reaction/reactionRate/BolsigFitReactionRate/BolsigFitReactionRateI.H @@ -0,0 +1,139 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::BolsigFitReactionRate::BolsigFitReactionRate +( + const scalar A, + const scalar B, + const scalar C, + const scalar D, + const scalar E, + const scalar threshold +) +: + A_(A), + B_(B), + C_(C), + D_(D), + E_(E), + threshold_(threshold) +{} + + +inline Foam::BolsigFitReactionRate::BolsigFitReactionRate +( + const speciesTable&, + Istream& is +) +: + A_(readScalar(is.readBegin("BolsigFitReactionRate(Istream&)"))), + B_(readScalar(is)), + C_(readScalar(is)), + D_(readScalar(is)), + E_(readScalar(is)), + threshold_(readScalar(is)) +{ + is.readEnd("BolsigFitReactionRate(Istream&)"); +} + + +inline Foam::BolsigFitReactionRate::BolsigFitReactionRate +( + const speciesTable&, + const dictionary& dict +) +: + A_(readScalar(dict.lookup("A"))), + B_(readScalar(dict.lookup("B"))), + C_(readScalar(dict.lookup("C"))), + D_(readScalar(dict.lookup("D"))), + E_(readScalar(dict.lookup("E"))), + threshold_(readScalar(dict.lookup("EnThreshold"))) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::scalar Foam::BolsigFitReactionRate::operator() +( + const scalar p, + const scalar T, + const scalarField& +) const +{ + const scalar oneTd = 1.0e-21; // 1e-21 Vm^2 = 1 Td + const scalar NA = 6.0221417930e+23; // mol^-1 + const scalar mol2kmol = 1000.0; //mol/kmol^-1 + + // p is actually E/n in Vm^2 unit + scalar x = p / oneTd; + + scalar ak = 0.0; + + // threshold_ is E/n threshold in Td unit + if (x > threshold_) + { + scalar x2 = x * x; + scalar x3 = x2 * x; + scalar lnx = log(x); + ak = exp(A_ + B_*lnx + C_/x + D_/x2 + E_/x3) * NA * mol2kmol; + } + + return ak > 0.0 ? ak : 0.0; +} + + +inline void Foam::BolsigFitReactionRate::write(Ostream& os) const +{ + os.writeKeyword("A") << A_ << token::END_STATEMENT << nl; + os.writeKeyword("B") << B_ << token::END_STATEMENT << nl; + os.writeKeyword("C") << C_ << token::END_STATEMENT << nl; + os.writeKeyword("D") << D_ << token::END_STATEMENT << nl; + os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeKeyword("EnThreshold") << threshold_ << token::END_STATEMENT << nl; +} + + +inline Foam::Ostream& Foam::operator<< +( + Ostream& os, + const BolsigFitReactionRate& arr +) +{ + os << token::BEGIN_LIST + << arr.A_ << token::SPACE + << arr.B_ << token::SPACE + << arr.C_ << token::SPACE + << arr.D_ << token::SPACE + << arr.E_ << token::SPACE + << arr.threshold_ + << token::END_LIST; + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/BolsigTableReactionRate/BolsigTableReactionRate.H b/src/thermophysicalModels/specie/reaction/reactionRate/BolsigTableReactionRate/BolsigTableReactionRate.H new file mode 100644 index 00000000..05b6297d --- /dev/null +++ b/src/thermophysicalModels/specie/reaction/reactionRate/BolsigTableReactionRate/BolsigTableReactionRate.H @@ -0,0 +1,134 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 . + +Class + Foam::BolsigTableReactionRate + +Description + BolsigTable reaction rate given by: + + k = A * T^beta * exp(-Ta/T) + +SourceFiles + BolsigTableReactionRateI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef BolsigTableReactionRate_H +#define BolsigTableReactionRate_H + +#include "scalarField.H" +#include "typeInfo.H" + +#include "CSV.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class BolsigTableReactionRate Declaration +\*---------------------------------------------------------------------------*/ + +class BolsigTableReactionRate +{ + // Private data + + // scalar A_; + // scalar B_; + // scalar C_; + // scalar D_; + // scalar E_; + // scalar beta_; + // scalar Ta_; + + autoPtr > ke_; + + +public: + + // Constructors + + //- Construct from components + inline BolsigTableReactionRate + ( + ); + + //- Construct from Istream + inline BolsigTableReactionRate + ( + const speciesTable& species, + Istream& is + ); + + //- Construct from dictionary + inline BolsigTableReactionRate + ( + const speciesTable& species, + const dictionary& dict + ); + + + // Member Functions + + //- Return the type name + static word type() + { + return "BolsigTable"; + } + + 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 BolsigTableReactionRate& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "BolsigTableReactionRateI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/BolsigTableReactionRate/BolsigTableReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/BolsigTableReactionRate/BolsigTableReactionRateI.H new file mode 100644 index 00000000..a1d4e6b8 --- /dev/null +++ b/src/thermophysicalModels/specie/reaction/reactionRate/BolsigTableReactionRate/BolsigTableReactionRateI.H @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::BolsigTableReactionRate::BolsigTableReactionRate +( +) +: + ke_(NULL) +{} + + +inline Foam::BolsigTableReactionRate::BolsigTableReactionRate +( + const speciesTable&, + Istream& is +) +: + ke_(NULL) +{ +} + + +inline Foam::BolsigTableReactionRate::BolsigTableReactionRate +( + const speciesTable&, + const dictionary& dict +) +: + ke_(new CSV ("k", dict)) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::scalar Foam::BolsigTableReactionRate::operator() +( + const scalar p, + const scalar T, + const scalarField& +) const +{ + const scalar NA = 6.0221417930e+23; // mol^-1 + const scalar mol2kmol = 1000.0; //mol/kmol^-1 + const scalar oneTd = 1.0e-21; // 1e-21 Vm^2 = 1 Td + + // p is actually E/n in Vm^2 unit + scalar coef = ke_->value(p / oneTd) * NA * mol2kmol; + // Info << ke_->value(p * 1e21) << endl; + return coef; + // return ke_->value(p / 1e-21) * NA * mol2kmol; +} + + +inline void Foam::BolsigTableReactionRate::write(Ostream& os) const +{ +} + + +inline Foam::Ostream& Foam::operator<< +( + Ostream& os, + const BolsigTableReactionRate& arr +) +{ + os << token::BEGIN_LIST + << token::END_LIST; + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/reaction/reactions/makeReaction.H b/src/thermophysicalModels/specie/reaction/reactions/makeReaction.H index b26495ee..ea40cff5 100644 --- a/src/thermophysicalModels/specie/reaction/reactions/makeReaction.H +++ b/src/thermophysicalModels/specie/reaction/reactions/makeReaction.H @@ -120,8 +120,6 @@ namespace Foam \ makeIRReactions(Thermo, ReactionRate) \ \ - makeReaction(Thermo, ElectronIReaction, ReactionRate) \ - \ makeReaction(Thermo, NonEquilibriumReversibleReaction, ReactionRate) diff --git a/src/thermophysicalModels/specie/reaction/reactions/makeReactions.C b/src/thermophysicalModels/specie/reaction/reactions/makeReactions.C index baf6c0d5..08fb8dc2 100644 --- a/src/thermophysicalModels/specie/reaction/reactions/makeReactions.C +++ b/src/thermophysicalModels/specie/reaction/reactions/makeReactions.C @@ -40,15 +40,26 @@ License #include "SRIFallOffFunction.H" #include "TroeFallOffFunction.H" +#include "BolsigTableReactionRate.H" +#include "BolsigFitReactionRate.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#define makeElectronReactions(Thermo) \ + \ + makeReaction(Thermo, ElectronIReaction, ArrheniusReactionRate) \ + makeReaction(Thermo, ElectronIReaction, BolsigFitReactionRate) \ + makeReaction(Thermo, ElectronIReaction, BolsigTableReactionRate) + + #define makeReactions(Thermo, Reaction) \ \ defineTemplateTypeNameAndDebug(Reaction, 0); \ defineTemplateRunTimeSelectionTable(Reaction, Istream); \ defineTemplateRunTimeSelectionTable(Reaction, dictionary); \ \ + makeElectronReactions(Thermo) \ + \ makeIRNReactions(Thermo, ArrheniusReactionRate) \ makeIRNReactions(Thermo, infiniteReactionRate) \ makeIRNReactions(Thermo, LandauTellerReactionRate) \