Commit 62eb0e15 authored by Henry Weller's avatar Henry Weller
Browse files

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
parent 65f94fbc
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "logPolynomialTransport.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo, int PolySize>
Foam::logPolynomialTransport<Thermo, PolySize>::logPolynomialTransport
(
Istream& is
)
:
Thermo(is),
muCoeffs_("muLogCoeffs<" + Foam::name(PolySize) + '>', is),
kappaCoeffs_("kappaLogCoeffs<" + Foam::name(PolySize) + '>', is)
{
muCoeffs_ *= this->W();
kappaCoeffs_ *= this->W();
}
template<class Thermo, int PolySize>
Foam::logPolynomialTransport<Thermo, PolySize>::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<class Thermo, int PolySize>
void Foam::logPolynomialTransport<Thermo, PolySize>::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<class Thermo, int PolySize>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const logPolynomialTransport<Thermo, PolySize>& pt
)
{
os << static_cast<const Thermo&>(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<Thermo, PolySize>&"
")"
);
return os;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
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 Thermo, int PolySize> class logPolynomialTransport;
template<class Thermo, int PolySize>
inline logPolynomialTransport<Thermo, PolySize> operator+
(
const logPolynomialTransport<Thermo, PolySize>&,
const logPolynomialTransport<Thermo, PolySize>&
);
template<class Thermo, int PolySize>
inline logPolynomialTransport<Thermo, PolySize> operator-
(
const logPolynomialTransport<Thermo, PolySize>&,
const logPolynomialTransport<Thermo, PolySize>&
);
template<class Thermo, int PolySize>
inline logPolynomialTransport<Thermo, PolySize> operator*
(
const scalar,
const logPolynomialTransport<Thermo, PolySize>&
);
template<class Thermo, int PolySize>
inline logPolynomialTransport<Thermo, PolySize> operator==
(
const logPolynomialTransport<Thermo, PolySize>&,
const logPolynomialTransport<Thermo, PolySize>&
);
template<class Thermo, int PolySize>
Ostream& operator<<
(
Ostream&,
const logPolynomialTransport<Thermo, PolySize>&
);
/*---------------------------------------------------------------------------*\
Class logPolynomialTransport Declaration
\*---------------------------------------------------------------------------*/
template<class Thermo, int PolySize=8>
class logPolynomialTransport
:
public Thermo
{
// Private data
//- Dynamic viscosity polynomial coefficients
// Note: input in [Pa.s], but internally uses [Pa.s/kmol]
Polynomial<PolySize> muCoeffs_;
//- Thermal conductivity polynomial coefficients
// Note: input in [W/m/K], but internally uses [W/m/K/kmol]
Polynomial<PolySize> kappaCoeffs_;
// Private Member Functions
//- Construct from components
inline logPolynomialTransport
(
const Thermo& t,
const Polynomial<PolySize>& muPoly,
const Polynomial<PolySize>& 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<logPolynomialTransport> clone() const;
// Selector from Istream
inline static autoPtr<logPolynomialTransport> New(Istream& is);
// Selector from dictionary
inline static autoPtr<logPolynomialTransport> 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+ <Thermo, PolySize>
(
const logPolynomialTransport&,
const logPolynomialTransport&
);
friend logPolynomialTransport operator- <Thermo, PolySize>
(
const logPolynomialTransport&,
const logPolynomialTransport&
);
friend logPolynomialTransport operator* <Thermo, PolySize>
(
const scalar,
const logPolynomialTransport&
);
friend logPolynomialTransport operator== <Thermo, PolySize>
(
const logPolynomialTransport&,
const logPolynomialTransport&
);
// Ostream Operator
friend Ostream& operator<< <Thermo, PolySize>
(
Ostream&,
const logPolynomialTransport&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "logPolynomialTransportI.H"
#ifdef NoRepository
# include "logPolynomialTransport.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "specie.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo, int PolySize>
inline Foam::logPolynomialTransport<Thermo, PolySize>::logPolynomialTransport
(
const logPolynomialTransport& pt
)
:
Thermo(pt),
muCoeffs_(pt.muCoeffs_),
kappaCoeffs_(pt.kappaCoeffs_)
{}
template<class Thermo, int PolySize>
inline Foam::logPolynomialTransport<Thermo, PolySize>::logPolynomialTransport
(
const Thermo& t,
const Polynomial<PolySize>& muCoeffs,
const Polynomial<PolySize>& kappaCoeffs
)
:
Thermo(t),
muCoeffs_(muCoeffs),
kappaCoeffs_(kappaCoeffs)
{}
template<class Thermo, int PolySize>
inline Foam::logPolynomialTransport<Thermo, PolySize>::logPolynomialTransport
(
const word& name,
const logPolynomialTransport& pt
)
:
Thermo(name, pt),
muCoeffs_(pt.muCoeffs_),
kappaCoeffs_(pt.kappaCoeffs_)
{}
template<class Thermo, int PolySize>
inline Foam::autoPtr<Foam::logPolynomialTransport<Thermo, PolySize> >
Foam::logPolynomialTransport<Thermo, PolySize>::clone() const
{
return autoPtr<logPolynomialTransport<Thermo, PolySize> >
(
new logPolynomialTransport<Thermo, PolySize>(*this)
);
}
template<class Thermo, int PolySize>
inline Foam::autoPtr<Foam::logPolynomialTransport<Thermo, PolySize> >
Foam::logPolynomialTransport<Thermo, PolySize>::New(Istream& is)
{
return autoPtr<logPolynomialTransport<Thermo, PolySize> >
(
new logPolynomialTransport<Thermo, PolySize>(is)
);
}
template<class Thermo, int PolySize>
inline Foam::autoPtr<Foam::logPolynomialTransport<Thermo, PolySize> >
Foam::logPolynomialTransport<Thermo, PolySize>::New(const dictionary& dict)
{
return autoPtr<logPolynomialTransport<Thermo, PolySize> >
(
new logPolynomialTransport<Thermo, PolySize>(dict)
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Thermo, int PolySize>
inline Foam::scalar Foam::logPolynomialTransport<Thermo, PolySize>::mu
(
const scalar p,
const scalar T
) const
{
return exp(muCoeffs_.value(log(T))/this->W());
}
template<class Thermo, int PolySize>
inline Foam::scalar Foam::logPolynomialTransport<Thermo, PolySize>::kappa
(
const scalar p,
const scalar T
) const
{
return exp(kappaCoeffs_.value(log(T))/this->W());
}
template<class Thermo, int PolySize>
inline Foam::scalar Foam::logPolynomialTransport<Thermo, PolySize>::alphah
(
const scalar p, const scalar T
) const
{
return kappa(p, T)/this->Cpv(p, T);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Thermo, int PolySize>
inline void Foam::logPolynomialTransport<Thermo, PolySize>::operator=
(
const logPolynomialTransport<Thermo, PolySize>& pt
)
{
Thermo::operator=(pt);
muCoeffs_ = pt.muCoeffs_;
kappaCoeffs_ = pt.kappaCoeffs_;
}
template<class Thermo, int PolySize>
inline void Foam::logPolynomialTransport<Thermo, PolySize>::operator+=
(
const logPolynomialTransport<Thermo, PolySize>& 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<class Thermo, int PolySize>
inline void Foam::logPolynomialTransport<Thermo, PolySize>::operator-=
(
const logPolynomialTransport<Thermo, PolySize>& 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<class Thermo, int PolySize>
inline void Foam::logPolynomialTransport<Thermo, PolySize>::operator*=
(
const scalar s
)
{
Thermo::operator*=(s);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class Thermo, int PolySize>
inline Foam::logPolynomialTransport<Thermo, PolySize> Foam::operator+
(
const logPolynomialTransport<Thermo, PolySize>& pt1,
const logPolynomialTransport<Thermo, PolySize>& pt2
)
{
Thermo t
(
static_cast<const Thermo&>(pt1) + static_cast<const Thermo&>(pt2)
);
scalar molr1 = pt1.nMoles()/t.nMoles();
scalar molr2 = pt2.nMoles()/t.nMoles();
return logPolynomialTransport<Thermo, PolySize>
(
t,
molr1*pt1.muCoeffs_ + molr2*pt2.muCoeffs_,
molr1*pt1.kappaCoeffs_ + molr2*pt2.kappaCoeffs_
);
}