rPolynomial.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2019 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::rPolynomial
28
29Description
30 Reciprocal polynomial equation of state for liquids and solids
31
32 \f[
33 1/\rho = C_0 + C_1 T + C_2 T^2 - C_3 p - C_4 p T
34 \f]
35
36 This polynomial for the reciprocal of the density provides a much better fit
37 than the equivalent polynomial for the density and has the advantage that it
38 support coefficient mixing to support liquid and solid mixtures in an
39 efficient manner.
40
41Usage
42 \table
43 Property | Description
44 C | Density polynomial coefficients
45 \endtable
46
47 Example of the specification of the equation of state for pure water:
48 \verbatim
49 equationOfState
50 {
51 C (0.001278 -2.1055e-06 3.9689e-09 4.3772e-13 -2.0225e-16);
52 }
53 \endverbatim
54 Note: This fit is based on the small amount of data which is freely
55 available for the range 20-65degC and 1-100bar.
56
57SourceFiles
58 rPolynomialI.H
59 rPolynomial.C
60
61\*---------------------------------------------------------------------------*/
62
63#ifndef rPolynomial_H
64#define rPolynomial_H
65
66#include "autoPtr.H"
67#include "VectorSpace.H"
68
69// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70
71namespace Foam
72{
73
74// Forward declaration of friend functions and operators
75
76template<class Specie> class rPolynomial;
77
78template<class Specie>
79inline rPolynomial<Specie> operator+
80(
81 const rPolynomial<Specie>&,
82 const rPolynomial<Specie>&
83);
85template<class Specie>
86inline rPolynomial<Specie> operator*
87(
88 const scalar,
90);
92template<class Specie>
93inline rPolynomial<Specie> operator==
94(
97);
99template<class Specie>
100Ostream& operator<<
101(
102 Ostream&,
104);
106
107/*---------------------------------------------------------------------------*\
108 Class rPolynomial Declaration
109\*---------------------------------------------------------------------------*/
110
111template<class Specie>
112class rPolynomial
113:
114 public Specie
115{
116 // Private Data
118 class coeffList
119 :
120 public VectorSpace<coeffList, scalar, 5>
121 {
122 public:
123
124 // Constructors
125
126 //- Construct null
127 inline coeffList()
128 {}
129
130 //- Construct from Istream
131 inline coeffList(Istream& is)
132 :
134 {}
135 };
136
137
138 //- Density coefficients
139 coeffList C_;
140
141
142public:
143
144 // Constructors
145
146 //- Construct from components
147 inline rPolynomial
148 (
149 const Specie& sp,
150 const coeffList& coeffs
151 );
152
153 //- Construct from dictionary
155
156 //- Construct as named copy
157 inline rPolynomial(const word& name, const rPolynomial&);
158
159 //- Construct and return a clone
160 inline autoPtr<rPolynomial> clone() const;
161
162 // Selector from dictionary
163 inline static autoPtr<rPolynomial> New(const dictionary& dict);
164
165
166 // Member Functions
167
168 //- Return the instantiated type name
169 static word typeName()
170 {
171 return "rPolynomial<" + word(Specie::typeName_()) + '>';
172 }
173
175 // Fundamental properties
176
177 //- Is the equation of state is incompressible i.e. rho != f(p)
178 static const bool incompressible = false;
179
180 //- Is the equation of state is isochoric i.e. rho = const
181 static const bool isochoric = false;
182
183 //- Return density [kg/m^3]
184 inline scalar rho(scalar p, scalar T) const;
185
186 //- Return enthalpy departure [J/kg]
187 inline scalar H(const scalar p, const scalar T) const;
188
189 //- Return Cp departure [J/(kg K]
190 inline scalar Cp(scalar p, scalar T) const;
191
192 //- Return internal energy departure [J/kg]
193 inline scalar E(const scalar p, const scalar T) const;
194
195 //- Return Cv departure [J/(kg K]
196 inline scalar Cv(scalar p, scalar T) const;
197
198 //- Return entropy [J/kg/K]
199 inline scalar S(const scalar p, const scalar T) const;
200
201 //- Return compressibility [s^2/m^2]
202 inline scalar psi(scalar p, scalar T) const;
203
204 //- Return compression factor []
205 inline scalar Z(scalar p, scalar T) const;
206
207 //- Return (Cp - Cv) [J/(kg K]
208 inline scalar CpMCv(scalar p, scalar T) const;
209
210
211 // IO
212
213 //- Write to Ostream
214 void write(Ostream& os) const;
215
216
217 // Member Operators
218
219 inline void operator+=(const rPolynomial&);
220 inline void operator*=(const scalar);
221
222
223 // Friend operators
224
225 friend rPolynomial operator+ <Specie>
226 (
227 const rPolynomial&,
228 const rPolynomial&
229 );
231 friend rPolynomial operator* <Specie>
232 (
233 const scalar s,
234 const rPolynomial&
235 );
237 friend rPolynomial operator== <Specie>
238 (
239 const rPolynomial&,
240 const rPolynomial&
241 );
243
244 // Ostream Operator
245
246 friend Ostream& operator<< <Specie>
247 (
248 Ostream&,
249 const rPolynomial&
250 );
252
253
254// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255
256} // End namespace Foam
257
258// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259
260#include "rPolynomialI.H"
261
262#ifdef NoRepository
263 #include "rPolynomial.C"
264#endif
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
268#endif
269
270// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Templated vector space.
Definition: VectorSpace.H:79
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Reciprocal polynomial equation of state for liquids and solids.
Definition: rPolynomial.H:120
rPolynomial(const word &name, const rPolynomial &)
Construct as named copy.
void operator+=(const rPolynomial &)
Definition: rPolynomialI.H:146
scalar E(const scalar p, const scalar T) const
Return internal energy departure [J/kg].
Definition: rPolynomialI.H:101
scalar H(const scalar p, const scalar T) const
Return enthalpy departure [J/kg].
Definition: rPolynomialI.H:87
static word typeName()
Return the instantiated type name.
Definition: rPolynomial.H:174
scalar S(const scalar p, const scalar T) const
Return entropy [J/kg/K].
Definition: rPolynomialI.H:115
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
Definition: rPolynomialI.H:136
static autoPtr< rPolynomial > New(const dictionary &dict)
Definition: rPolynomialI.H:69
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: rPolynomial.H:186
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: rPolynomial.H:183
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: rPolynomialI.H:129
autoPtr< rPolynomial > clone() const
Construct and return a clone.
Definition: rPolynomialI.H:60
void operator*=(const scalar)
Definition: rPolynomialI.H:161
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
const volScalarField & psi
const volScalarField & T
const volScalarField & Cv
Definition: EEqn.H:8
const volScalarField & Cp
Definition: EEqn.H:7
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
runTime write()
dictionary dict