diff --git a/src/thermophysicalModels/specie/Make/files b/src/thermophysicalModels/specie/Make/files index 2f0e008422..ad4f7e0639 100644 --- a/src/thermophysicalModels/specie/Make/files +++ b/src/thermophysicalModels/specie/Make/files @@ -1,13 +1,14 @@ atomicWeights = atomicWeights specie = specie speciesTable = speciesTable -perfectGas = equationOfState/perfectGas +equationOfState = equationOfState reactions = reaction/reactions $(atomicWeights)/atomicWeights.C $(specie)/specie.C $(speciesTable)/speciesTable.C -$(perfectGas)/perfectGas.C +$(equationOfState)/perfectGas/perfectGas.C +$(equationOfState)/icoPolynomial/makeIcoPolynomials.C $(reactions)/makeChemkinReactions.C $(reactions)/makeLangmuirHinshelwoodReactions.C diff --git a/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.C b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.C new file mode 100644 index 0000000000..9fd15c2986 --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "icoPolynomial.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +icoPolynomial::icoPolynomial(Istream& is) +: + specie(is), + rhoPolynomial_("rhoPolynomial", is) +{} + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + +template +Ostream& operator<<(Ostream& os, const icoPolynomial& ip) +{ + os << static_cast(ip); + + os.check + ( + "Ostream& operator<<(Ostream& os, const icoPolynomial& ip)" + ); + + return os; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.H b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.H new file mode 100644 index 0000000000..b23de491d1 --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.H @@ -0,0 +1,214 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::icoPolynomial + +Description + Incompressible, polynomial form of equation of state, using a polynomial + function for density. + +SourceFiles + icoPolynomialI.H + icoPolynomial.C + +\*---------------------------------------------------------------------------*/ + +#ifndef icoPolynomial_H +#define icoPolynomial_H + +#include "specie.H" +#include "autoPtr.H" +#include "Polynomial.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template +class icoPolynomial; + +template +icoPolynomial operator+ +( + const icoPolynomial&, + const icoPolynomial& +); + +template +icoPolynomial operator- +( + const icoPolynomial&, + const icoPolynomial& +); + +template +icoPolynomial operator* +( + const scalar, + const icoPolynomial& +); + +template +icoPolynomial operator== +( + const icoPolynomial&, + const icoPolynomial& +); + +template +Ostream& operator<< +( + Ostream&, + const icoPolynomial& +); + + +/*---------------------------------------------------------------------------*\ + Class icoPolynomial Declaration +\*---------------------------------------------------------------------------*/ + +template +class icoPolynomial +: + public specie +{ + // Private data + + //- Density + Polynomial rhoPolynomial_; + + +public: + + TypeName("icoPolynomial") + + // Constructors + + //- Construct from components + inline icoPolynomial + ( + const specie& sp, + const Polynomial& rhoPoly + ); + + //- Construct from Istream + icoPolynomial(Istream&); + + //- Construct as named copy + inline icoPolynomial(const word& name, const icoPolynomial&); + + //- Construct and return a clone + inline autoPtr clone() const; + + // Selector from Istream + inline static autoPtr New(Istream& is); + + + // Member functions + + //- Return density [kg/m^3] + inline scalar rho(scalar p, scalar T) const; + + //- Return compressibility rho/p [s^2/m^2] + inline scalar psi(scalar p, scalar T) const; + + //- Return compression factor [] + inline scalar Z(scalar p, scalar T) const; + + + // Member operators + + inline void operator+=(const icoPolynomial&); + inline void operator-=(const icoPolynomial&); + + inline void operator*=(const scalar); + + + // Friend operators + + friend icoPolynomial operator+ + ( + const icoPolynomial&, + const icoPolynomial& + ); + + friend icoPolynomial operator- + ( + const icoPolynomial&, + const icoPolynomial& + ); + + friend icoPolynomial operator* + ( + const scalar s, + const icoPolynomial& + ); + + friend icoPolynomial operator== + ( + const icoPolynomial&, + const icoPolynomial& + ); + + + // Ostream Operator + + friend Ostream& operator<< (Ostream&, const icoPolynomial&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeIcoPolynomial(PolySize) \ + \ +defineTemplateTypeNameAndDebugWithName \ +( \ + icoPolynomial, \ + "icoPolynomial<"#PolySize">", \ + 0 \ +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "icoPolynomialI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "icoPolynomial.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomialI.H b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomialI.H new file mode 100644 index 0000000000..d174c57192 --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomialI.H @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "icoPolynomial.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +inline Foam::icoPolynomial::icoPolynomial +( + const specie& sp, + const Polynomial& rhoPoly +) +: + specie(sp), + rhoPolynomial_(rhoPoly) +{} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::icoPolynomial::icoPolynomial +( + const word& name, + const icoPolynomial& ip +) +: + specie(name, ip), + rhoPolynomial_(ip.rhoPolynomial_) +{} + + +template +inline Foam::autoPtr > +Foam::icoPolynomial::clone() const +{ + return autoPtr > + ( + new icoPolynomial(*this) + ); +} + + +template +inline Foam::autoPtr > +Foam::icoPolynomial::New(Istream& is) +{ + return autoPtr >(new icoPolynomial(is)); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::scalar Foam::icoPolynomial::rho(scalar, scalar T) const +{ + return rhoPolynomial_.evaluate(T); +} + + +template +inline Foam::scalar Foam::icoPolynomial::psi(scalar, scalar) const +{ + return 0.0; +} + + +template +inline Foam::scalar Foam::icoPolynomial::Z(scalar, scalar) const +{ + return 0.0; +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline void Foam::icoPolynomial::operator+= +( + const icoPolynomial& ip +) +{ + scalar molr1 = this->nMoles(); + + specie::operator+=(ip); + + molr1 /= this->nMoles(); + scalar molr2 = ip.nMoles()/this->nMoles(); + + rhoPolynomial_ = molr1*rhoPolynomial_ + molr2*ip.rhoPolynomial_; +} + + +template +inline void Foam::icoPolynomial::operator-= +( + const icoPolynomial& ip +) +{ + scalar molr1 = this->nMoles(); + specie::operator-=(ip); + + molr1 /= this->nMoles(); + scalar molr2 = ip.nMoles()/this->nMoles(); + + rhoPolynomial_ = molr1*rhoPolynomial_ - molr2*ip.rhoPolynomial_; +} + + +template +inline void Foam::icoPolynomial::operator*=(const scalar s) +{ + specie::operator*=(s); +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +Foam::icoPolynomial Foam::operator+ +( + const icoPolynomial& ip1, + const icoPolynomial& ip2 +) +{ + scalar mol1 = ip1.nMoles(); + scalar mol2 = ip2.nMoles(); + scalar nMoles = mol1 + mol2; + + return icoPolynomial + ( + static_cast(ip1) + + static_cast(ip2), + (mol1/nMoles)*ip1.rhoPolynomial_ + (mol2/nMoles)*ip2.rhoPolynomial_ + ); +} + + +template +Foam::icoPolynomial Foam::operator- +( + const icoPolynomial& ip1, + const icoPolynomial& ip2 +) +{ + scalar mol1 = ip1.nMoles(); + scalar mol2 = ip2.nMoles(); + scalar nMoles = mol1 + mol2; + + return icoPolynomial + ( + static_cast(ip1) + - static_cast(ip2), + (mol1/nMoles)*ip1.rhoPolynomial_ - (mol2/nMoles)*ip2.rhoPolynomial_ + ); +} + + +template +Foam::icoPolynomial Foam::operator* +( + const scalar s, + const icoPolynomial& ip +) +{ + return icoPolynomial + ( + s*static_cast(ip), + ip.rhoPolynomial_ + ); +} + + +template +Foam::icoPolynomial Foam::operator== +( + const icoPolynomial& ip1, + const icoPolynomial& ip2 +) +{ + return ip2 - ip1; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/equationOfState/icoPolynomial/makeIcoPolynomials.C b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/makeIcoPolynomials.C new file mode 100644 index 0000000000..e4136284c0 --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/makeIcoPolynomials.C @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "icoPolynomial.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makeIcoPolynomial(1) + makeIcoPolynomial(2) + makeIcoPolynomial(3) + makeIcoPolynomial(4) + makeIcoPolynomial(5) + makeIcoPolynomial(6) + makeIcoPolynomial(7) + makeIcoPolynomial(8) +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermo.C b/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermo.C new file mode 100644 index 0000000000..d8a2e19861 --- /dev/null +++ b/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermo.C @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "polynomialThermo.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::polynomialThermo::polynomialThermo(Istream& is) +: + EquationOfState(is), + Hf_(readScalar(is)), + cpPolynomial_("cpPolynomial", is), + dhPolynomial_("dhPolynomial", cpPolynomial_.integrate()) +{} + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const polynomialThermo& pt +) +{ + os << static_cast(pt) << tab << pt.Hf_; + + os.check + ( + "operator<<(Ostream& os, const polynomialThermo& pt)" + ); + + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermo.H b/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermo.H new file mode 100644 index 0000000000..903cf1d2db --- /dev/null +++ b/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermo.H @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::polynomialThermo + +Description + Thermodynamics package templated on the equation of state, using polynomial + functions for cp and h + +SourceFiles + polynomialThermoI.H + polynomialThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef polynomialThermo_H +#define polynomialThermo_H + +#include "scalar.H" +#include "Polynomial.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template +class polynomialThermo; + +template +inline polynomialThermo operator+ +( + const polynomialThermo&, + const polynomialThermo& +); + +template +inline polynomialThermo operator- +( + const polynomialThermo&, + const polynomialThermo& +); + +template +inline polynomialThermo operator* +( + const scalar, + const polynomialThermo& +); + +template +inline polynomialThermo operator== +( + const polynomialThermo&, + const polynomialThermo& +); + +template +Ostream& operator<< +( + Ostream&, + const polynomialThermo& +); + + +/*---------------------------------------------------------------------------*\ + Class polynomialThermo Declaration +\*---------------------------------------------------------------------------*/ + +template +class polynomialThermo +: + public EquationOfState +{ + // Private data + + //- Heat of formation + scalar Hf_; + + //- Specific heat at constant pressure + Polynomial cpPolynomial_; + + //- Enthalpy - derived from cp + typename Polynomial::intPolyType dhPolynomial_; + + + // Private member functions + + //- Construct from components + inline polynomialThermo + ( + const EquationOfState& pt, + const scalar Hf, + const Polynomial& cpPoly, + const typename Polynomial::intPolyType& hPoly + ); + + +public: + + // Constructors + + //- Construct from dictionary + polynomialThermo(Istream& is); + + //- Construct as a named copy + inline polynomialThermo(const word&, const polynomialThermo&); + + + // Member Functions + + //- Heat capacity at constant pressure [J/(kmol K)] + inline scalar cp(const scalar T) const; + + //- Enthalpy [J/kmol] + inline scalar h(const scalar T) const; + + //- Sensible enthalpy [J/kmol] + inline scalar hs(const scalar T) const; + + //- Chemical enthalpy [J/kmol] + inline scalar hc() const; + + //- Entropy [J/(kmol K)] + inline scalar s(const scalar T) const; + + + // Member operators + + inline void operator+=(const polynomialThermo&); + inline void operator-=(const polynomialThermo&); + + + // Friend operators + + friend polynomialThermo operator+ + ( + const polynomialThermo&, + const polynomialThermo& + ); + + friend polynomialThermo operator- + ( + const polynomialThermo&, + const polynomialThermo& + ); + + friend polynomialThermo operator* + ( + const scalar, + const polynomialThermo& + ); + + friend polynomialThermo operator== + ( + const polynomialThermo&, + const polynomialThermo& + ); + + + // Ostream Operator + + friend Ostream& operator<< + ( + Ostream&, + const polynomialThermo& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "polynomialThermoI.H" + +#ifdef NoRepository +# include "polynomialThermo.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermoI.H b/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermoI.H new file mode 100644 index 0000000000..a34f9fda80 --- /dev/null +++ b/src/thermophysicalModels/specie/thermo/polynomial/polynomialThermoI.H @@ -0,0 +1,235 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "polynomialThermo.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +inline Foam::polynomialThermo::polynomialThermo +( + const EquationOfState& pt, + const scalar Hf, + const Polynomial& cpPoly, + const typename Polynomial::intPolyType& dhPoly +) +: + EquationOfState(pt), + Hf_(Hf), + cpPolynomial_(cpPoly), + dhPolynomial_(dhPoly) +{} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::polynomialThermo::polynomialThermo +( + const word& name, + const polynomialThermo& pt +) +: + EquationOfState(name, pt), + Hf_(pt.Hf_), + cpPolynomial_(pt.cpPolynomial_), + dhPolynomial_(pt.dhPolynomial_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::scalar Foam::polynomialThermo::cp +( + const scalar T +) const +{ + return cpPolynomial_.evaluate(T)*this->W(); +} + + +template +inline Foam::scalar Foam::polynomialThermo::h +( + const scalar T +) const +{ + return (dhPolynomial_.evaluate(T) + Hf_)*this->W(); +} + + +template +inline Foam::scalar Foam::polynomialThermo::hs +( + const scalar T +) const +{ + return dhPolynomial_.evaluate(T)*this->W(); +} + + +template +inline Foam::scalar Foam::polynomialThermo::hc() +const +{ + return Hf_*this->W(); +} + + +template +inline Foam::scalar Foam::polynomialThermo::s +( + const scalar T +) const +{ + notImplemented("scalar polynomialThermo::s"); + + return 0.0; +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline void Foam::polynomialThermo::operator+= +( + const polynomialThermo& pt +) +{ + scalar molr1 = this->nMoles(); + + EquationOfState::operator+=(pt); + + molr1 /= this->nMoles(); + scalar molr2 = pt.nMoles()/this->nMoles(); + + Hf_ = molr1*Hf_ + molr2*pt.Hf_; + cpPolynomial_ = molr1*cpPolynomial_ + molr2*pt.cpPolynomial_; + dhPolynomial_ = molr1*dhPolynomial_ + molr2*pt.dhPolynomial_; +} + + +template +inline void Foam::polynomialThermo::operator-= +( + const polynomialThermo& pt +) +{ + scalar molr1 = this->nMoles(); + + EquationOfState::operator-=(pt); + + molr1 /= this->nMoles(); + scalar molr2 = pt.nMoles()/this->nMoles(); + + Hf_ = molr1*Hf_ - molr2*pt.Hf_; + cpPolynomial_ = molr1*cpPolynomial_ - molr2*pt.cpPolynomial_; + dhPolynomial_ = molr1*dhPolynomial_ - molr2*pt.dhPolynomial_; +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +inline Foam::polynomialThermo Foam::operator+ +( + const polynomialThermo& pt1, + const polynomialThermo& pt2 +) +{ + EquationOfState eofs + ( + static_cast(pt1) + + static_cast(pt2) + ); + + scalar molr1 = pt1.nMoles()/eofs.nMoles(); + scalar molr2 = pt2.nMoles()/eofs.nMoles(); + return polynomialThermo + ( + eofs, + molr1*pt1.Hf_ + molr2*pt2.Hf_, + molr1*pt1.cpPolynomial_ + molr2*pt2.cpPolynomial_, + molr1*pt1.dhPolynomial_ + molr2*pt2.dhPolynomial_ + ); +} + + +template +inline Foam::polynomialThermo Foam::operator- +( + const polynomialThermo& pt1, + const polynomialThermo& pt2 +) +{ + EquationOfState eofs + ( + static_cast(pt1) + - static_cast(pt2) + ); + + scalar molr1 = pt1.nMoles()/eofs.nMoles(); + scalar molr2 = pt2.nMoles()/eofs.nMoles(); + return polynomialThermo + ( + eofs, + molr1*pt1.Hf_ - molr2*pt2.Hf_, + molr1*pt1.cpPolynomial_ - molr2*pt2.cpPolynomial_, + molr1*pt1.dhPolynomial_ - molr2*pt2.dhPolynomial_ + ); +} + + +template +inline Foam::polynomialThermo Foam::operator* +( + const scalar s, + const polynomialThermo& pt +) +{ + return polynomialThermo + ( + s*static_cast(pt), + pt.Hf_, + pt.cpPolynomial_, + pt.dhPolynomial_ + ); +} + + +template +inline Foam::polynomialThermo Foam::operator== +( + const polynomialThermo& pt1, + const polynomialThermo& pt2 +) +{ + return pt2 - pt1; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C new file mode 100644 index 0000000000..2744d4a979 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "polynomialTransport.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::polynomialTransport::polynomialTransport(Istream& is) +: + Thermo(is), + muPolynomial_("muPolynomial", is), + kappaPolynomial_("kappaPolynomial", is) +{} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const polynomialTransport& pt +) +{ + os << static_cast(pt); + + os.check + ( + "Ostream& operator<<" + "(" + "Ostream&, " + "const polynomialTransport&" + ")" + ); + + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.H b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.H new file mode 100644 index 0000000000..3ab3879e64 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.H @@ -0,0 +1,206 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::polynomialTransport + +Description + Transport package using polynomial functions for mu and kappa + +SourceFiles + polynomialTransportI.H + polynomialTransport.C + +\*---------------------------------------------------------------------------*/ + +#ifndef polynomialTransport_H +#define polynomialTransport_H + +#include "Polynomial.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template class polynomialTransport; + +template +inline polynomialTransport operator+ +( + const polynomialTransport&, + const polynomialTransport& +); + +template +inline polynomialTransport operator- +( + const polynomialTransport&, + const polynomialTransport& +); + +template +inline polynomialTransport operator* +( + const scalar, + const polynomialTransport& +); + +template +inline polynomialTransport operator== +( + const polynomialTransport&, + const polynomialTransport& +); + +template +Ostream& operator<< +( + Ostream&, + const polynomialTransport& +); + + +/*---------------------------------------------------------------------------*\ + Class polynomialTransport Declaration +\*---------------------------------------------------------------------------*/ + +template +class polynomialTransport +: + public Thermo +{ + // Private data + + //- Dynamic viscosity + Polynomial muPolynomial_; + + //- Thermal conductivity + Polynomial kappaPolynomial_; + + + // Private member functions + + //- Construct from components + inline polynomialTransport + ( + const Thermo& t, + const Polynomial& muPoly, + const Polynomial& kappaPoly + ); + + +public: + + // Constructors + + //- Construct as named copy + inline polynomialTransport(const word&, const polynomialTransport&); + + //- Construct from Istream + polynomialTransport(Istream& is); + + //- Construct and return a clone + inline autoPtr clone() const; + + // Selector from Istream + inline static autoPtr New(Istream& is); + + + // Member functions + + //- Dynamic viscosity [kg/ms] + inline scalar mu(const scalar T) const; + + //- Thermal conductivity [W/mK] + inline scalar kappa(const scalar T) const; + + //- Thermal diffusivity for enthalpy [kg/ms] + inline scalar alpha(const scalar T) const; + + // Species diffusivity + //inline scalar D(const scalar T) const; + + + // Member operators + + inline polynomialTransport& operator=(const polynomialTransport&); + + + // Friend operators + + friend polynomialTransport operator+ + ( + const polynomialTransport&, + const polynomialTransport& + ); + + friend polynomialTransport operator- + ( + const polynomialTransport&, + const polynomialTransport& + ); + + friend polynomialTransport operator* + ( + const scalar, + const polynomialTransport& + ); + + friend polynomialTransport operator== + ( + const polynomialTransport&, + const polynomialTransport& + ); + + + // Ostream Operator + + friend Ostream& operator<< + ( + Ostream&, + const polynomialTransport& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "polynomialTransportI.H" + +#ifdef NoRepository +# include "polynomialTransport.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/polynomial/polynomialTransportI.H b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransportI.H new file mode 100644 index 0000000000..9e6e00e6e3 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransportI.H @@ -0,0 +1,213 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "specie.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::polynomialTransport::polynomialTransport +( + const Thermo& t, + const Polynomial& muPoly, + const Polynomial& kappaPoly +) +: + Thermo(t), + muPolynomial_(muPoly), + kappaPolynomial_(kappaPoly) +{} + + +template +inline Foam::polynomialTransport::polynomialTransport +( + const word& name, + const polynomialTransport& pt +) +: + Thermo(name, pt), + muPolynomial_(pt.muPolynomial_), + kappaPolynomial_(pt.kappaPolynomial_) +{} + + +template +inline Foam::autoPtr > +Foam::polynomialTransport::clone() const +{ + return autoPtr > + ( + new polynomialTransport(*this) + ); +} + + +template +inline Foam::autoPtr > +Foam::polynomialTransport::New(Istream& is) +{ + return autoPtr > + ( + new polynomialTransport(is) + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::scalar Foam::polynomialTransport::mu +( + const scalar T +) const +{ + return muPolynomial_.evaluate(T); +} + + +template +inline Foam::scalar Foam::polynomialTransport::kappa +( + const scalar T +) const +{ + return kappaPolynomial_.evaluate(T); +} + + +template +inline Foam::scalar Foam::polynomialTransport::alpha +( + const scalar T +) const +{ + scalar deltaT = T - specie::Tstd; + scalar CpBar = + (deltaT*(this->H(T) - this->H(specie::Tstd)) + this->Cp(T)) + /(sqr(deltaT) + 1); + + return kappa(T)/CpBar; +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline Foam::polynomialTransport& +Foam::polynomialTransport::operator= +( + const polynomialTransport& pt +) +{ + Thermo::operator=(pt); + + muPolynomial_ = pt.muPolynomial_; + kappaPolynomial_ = pt.kappaPolynomial_; + + return *this; +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +inline Foam::polynomialTransport Foam::operator+ +( + const polynomialTransport& pt1, + const polynomialTransport& pt2 +) +{ + Thermo t + ( + static_cast(pt1) + static_cast(pt2) + ); + + + scalar molr1 = pt1.nMoles()/t.nMoles(); + scalar molr2 = pt2.nMoles()/t.nMoles(); + + return polynomialTransport + ( + t, + molr1*pt1.muPolynomial_ + molr2*pt2.muPolynomial_, + molr1*pt1.kappaPolynomial_ + molr2*pt2.kappaPolynomial_ + ); +} + + +template +inline Foam::polynomialTransport Foam::operator- +( + const polynomialTransport& pt1, + const polynomialTransport& pt2 +) +{ + Thermo t + ( + static_cast(pt1) - static_cast(pt2) + ); + + scalar molr1 = pt1.nMoles()/t.nMoles(); + scalar molr2 = pt2.nMoles()/t.nMoles(); + + return polynomialTransport + ( + t, + molr1*pt1.muPolynomial_ - molr2*pt2.muPolynomial_, + molr1*pt1.kappaPolynomial_ - molr2*pt2.kappaPolynomial_ + ); +} + + +template +inline Foam::polynomialTransport Foam::operator* +( + const scalar s, + const polynomialTransport& pt +) +{ + return polynomialTransport + ( + s*static_cast(pt), + pt.muPolynomial_, + pt.kappaPolynomial_ + ); +} + + +template +inline Foam::polynomialTransport Foam::operator== +( + const polynomialTransport& pt1, + const polynomialTransport& pt2 +) +{ + return pt2 - pt1; +} + + +// ************************************************************************* //