liquidProperties.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2014 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 \*---------------------------------------------------------------------------*/
25 
26 #include "liquidProperties.H"
27 #include "HashTable.H"
28 #include "Switch.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(liquidProperties, 0);
35  defineRunTimeSelectionTable(liquidProperties,);
36  defineRunTimeSelectionTable(liquidProperties, Istream);
37  defineRunTimeSelectionTable(liquidProperties, dictionary);
38 }
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 (
44  scalar W,
45  scalar Tc,
46  scalar Pc,
47  scalar Vc,
48  scalar Zc,
49  scalar Tt,
50  scalar Pt,
51  scalar Tb,
52  scalar dipm,
53  scalar omega,
54  scalar delta
55 )
56 :
57  W_(W),
58  Tc_(Tc),
59  Pc_(Pc),
60  Vc_(Vc),
61  Zc_(Zc),
62  Tt_(Tt),
63  Pt_(Pt),
64  Tb_(Tb),
65  dipm_(dipm),
66  omega_(omega),
67  delta_(delta)
68 {}
69 
70 
72 :
73  W_(readScalar(is)),
74  Tc_(readScalar(is)),
75  Pc_(readScalar(is)),
76  Vc_(readScalar(is)),
77  Zc_(readScalar(is)),
78  Tt_(readScalar(is)),
79  Pt_(readScalar(is)),
80  Tb_(readScalar(is)),
81  dipm_(readScalar(is)),
82  omega_(readScalar(is)),
83  delta_(readScalar(is))
84 {}
85 
86 
88 :
89  W_(readScalar(dict.lookup("W"))),
90  Tc_(readScalar(dict.lookup("Tc"))),
91  Pc_(readScalar(dict.lookup("Pc"))),
92  Vc_(readScalar(dict.lookup("Vc"))),
93  Zc_(readScalar(dict.lookup("Zc"))),
94  Tt_(readScalar(dict.lookup("Tt"))),
95  Pt_(readScalar(dict.lookup("Pt"))),
96  Tb_(readScalar(dict.lookup("Tb"))),
97  dipm_(readScalar(dict.lookup("dipm"))),
98  omega_(readScalar(dict.lookup("omega"))),
99  delta_(readScalar(dict.lookup("delta")))
100 {}
101 
102 
104 :
105  W_(liq.W_),
106  Tc_(liq.Tc_),
107  Pc_(liq.Pc_),
108  Vc_(liq.Vc_),
109  Zc_(liq.Zc_),
110  Tt_(liq.Tt_),
111  Pt_(liq.Pt_),
112  Tb_(liq.Tb_),
113  dipm_(liq.dipm_),
114  omega_(liq.omega_),
115  delta_(liq.delta_)
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
120 
122 {
123  if (debug)
124  {
125  Info<< "liquidProperties::New(Istream&): "
126  << "constructing liquidProperties" << endl;
127  }
128 
129  const word liquidPropertiesType(is);
130  const word coeffs(is);
131 
132  if (coeffs == "defaultCoeffs")
133  {
134  ConstructorTable::iterator cstrIter =
135  ConstructorTablePtr_->find(liquidPropertiesType);
136 
137  if (cstrIter == ConstructorTablePtr_->end())
138  {
139  FatalErrorIn("liquidProperties::New(Istream&)")
140  << "Unknown liquidProperties type "
141  << liquidPropertiesType << nl << nl
142  << "Valid liquidProperties types are:" << nl
143  << ConstructorTablePtr_->sortedToc()
144  << abort(FatalError);
145  }
146 
147  return autoPtr<liquidProperties>(cstrIter()());
148  }
149  else if (coeffs == "coeffs")
150  {
152  }
153  else
154  {
155  FatalErrorIn("liquidProperties::New(Istream&)")
156  << "liquidProperties type " << liquidPropertiesType
157  << ", option " << coeffs << " given"
158  << ", should be coeffs or defaultCoeffs"
159  << abort(FatalError);
160 
161  return autoPtr<liquidProperties>(NULL);
162  }
163 }
164 
165 
167 (
168  const dictionary& dict
169 )
170 {
171  if (debug)
172  {
173  Info<< "liquidProperties::New(const dictionary&):"
174  << "constructing liquidProperties" << endl;
175  }
176 
177  const word& liquidPropertiesTypeName = dict.dictName();
178 
179  const Switch defaultCoeffs(dict.lookup("defaultCoeffs"));
180 
181  if (defaultCoeffs)
182  {
183  ConstructorTable::iterator cstrIter =
184  ConstructorTablePtr_->find(liquidPropertiesTypeName);
185 
186  if (cstrIter == ConstructorTablePtr_->end())
187  {
189  (
190  "liquidProperties::New(const dictionary&)"
191  ) << "Unknown liquidProperties type "
192  << liquidPropertiesTypeName << nl << nl
193  << "Valid liquidProperties types are:" << nl
194  << ConstructorTablePtr_->sortedToc()
195  << abort(FatalError);
196  }
197 
198  return autoPtr<liquidProperties>(cstrIter()());
199  }
200  else
201  {
202  dictionaryConstructorTable::iterator cstrIter =
203  dictionaryConstructorTablePtr_->find(liquidPropertiesTypeName);
204 
205  if (cstrIter == dictionaryConstructorTablePtr_->end())
206  {
208  (
209  "liquidProperties::New(const dictionary&)"
210  ) << "Unknown liquidProperties type "
211  << liquidPropertiesTypeName << nl << nl
212  << "Valid liquidProperties types are:" << nl
213  << dictionaryConstructorTablePtr_->sortedToc()
214  << abort(FatalError);
215  }
216 
218  (
219  cstrIter()(dict.subDict(liquidPropertiesTypeName + "Coeffs"))
220  );
221  }
222 }
223 
224 
225 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
226 
227 Foam::scalar Foam::liquidProperties::rho(scalar p, scalar T) const
228 {
230  (
231  "Foam::scalar Foam::liquidProperties::rho(scalar, scalar) const"
232  );
233  return 0.0;
234 }
235 
236 
237 Foam::scalar Foam::liquidProperties::pv(scalar p, scalar T) const
238 {
240  (
241  "Foam::scalar Foam::liquidProperties::pv(scalar, scalar) const"
242  );
243  return 0.0;
244 }
245 
246 
247 Foam::scalar Foam::liquidProperties::hl(scalar p, scalar T) const
248 {
250  (
251  "Foam::scalar Foam::liquidProperties::hl(scalar, scalar) const"
252  );
253  return 0.0;
254 }
255 
256 
257 Foam::scalar Foam::liquidProperties::Cp(scalar p, scalar T) const
258 {
260  (
261  "Foam::scalar Foam::liquidProperties::Cp(scalar, scalar) const"
262  );
263  return 0.0;
264 }
265 
266 
267 Foam::scalar Foam::liquidProperties::h(scalar p, scalar T) const
268 {
270  (
271  "Foam::scalar Foam::liquidProperties::h(scalar, scalar) const"
272  );
273  return 0.0;
274 }
275 
276 
277 Foam::scalar Foam::liquidProperties::Cpg(scalar p, scalar T) const
278 {
280  (
281  "Foam::scalar Foam::liquidProperties::Cpg(scalar, scalar) const"
282  );
283  return 0.0;
284 }
285 
286 
287 Foam::scalar Foam::liquidProperties::mu(scalar p, scalar T) const
288 {
290  (
291  "Foam::scalar Foam::liquidProperties::mu(scalar, scalar) const"
292  );
293  return 0.0;
294 }
295 
296 
297 Foam::scalar Foam::liquidProperties::mug(scalar p, scalar T) const
298 {
300  (
301  "Foam::scalar Foam::liquidProperties::mug(scalar, scalar) const"
302  );
303  return 0.0;
304 }
305 
306 
307 Foam::scalar Foam::liquidProperties::K(scalar p, scalar T) const
308 {
310  (
311  "Foam::scalar Foam::liquidProperties::K(scalar, scalar) const"
312  );
313  return 0.0;
314 }
315 
316 
317 Foam::scalar Foam::liquidProperties::Kg(scalar p, scalar T) const
318 {
320  (
321  "Foam::scalar Foam::liquidProperties::Kg(scalar, scalar) const"
322  );
323  return 0.0;
324 }
325 
326 
327 Foam::scalar Foam::liquidProperties::sigma(scalar p, scalar T) const
328 {
330  (
331  "Foam::scalar Foam::liquidProperties::sigms(scalar, scalar) const"
332  );
333  return 0.0;
334 }
335 
336 
337 Foam::scalar Foam::liquidProperties::D(scalar p, scalar T) const
338 {
340  (
341  "Foam::scalar Foam::liquidProperties::D(scalar, scalar) const"
342  );
343  return 0.0;
344 }
345 
346 
347 Foam::scalar Foam::liquidProperties::D(scalar p, scalar T, scalar Wb) const
348 {
350  (
351  "Foam::scalar Foam::liquidProperties::D(scalar, scalar) const"
352  );
353  return 0.0;
354 }
355 
356 
357 Foam::scalar Foam::liquidProperties::pvInvert(scalar p) const
358 {
359  // Check for critical and solid phase conditions
360  if (p >= Pc_)
361  {
362  return Tc_;
363  }
364  else if (p < Pt_)
365  {
366  if (debug)
367  {
368  WarningIn
369  (
370  "Foam::scalar Foam::liquidProperties::pvInvert(scalar) const"
371  ) << "Pressure below triple point pressure: "
372  << "p = " << p << " < Pt = " << Pt_ << nl << endl;
373  }
374  return -1;
375  }
376 
377  // Set initial upper and lower bounds
378  scalar Thi = Tc_;
379  scalar Tlo = Tt_;
380 
381  // Initialise T as boiling temperature under normal conditions
382  scalar T = Tb_;
383 
384  while ((Thi - Tlo) > 1.0e-4)
385  {
386  if ((pv(p, T) - p) <= 0.0)
387  {
388  Tlo = T;
389  }
390  else
391  {
392  Thi = T;
393  }
394 
395  T = (Thi + Tlo)*0.5;
396  }
397 
398  return T;
399 }
400 
401 
403 {
404 
405  os << W_ << token::SPACE
406  << Tc_ << token::SPACE
407  << Pc_ << token::SPACE
408  << Vc_ << token::SPACE
409  << Zc_ << token::SPACE
410  << Tt_ << token::SPACE
411  << Pt_ << token::SPACE
412  << Tb_ << token::SPACE
413  << dipm_ << token::SPACE
414  << omega_<< token::SPACE
415  << delta_;
416 }
417 
418 
419 // ************************************************************************* //
The thermophysical properties of a liquidProperties.
virtual void writeData(Ostream &os) const
Write the function coefficients.
virtual scalar Cp(scalar p, scalar T) const
Liquid heat capacity [J/(kg K)].
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A class for handling words, derived from string.
Definition: word.H:59
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:638
virtual scalar h(scalar p, scalar T) const
Liquid enthalpy [J/kg] - reference to 298.15 K.
virtual scalar D(scalar p, scalar T) const
Vapour diffussivity [m2/s].
Namespace for OpenFOAM.
static const char nl
Definition: Ostream.H:260
const double e
Elementary charge.
Definition: doubleFloat.H:78
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
stressControl lookup("compactNormalStress") >> compactNormalStress
#define WarningIn(functionName)
Report a warning using Foam::Warning.
virtual scalar K(scalar p, scalar T) const
Liquid thermal conductivity [W/(m K)].
volScalarField & p
Definition: createFields.H:51
virtual scalar mug(scalar p, scalar T) const
Vapour viscosity [Pa s].
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
virtual scalar pv(scalar p, scalar T) const
Vapour pressure [Pa].
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
virtual scalar pvInvert(scalar p) const
Invert the vapour pressure relationship to retrieve the.
virtual scalar rho(scalar p, scalar T) const
Liquid rho [kg/m^3].
static autoPtr< liquidProperties > New(Istream &is)
Return a pointer to a new liquidProperties created from input.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual scalar Cpg(scalar p, scalar T) const
Ideal gas heat capacity [J/(kg K)].
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
virtual scalar mu(scalar p, scalar T) const
Liquid viscosity [Pa s].
virtual scalar Kg(scalar p, scalar T) const
Vapour thermal conductivity [W/(m K)].
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
liquidProperties(scalar W, scalar Tc, scalar Pc, scalar Vc, scalar Zc, scalar Tt, scalar Pt, scalar Tb, scalar dipm, scalar omega, scalar delta)
Construct from components.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
virtual scalar hl(scalar p, scalar T) const
Heat of vapourisation [J/kg].
virtual scalar sigma(scalar p, scalar T) const
Surface tension [N/m].
defineTypeNameAndDebug(combustionModel, 0)