1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 Foam::hPolynomialThermo
28 Thermodynamics package templated on the equation of state, using polynomial
29 functions for cp, h and s
31 Polynomials for h and s derived from cp
37 \*---------------------------------------------------------------------------*/
39 #ifndef hPolynomialThermo_H
40 #define hPolynomialThermo_H
43 #include "Polynomial.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 // Forward declaration of friend functions and operators
52 template<class EquationOfState, int PolySize>
53 class hPolynomialThermo;
55 template<class EquationOfState, int PolySize>
56 inline hPolynomialThermo<EquationOfState, PolySize> operator+
58 const hPolynomialThermo<EquationOfState, PolySize>&,
59 const hPolynomialThermo<EquationOfState, PolySize>&
62 template<class EquationOfState, int PolySize>
63 inline hPolynomialThermo<EquationOfState, PolySize> operator-
65 const hPolynomialThermo<EquationOfState, PolySize>&,
66 const hPolynomialThermo<EquationOfState, PolySize>&
69 template<class EquationOfState, int PolySize>
70 inline hPolynomialThermo<EquationOfState, PolySize> operator*
73 const hPolynomialThermo<EquationOfState, PolySize>&
76 template<class EquationOfState, int PolySize>
77 inline hPolynomialThermo<EquationOfState, PolySize> operator==
79 const hPolynomialThermo<EquationOfState, PolySize>&,
80 const hPolynomialThermo<EquationOfState, PolySize>&
83 template<class EquationOfState, int PolySize>
87 const hPolynomialThermo<EquationOfState, PolySize>&
91 /*---------------------------------------------------------------------------*\
92 Class hPolynomialThermo Declaration
93 \*---------------------------------------------------------------------------*/
95 template<class EquationOfState, int PolySize>
96 class hPolynomialThermo
98 public EquationOfState
102 //- Heat of formation
103 // Note: input in [J/kg], but internally uses [J/kmol]
107 // Note: input in [J/kg/K], but internally uses [J/kmol/K]
110 //- Specific heat at constant pressure polynomial coeffs [J/(kg.K)]
111 Polynomial<PolySize> CpCoeffs_;
113 //- Enthalpy polynomial coeffs - derived from cp [J/kg]
114 // NOTE: relative to Tstd
115 typename Polynomial<PolySize>::intPolyType hCoeffs_;
117 //- Entropy - derived from Cp [J/(kg.K)] - relative to Tstd
118 Polynomial<PolySize> sCoeffs_;
121 // Private Member Functions
123 //- Construct from components
124 inline hPolynomialThermo
126 const EquationOfState& pt,
129 const Polynomial<PolySize>& CpCoeffs,
130 const typename Polynomial<PolySize>::intPolyType& hCoeffs,
131 const Polynomial<PolySize>& sCoeffs
139 //- Construct from Istream
140 hPolynomialThermo(Istream& is);
142 //- Construct from dictionary
143 hPolynomialThermo(const dictionary& dict);
145 //- Construct as copy
146 inline hPolynomialThermo(const hPolynomialThermo&);
148 //- Construct as a named copy
149 inline hPolynomialThermo(const word&, const hPolynomialThermo&);
154 //- Limit the temperature to be in the range Tlow_ to Thigh_
155 inline scalar limit(const scalar T) const;
157 // Fundamental properties
159 //- Heat capacity at constant pressure [J/(kmol K)]
160 inline scalar cp(const scalar T) const;
162 //- Enthalpy [J/kmol]
163 inline scalar h(const scalar T) const;
165 //- Sensible enthalpy [J/kmol]
166 inline scalar hs(const scalar T) const;
168 //- Chemical enthalpy [J/kmol]
169 inline scalar hc() const;
171 //- Entropy [J/(kmol K)]
172 inline scalar s(const scalar T) const;
178 void write(Ostream& os) const;
183 inline hPolynomialThermo& operator=(const hPolynomialThermo&);
184 inline void operator+=(const hPolynomialThermo&);
185 inline void operator-=(const hPolynomialThermo&);
186 inline void operator*=(const scalar);
191 friend hPolynomialThermo operator+ <EquationOfState, PolySize>
193 const hPolynomialThermo&,
194 const hPolynomialThermo&
197 friend hPolynomialThermo operator- <EquationOfState, PolySize>
199 const hPolynomialThermo&,
200 const hPolynomialThermo&
203 friend hPolynomialThermo operator* <EquationOfState, PolySize>
206 const hPolynomialThermo&
209 friend hPolynomialThermo operator== <EquationOfState, PolySize>
211 const hPolynomialThermo&,
212 const hPolynomialThermo&
218 friend Ostream& operator<< <EquationOfState, PolySize>
221 const hPolynomialThermo&
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 } // End namespace Foam
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 #include "hPolynomialThermoI.H"
235 # include "hPolynomialThermo.C"
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 // ************************************************************************* //