ePolynomialThermo.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::ePolynomialThermo
26 
27 Description
28  Internal energy based thermodynamics package using a polynomial function
29  of temperature for the constant heat capacity at constant volume:
30 
31  \verbatim
32  Cv = CvCoeffs[0] + CvCoeffs[1]*T + CvCoeffs[2]*sqr(T)
33  + CvCoeffs[3]*pow3(T) + CvCoeffs[4]*pow4(T)
34  + CvCoeffs[5]*pow(T, 5) + CvCoeffs[6]*pow(T, 6)
35  + CvCoeffs[7]*pow(T, 7)
36  \endverbatim
37 
38  The polynomial function is templated on the order of the polynomial which
39  defaults to 8.
40 
41 Usage
42  \table
43  Property | Description
44  Hf | Heat of formation
45  Sf | Standard entropy
46  CvCoeffs<8> | Specific heat at constant volume polynomial coeffs
47  \endtable
48 
49  Example of the specification of the thermodynamic properties:
50  \verbatim
51  thermodynamics
52  {
53  Hf 0;
54  Sf 0;
55  CvCoeffs<8> (1000 -0.05 0.003 0 0 0 0 0);
56  }
57  \endverbatim
58 
59  Note:
60  Specific heat at constant volume polynomial coefficients evaluate to an
61  expression in [J/kg/K].
62 
63 SourceFiles
64  ePolynomialThermoI.H
65  ePolynomialThermo.C
66 
67 See also
68  Foam::Polynomial
69 
70 \*---------------------------------------------------------------------------*/
71 
72 #ifndef ePolynomialThermo_H
73 #define ePolynomialThermo_H
74 
75 #include "scalar.H"
76 #include "Polynomial.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 
83 // Forward declaration of friend functions and operators
84 
85 template<class EquationOfState, int PolySize>
86 class ePolynomialThermo;
87 
88 template<class EquationOfState, int PolySize>
89 inline ePolynomialThermo<EquationOfState, PolySize> operator+
90 (
91  const ePolynomialThermo<EquationOfState, PolySize>&,
92  const ePolynomialThermo<EquationOfState, PolySize>&
93 );
94 
95 template<class EquationOfState, int PolySize>
96 inline ePolynomialThermo<EquationOfState, PolySize> operator*
97 (
98  const scalar,
99  const ePolynomialThermo<EquationOfState, PolySize>&
100 );
101 
102 template<class EquationOfState, int PolySize>
103 inline ePolynomialThermo<EquationOfState, PolySize> operator==
104 (
105  const ePolynomialThermo<EquationOfState, PolySize>&,
106  const ePolynomialThermo<EquationOfState, PolySize>&
107 );
108 
109 template<class EquationOfState, int PolySize>
110 Ostream& operator<<
111 (
112  Ostream&,
113  const ePolynomialThermo<EquationOfState, PolySize>&
114 );
115 
116 
117 /*---------------------------------------------------------------------------*\
118  Class ePolynomialThermo Declaration
119 \*---------------------------------------------------------------------------*/
120 
121 template<class EquationOfState, int PolySize=8>
122 class ePolynomialThermo
123 :
124  public EquationOfState
125 {
126  // Private Data
127 
128  //- Heat of formation
129  scalar Hf_;
130 
131  //- Standard entropy
132  scalar Sf_;
133 
134  //- Specific heat at constant volume polynomial coeffs [J/kg/K/K^i]
135  Polynomial<PolySize> CvCoeffs_;
136 
137  //- Internal energy polynomial coeffs [J/kg/K^i]
138  // Derived from Cv coeffs. Relative to Tstd.
139  typename Polynomial<PolySize>::intPolyType eCoeffs_;
140 
141  //- Entropy polynomial coeffs [J/kg/K/K^i]
142  // Derived from Cv coeffs. Relative to Tstd.
143  Polynomial<PolySize> sCoeffs_;
144 
145 
146  // Private Member Functions
147 
148  //- Construct from components
149  inline ePolynomialThermo
150  (
151  const EquationOfState& pt,
152  const scalar Hf,
153  const scalar Sf,
154  const Polynomial<PolySize>& CvCoeffs,
155  const typename Polynomial<PolySize>::intPolyType& eCoeffs,
156  const Polynomial<PolySize>& sCoeffs
157  );
158 
159 
160 public:
161 
162  // Constructors
163 
164  //- Construct from dictionary
166 
167  //- Construct as a named copy
168  inline ePolynomialThermo(const word&, const ePolynomialThermo&);
169 
170 
171  // Member Functions
172 
173  //- Return the instantiated type name
174  static word typeName()
175  {
176  return "ePolynomial<" + EquationOfState::typeName() + '>';
177  }
178 
179  //- Limit the temperature to be in the range Tlow_ to Thigh_
180  inline scalar limit(const scalar) const;
181 
182 
183  // Fundamental properties
184 
185  //- Heat capacity at constant volume [J/kg/K]
186  inline scalar Cv(const scalar p, const scalar T) const;
187 
188  //- Sensible internal energy [J/kg]
189  inline scalar Es(const scalar p, const scalar T) const;
190 
191  //- Absolute internal energy [J/kg]
192  inline scalar Ea(const scalar p, const scalar T) const;
193 
194  //- Enthalpy of formation [J/kg]
195  inline scalar Hf() const;
196 
197  //- Entropy [J/kg/K]
198  inline scalar S(const scalar p, const scalar T) const;
199 
200  //- Gibbs free energy of the mixture in the standard state [J/kg]
201  inline scalar Gstd(const scalar T) const;
202 
203  #include "EtoHthermo.H"
204 
205 
206  // Derivative term used for Jacobian
207 
208  //- Temperature derivative of heat capacity at constant pressure
209  inline scalar dCpdT(const scalar p, const scalar T) const;
210 
211 
212  // I-O
213 
214  //- Write to Ostream
215  void write(Ostream& os) const;
216 
217 
218  // Member Operators
219 
220  inline void operator+=(const ePolynomialThermo&);
221  inline void operator*=(const scalar);
222 
223 
224  // Friend operators
225 
226  friend ePolynomialThermo operator+ <EquationOfState, PolySize>
227  (
228  const ePolynomialThermo&,
229  const ePolynomialThermo&
230  );
231 
232  friend ePolynomialThermo operator* <EquationOfState, PolySize>
233  (
234  const scalar,
235  const ePolynomialThermo&
236  );
237 
238  friend ePolynomialThermo operator== <EquationOfState, PolySize>
239  (
240  const ePolynomialThermo&,
241  const ePolynomialThermo&
242  );
243 
244 
245  // Ostream Operator
246 
247  friend Ostream& operator<< <EquationOfState, PolySize>
248  (
249  Ostream&,
250  const ePolynomialThermo&
251  );
252 };
253 
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #include "ePolynomialThermoI.H"
262 
263 #ifdef NoRepository
264  #include "ePolynomialThermo.C"
265 #endif
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 #endif
270 
271 // ************************************************************************* //
Internal energy based thermodynamics package using a polynomial function of temperature for the const...
scalar Es(const scalar p, const scalar T) const
Sensible internal energy [J/kg].
scalar S(const scalar p, const scalar T) const
Entropy [J/kg/K].
dictionary dict
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
void write(Ostream &os) const
Write to Ostream.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
void operator+=(const ePolynomialThermo &)
A class for handling words, derived from string.
Definition: word.H:59
void operator*=(const scalar)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
scalar Hf() const
Enthalpy of formation [J/kg].
scalar Cv(const scalar p, const scalar T) const
Heat capacity at constant volume [J/kg/K].
Polynomial templated on size (order):
Definition: Polynomial.H:65
static word typeName()
Return the instantiated type name.
scalar limit(const scalar) const
Limit the temperature to be in the range Tlow_ to Thigh_.
volScalarField & p
scalar Ea(const scalar p, const scalar T) const
Absolute internal energy [J/kg].
Namespace for OpenFOAM.