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-2023 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>
104 (
107 );
108 
109 template<class EquationOfState, int PolySize>
110 Ostream& operator<<
111 (
112  Ostream&,
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 name and dictionary
165  ePolynomialThermo(const word& name, const dictionary& dict);
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  (
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 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Polynomial templated on size (order):
Definition: Polynomial.H:84
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Internal energy based thermodynamics package using a polynomial function of temperature for the const...
scalar gStd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
void operator+=(const ePolynomialThermo &)
scalar s(const scalar p, const scalar T) const
Entropy [J/kg/K].
static word typeName()
Return the instantiated type name.
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
scalar ea(const scalar p, const scalar T) const
Absolute internal energy [J/kg].
void write(Ostream &os) const
Write to Ostream.
scalar Cv(const scalar p, const scalar T) const
Heat capacity at constant volume [J/kg/K].
scalar hf() const
Enthalpy of formation [J/kg].
scalar limit(const scalar) const
Limit the temperature to be in the range Tlow_ to Thigh_.
scalar es(const scalar p, const scalar T) const
Sensible internal energy [J/kg].
void operator*=(const scalar)
A class for handling words, derived from string.
Definition: word.H:62
volScalarField sf(fieldObject, mesh)
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict
volScalarField & p