From 62eb0e1567607208c89a7fba6ef9602c7a459df7 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 2 Feb 2016 18:59:44 +0000 Subject: [PATCH] thermophysicalModels/specie/transport/logPolynomial: Polynomial in ln(T) for transport properties ln(mu) = sum_i=1^N(a[i]*ln(T)^(i-1)) ln(kappa) = sum_i=1^N(b[i]* ln(T)^(i-1)) Based on patch provided by Armin Wehrfritz Resolves feature-request http://www.openfoam.org/mantisbt/view.php?id=978 --- .../logPolynomial/logPolynomialTransport.C | 128 ++++++++ .../logPolynomial/logPolynomialTransport.H | 238 +++++++++++++++ .../logPolynomial/logPolynomialTransportI.H | 274 ++++++++++++++++++ 3 files changed, 640 insertions(+) create mode 100644 src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C create mode 100644 src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.H create mode 100644 src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransportI.H diff --git a/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C new file mode 100644 index 0000000000..b1fd1f8216 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C @@ -0,0 +1,128 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 . + +\*---------------------------------------------------------------------------*/ + +#include "logPolynomialTransport.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::logPolynomialTransport::logPolynomialTransport +( + Istream& is +) +: + Thermo(is), + muCoeffs_("muLogCoeffs<" + Foam::name(PolySize) + '>', is), + kappaCoeffs_("kappaLogCoeffs<" + Foam::name(PolySize) + '>', is) +{ + muCoeffs_ *= this->W(); + kappaCoeffs_ *= this->W(); +} + + +template +Foam::logPolynomialTransport::logPolynomialTransport +( + const dictionary& dict +) +: + Thermo(dict), + muCoeffs_ + ( + dict.subDict("transport").lookup + ( + "muLogCoeffs<" + Foam::name(PolySize) + '>' + ) + ), + kappaCoeffs_ + ( + dict.subDict("transport").lookup + ( + "kappaLogCoeffs<" + Foam::name(PolySize) + '>' + ) + ) +{ + muCoeffs_ *= this->W(); + kappaCoeffs_ *= this->W(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::logPolynomialTransport::write(Ostream& os) const +{ + os << this->name() << endl; + os << token::BEGIN_BLOCK << incrIndent << nl; + + Thermo::write(os); + + dictionary dict("transport"); + dict.add + ( + word("muLogCoeffs<" + Foam::name(PolySize) + '>'), + muCoeffs_/this->W() + ); + dict.add + ( + word("kappaLogCoeffs<" + Foam::name(PolySize) + '>'), + kappaCoeffs_/this->W() + ); + os << indent << dict.dictName() << dict; + + os << decrIndent << token::END_BLOCK << nl; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const logPolynomialTransport& pt +) +{ + os << static_cast(pt) << tab + << "muLogCoeffs<" << Foam::name(PolySize) << '>' << tab + << pt.muCoeffs_/pt.W() << tab + << "kappaLogCoeffs<" << Foam::name(PolySize) << '>' << tab + << pt.kappaCoeffs_/pt.W(); + + os.check + ( + "Ostream& operator<<" + "(" + "Ostream&, " + "const logPolynomialTransport&" + ")" + ); + + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.H b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.H new file mode 100644 index 0000000000..f2a3032c5c --- /dev/null +++ b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.H @@ -0,0 +1,238 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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::logPolynomialTransport + +Description + Transport package using polynomial functions of ln(T) for mu and kappa: + + ln(mu) = sum_i=1^N( a[i] * ln(T)^(i-1) ) + ln(kappa) = sum_i=1^N( b[i] * ln(T)^(i-1) ) + +SourceFiles + logPolynomialTransportI.H + logPolynomialTransport.C + +\*---------------------------------------------------------------------------*/ + +#ifndef logPolynomialTransport_H +#define logPolynomialTransport_H + +#include "Polynomial.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template class logPolynomialTransport; + +template +inline logPolynomialTransport operator+ +( + const logPolynomialTransport&, + const logPolynomialTransport& +); + +template +inline logPolynomialTransport operator- +( + const logPolynomialTransport&, + const logPolynomialTransport& +); + +template +inline logPolynomialTransport operator* +( + const scalar, + const logPolynomialTransport& +); + +template +inline logPolynomialTransport operator== +( + const logPolynomialTransport&, + const logPolynomialTransport& +); + +template +Ostream& operator<< +( + Ostream&, + const logPolynomialTransport& +); + + +/*---------------------------------------------------------------------------*\ + Class logPolynomialTransport Declaration +\*---------------------------------------------------------------------------*/ + +template +class logPolynomialTransport +: + public Thermo +{ + // Private data + + //- Dynamic viscosity polynomial coefficients + // Note: input in [Pa.s], but internally uses [Pa.s/kmol] + Polynomial muCoeffs_; + + //- Thermal conductivity polynomial coefficients + // Note: input in [W/m/K], but internally uses [W/m/K/kmol] + Polynomial kappaCoeffs_; + + + // Private Member Functions + + //- Construct from components + inline logPolynomialTransport + ( + const Thermo& t, + const Polynomial& muPoly, + const Polynomial& kappaPoly + ); + + +public: + + // Constructors + + //- Construct copy + inline logPolynomialTransport(const logPolynomialTransport&); + + //- Construct as named copy + inline logPolynomialTransport + ( + const word&, + const logPolynomialTransport& + ); + + //- Construct from Istream + logPolynomialTransport(Istream& is); + + //- Construct from dictionary + logPolynomialTransport(const dictionary& dict); + + //- Construct and return a clone + inline autoPtr clone() const; + + // Selector from Istream + inline static autoPtr New(Istream& is); + + // Selector from dictionary + inline static autoPtr New + ( + const dictionary& dict + ); + + + // Member functions + + //- Return the instantiated type name + static word typeName() + { + return "logPolynomial<" + Thermo::typeName() + '>'; + } + + //- Dynamic viscosity [kg/ms] + inline scalar mu(const scalar p, const scalar T) const; + + //- Thermal conductivity [W/mK] + inline scalar kappa(const scalar p, const scalar T) const; + + //- Thermal diffusivity of enthalpy [kg/ms] + inline scalar alphah(const scalar p, const scalar T) const; + + // Species diffusivity + //inline scalar D(const scalar p, const scalar T) const; + + //- Write to Ostream + void write(Ostream& os) const; + + + // Member operators + + inline void operator=(const logPolynomialTransport&); + inline void operator+=(const logPolynomialTransport&); + inline void operator-=(const logPolynomialTransport&); + inline void operator*=(const scalar); + + + // Friend operators + + friend logPolynomialTransport operator+ + ( + const logPolynomialTransport&, + const logPolynomialTransport& + ); + + friend logPolynomialTransport operator- + ( + const logPolynomialTransport&, + const logPolynomialTransport& + ); + + friend logPolynomialTransport operator* + ( + const scalar, + const logPolynomialTransport& + ); + + friend logPolynomialTransport operator== + ( + const logPolynomialTransport&, + const logPolynomialTransport& + ); + + + // Ostream Operator + + friend Ostream& operator<< + ( + Ostream&, + const logPolynomialTransport& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "logPolynomialTransportI.H" + +#ifdef NoRepository +# include "logPolynomialTransport.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransportI.H b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransportI.H new file mode 100644 index 0000000000..5bfab1a40f --- /dev/null +++ b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransportI.H @@ -0,0 +1,274 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 . + +\*---------------------------------------------------------------------------*/ + +#include "specie.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::logPolynomialTransport::logPolynomialTransport +( + const logPolynomialTransport& pt +) +: + Thermo(pt), + muCoeffs_(pt.muCoeffs_), + kappaCoeffs_(pt.kappaCoeffs_) +{} + + +template +inline Foam::logPolynomialTransport::logPolynomialTransport +( + const Thermo& t, + const Polynomial& muCoeffs, + const Polynomial& kappaCoeffs +) +: + Thermo(t), + muCoeffs_(muCoeffs), + kappaCoeffs_(kappaCoeffs) +{} + + +template +inline Foam::logPolynomialTransport::logPolynomialTransport +( + const word& name, + const logPolynomialTransport& pt +) +: + Thermo(name, pt), + muCoeffs_(pt.muCoeffs_), + kappaCoeffs_(pt.kappaCoeffs_) +{} + + +template +inline Foam::autoPtr > +Foam::logPolynomialTransport::clone() const +{ + return autoPtr > + ( + new logPolynomialTransport(*this) + ); +} + + +template +inline Foam::autoPtr > +Foam::logPolynomialTransport::New(Istream& is) +{ + return autoPtr > + ( + new logPolynomialTransport(is) + ); +} + + +template +inline Foam::autoPtr > +Foam::logPolynomialTransport::New(const dictionary& dict) +{ + return autoPtr > + ( + new logPolynomialTransport(dict) + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::scalar Foam::logPolynomialTransport::mu +( + const scalar p, + const scalar T +) const +{ + return exp(muCoeffs_.value(log(T))/this->W()); +} + + +template +inline Foam::scalar Foam::logPolynomialTransport::kappa +( + const scalar p, + const scalar T +) const +{ + return exp(kappaCoeffs_.value(log(T))/this->W()); +} + + +template +inline Foam::scalar Foam::logPolynomialTransport::alphah +( + const scalar p, const scalar T +) const +{ + return kappa(p, T)/this->Cpv(p, T); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline void Foam::logPolynomialTransport::operator= +( + const logPolynomialTransport& pt +) +{ + Thermo::operator=(pt); + + muCoeffs_ = pt.muCoeffs_; + kappaCoeffs_ = pt.kappaCoeffs_; +} + + +template +inline void Foam::logPolynomialTransport::operator+= +( + const logPolynomialTransport& pt +) +{ + scalar molr1 = this->nMoles(); + + Thermo::operator+=(pt); + + molr1 /= this->nMoles(); + scalar molr2 = pt.nMoles()/this->nMoles(); + + muCoeffs_ = molr1*muCoeffs_ + molr2*pt.muCoeffs_; + kappaCoeffs_ = molr1*kappaCoeffs_ + molr2*pt.kappaCoeffs_; +} + + +template +inline void Foam::logPolynomialTransport::operator-= +( + const logPolynomialTransport& pt +) +{ + scalar molr1 = this->nMoles(); + + Thermo::operator-=(pt); + + molr1 /= this->nMoles(); + scalar molr2 = pt.nMoles()/this->nMoles(); + + muCoeffs_ = molr1*muCoeffs_ - molr2*pt.muCoeffs_; + kappaCoeffs_ = molr1*kappaCoeffs_ - molr2*pt.kappaCoeffs_; +} + + +template +inline void Foam::logPolynomialTransport::operator*= +( + const scalar s +) +{ + Thermo::operator*=(s); +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +inline Foam::logPolynomialTransport Foam::operator+ +( + const logPolynomialTransport& pt1, + const logPolynomialTransport& pt2 +) +{ + Thermo t + ( + static_cast(pt1) + static_cast(pt2) + ); + + scalar molr1 = pt1.nMoles()/t.nMoles(); + scalar molr2 = pt2.nMoles()/t.nMoles(); + + return logPolynomialTransport + ( + t, + molr1*pt1.muCoeffs_ + molr2*pt2.muCoeffs_, + molr1*pt1.kappaCoeffs_ + molr2*pt2.kappaCoeffs_ + ); +} + + +template +inline Foam::logPolynomialTransport Foam::operator- +( + const logPolynomialTransport& pt1, + const logPolynomialTransport& pt2 +) +{ + Thermo t + ( + static_cast(pt1) - static_cast(pt2) + ); + + scalar molr1 = pt1.nMoles()/t.nMoles(); + scalar molr2 = pt2.nMoles()/t.nMoles(); + + return logPolynomialTransport + ( + t, + molr1*pt1.muCoeffs_ - molr2*pt2.muCoeffs_, + molr1*pt1.kappaCoeffs_ - molr2*pt2.kappaCoeffs_ + ); +} + + +template +inline Foam::logPolynomialTransport Foam::operator* +( + const scalar s, + const logPolynomialTransport& pt +) +{ + return logPolynomialTransport + ( + s*static_cast(pt), + pt.muCoeffs_, + pt.kappaCoeffs_ + ); +} + + +template +inline Foam::logPolynomialTransport Foam::operator== +( + const logPolynomialTransport& pt1, + const logPolynomialTransport& pt2 +) +{ + return pt2 - pt1; +} + + +// ************************************************************************* //