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-2015 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  {
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  {
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  << "Unknown liquidProperties type "
190  << liquidPropertiesTypeName << nl << nl
191  << "Valid liquidProperties types are:" << nl
192  << ConstructorTablePtr_->sortedToc()
193  << abort(FatalError);
194  }
195 
196  return autoPtr<liquidProperties>(cstrIter()());
197  }
198  else
199  {
200  dictionaryConstructorTable::iterator cstrIter =
201  dictionaryConstructorTablePtr_->find(liquidPropertiesTypeName);
202 
203  if (cstrIter == dictionaryConstructorTablePtr_->end())
204  {
206  << "Unknown liquidProperties type "
207  << liquidPropertiesTypeName << nl << nl
208  << "Valid liquidProperties types are:" << nl
209  << dictionaryConstructorTablePtr_->sortedToc()
210  << abort(FatalError);
211  }
212 
214  (
215  cstrIter()(dict.subDict(liquidPropertiesTypeName + "Coeffs"))
216  );
217  }
218 }
219 
220 
221 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
222 
223 Foam::scalar Foam::liquidProperties::rho(scalar p, scalar T) const
224 {
226  return 0.0;
227 }
228 
229 
230 Foam::scalar Foam::liquidProperties::pv(scalar p, scalar T) const
231 {
233  return 0.0;
234 }
235 
236 
237 Foam::scalar Foam::liquidProperties::hl(scalar p, scalar T) const
238 {
240  return 0.0;
241 }
242 
243 
244 Foam::scalar Foam::liquidProperties::Cp(scalar p, scalar T) const
245 {
247  return 0.0;
248 }
249 
250 
251 Foam::scalar Foam::liquidProperties::h(scalar p, scalar T) const
252 {
254  return 0.0;
255 }
256 
257 
258 Foam::scalar Foam::liquidProperties::Cpg(scalar p, scalar T) const
259 {
261  return 0.0;
262 }
263 
264 
265 Foam::scalar Foam::liquidProperties::mu(scalar p, scalar T) const
266 {
268  return 0.0;
269 }
270 
271 
272 Foam::scalar Foam::liquidProperties::mug(scalar p, scalar T) const
273 {
275  return 0.0;
276 }
277 
278 
279 Foam::scalar Foam::liquidProperties::K(scalar p, scalar T) const
280 {
282  return 0.0;
283 }
284 
285 
286 Foam::scalar Foam::liquidProperties::Kg(scalar p, scalar T) const
287 {
289  return 0.0;
290 }
291 
292 
293 Foam::scalar Foam::liquidProperties::sigma(scalar p, scalar T) const
294 {
296  return 0.0;
297 }
298 
299 
300 Foam::scalar Foam::liquidProperties::D(scalar p, scalar T) const
301 {
303  return 0.0;
304 }
305 
306 
307 Foam::scalar Foam::liquidProperties::D(scalar p, scalar T, scalar Wb) const
308 {
310  return 0.0;
311 }
312 
313 
314 Foam::scalar Foam::liquidProperties::pvInvert(scalar p) const
315 {
316  // Check for critical and solid phase conditions
317  if (p >= Pc_)
318  {
319  return Tc_;
320  }
321  else if (p < Pt_)
322  {
323  if (debug)
324  {
326  << "Pressure below triple point pressure: "
327  << "p = " << p << " < Pt = " << Pt_ << nl << endl;
328  }
329  return -1;
330  }
331 
332  // Set initial upper and lower bounds
333  scalar Thi = Tc_;
334  scalar Tlo = Tt_;
335 
336  // Initialise T as boiling temperature under normal conditions
337  scalar T = Tb_;
338 
339  while ((Thi - Tlo) > 1.0e-4)
340  {
341  if ((pv(p, T) - p) <= 0.0)
342  {
343  Tlo = T;
344  }
345  else
346  {
347  Thi = T;
348  }
349 
350  T = (Thi + Tlo)*0.5;
351  }
352 
353  return T;
354 }
355 
356 
358 {
359 
360  os << W_ << token::SPACE
361  << Tc_ << token::SPACE
362  << Pc_ << token::SPACE
363  << Vc_ << token::SPACE
364  << Zc_ << token::SPACE
365  << Tt_ << token::SPACE
366  << Pt_ << token::SPACE
367  << Tb_ << token::SPACE
368  << dipm_ << token::SPACE
369  << omega_<< token::SPACE
370  << delta_;
371 }
372 
373 
374 // ************************************************************************* //
Foam::dictionaryName::dictName
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
Foam::liquidProperties::K
virtual scalar K(scalar p, scalar T) const
Liquid thermal conductivity [W/(m K)].
Definition: liquidProperties.C:279
Foam::liquidProperties::Kg
virtual scalar Kg(scalar p, scalar T) const
Vapour thermal conductivity [W/(m K)].
Definition: liquidProperties.C:286
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
HashTable.H
Foam::liquidProperties::hl
virtual scalar hl(scalar p, scalar T) const
Heat of vapourisation [J/kg].
Definition: liquidProperties.C:237
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::liquidProperties::Cp
virtual scalar Cp(scalar p, scalar T) const
Liquid heat capacity [J/(kg K)].
Definition: liquidProperties.C:244
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::liquidProperties::writeData
virtual void writeData(Ostream &os) const
Write the function coefficients.
Definition: liquidProperties.C:357
Foam::liquidProperties::mug
virtual scalar mug(scalar p, scalar T) const
Vapour viscosity [Pa s].
Definition: liquidProperties.C:272
Foam::liquidProperties::h
virtual scalar h(scalar p, scalar T) const
Liquid enthalpy [J/kg] - reference to 298.15 K.
Definition: liquidProperties.C:251
Foam::liquidProperties::mu
virtual scalar mu(scalar p, scalar T) const
Liquid viscosity [Pa s].
Definition: liquidProperties.C:265
Foam::liquidProperties::sigma
virtual scalar sigma(scalar p, scalar T) const
Surface tension [N/m].
Definition: liquidProperties.C:293
Foam::liquidProperties::New
static autoPtr< liquidProperties > New(Istream &is)
Return a pointer to a new liquidProperties created from input.
Definition: liquidProperties.C:121
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::liquidProperties
The thermophysical properties of a liquidProperties.
Definition: liquidProperties.H:53
Foam::liquidProperties::liquidProperties
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.
Definition: liquidProperties.C:43
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
delta
scalar delta
Definition: LISASMDCalcMethod2.H:8
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Switch.H
Foam::liquidProperties::rho
virtual scalar rho(scalar p, scalar T) const
Liquid rho [kg/m^3].
Definition: liquidProperties.C:223
Foam::liquidProperties::pvInvert
virtual scalar pvInvert(scalar p) const
Invert the vapour pressure relationship to retrieve the.
Definition: liquidProperties.C:314
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
liquidProperties.H
readScalar
#define readScalar
Definition: doubleScalar.C:38
Foam::autoPtr< Foam::liquidProperties >
Foam::liquidProperties::D
virtual scalar D(scalar p, scalar T) const
Vapour diffussivity [m2/s].
Definition: liquidProperties.C:300
Foam::liquidProperties::Cpg
virtual scalar Cpg(scalar p, scalar T) const
Ideal gas heat capacity [J/(kg K)].
Definition: liquidProperties.C:258
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::liquidProperties::pv
virtual scalar pv(scalar p, scalar T) const
Vapour pressure [Pa].
Definition: liquidProperties.C:230
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress
Foam::token::SPACE
@ SPACE
Definition: token.H:95