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-2016 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  InfoInFunction << "Constructing liquidProperties" << endl;
126  }
127 
128  const word liquidPropertiesType(is);
129  const word coeffs(is);
130 
131  if (coeffs == "defaultCoeffs")
132  {
133  ConstructorTable::iterator cstrIter =
134  ConstructorTablePtr_->find(liquidPropertiesType);
135 
136  if (cstrIter == ConstructorTablePtr_->end())
137  {
139  << "Unknown liquidProperties type "
140  << liquidPropertiesType << nl << nl
141  << "Valid liquidProperties types are:" << nl
142  << ConstructorTablePtr_->sortedToc()
143  << abort(FatalError);
144  }
145 
146  return autoPtr<liquidProperties>(cstrIter()());
147  }
148  else if (coeffs == "coeffs")
149  {
151  }
152  else
153  {
155  << "liquidProperties type " << liquidPropertiesType
156  << ", option " << coeffs << " given"
157  << ", should be coeffs or defaultCoeffs"
158  << abort(FatalError);
159 
160  return autoPtr<liquidProperties>(NULL);
161  }
162 }
163 
164 
166 (
167  const dictionary& dict
168 )
169 {
170  if (debug)
171  {
172  InfoInFunction << "Constructing liquidProperties" << endl;
173  }
174 
175  const word& liquidPropertiesTypeName = dict.dictName();
176 
177  const Switch defaultCoeffs(dict.lookup("defaultCoeffs"));
178 
179  if (defaultCoeffs)
180  {
181  ConstructorTable::iterator cstrIter =
182  ConstructorTablePtr_->find(liquidPropertiesTypeName);
183 
184  if (cstrIter == ConstructorTablePtr_->end())
185  {
187  << "Unknown liquidProperties type "
188  << liquidPropertiesTypeName << nl << nl
189  << "Valid liquidProperties types are:" << nl
190  << ConstructorTablePtr_->sortedToc()
191  << abort(FatalError);
192  }
193 
194  return autoPtr<liquidProperties>(cstrIter()());
195  }
196  else
197  {
198  dictionaryConstructorTable::iterator cstrIter =
199  dictionaryConstructorTablePtr_->find(liquidPropertiesTypeName);
200 
201  if (cstrIter == dictionaryConstructorTablePtr_->end())
202  {
204  << "Unknown liquidProperties type "
205  << liquidPropertiesTypeName << nl << nl
206  << "Valid liquidProperties types are:" << nl
207  << dictionaryConstructorTablePtr_->sortedToc()
208  << abort(FatalError);
209  }
210 
212  (
213  cstrIter()(dict.subDict(liquidPropertiesTypeName + "Coeffs"))
214  );
215  }
216 }
217 
218 
219 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
220 
221 Foam::scalar Foam::liquidProperties::rho(scalar p, scalar T) const
222 {
224  return 0.0;
225 }
226 
227 
228 Foam::scalar Foam::liquidProperties::pv(scalar p, scalar T) const
229 {
231  return 0.0;
232 }
233 
234 
235 Foam::scalar Foam::liquidProperties::hl(scalar p, scalar T) const
236 {
238  return 0.0;
239 }
240 
241 
242 Foam::scalar Foam::liquidProperties::Cp(scalar p, scalar T) const
243 {
245  return 0.0;
246 }
247 
248 
249 Foam::scalar Foam::liquidProperties::h(scalar p, scalar T) const
250 {
252  return 0.0;
253 }
254 
255 
256 Foam::scalar Foam::liquidProperties::Cpg(scalar p, scalar T) const
257 {
259  return 0.0;
260 }
261 
262 
263 Foam::scalar Foam::liquidProperties::mu(scalar p, scalar T) const
264 {
266  return 0.0;
267 }
268 
269 
270 Foam::scalar Foam::liquidProperties::mug(scalar p, scalar T) const
271 {
273  return 0.0;
274 }
275 
276 
277 Foam::scalar Foam::liquidProperties::K(scalar p, scalar T) const
278 {
280  return 0.0;
281 }
282 
283 
284 Foam::scalar Foam::liquidProperties::Kg(scalar p, scalar T) const
285 {
287  return 0.0;
288 }
289 
290 
291 Foam::scalar Foam::liquidProperties::sigma(scalar p, scalar T) const
292 {
294  return 0.0;
295 }
296 
297 
298 Foam::scalar Foam::liquidProperties::D(scalar p, scalar T) const
299 {
301  return 0.0;
302 }
303 
304 
305 Foam::scalar Foam::liquidProperties::D(scalar p, scalar T, scalar Wb) const
306 {
308  return 0.0;
309 }
310 
311 
312 Foam::scalar Foam::liquidProperties::pvInvert(scalar p) const
313 {
314  // Check for critical and solid phase conditions
315  if (p >= Pc_)
316  {
317  return Tc_;
318  }
319  else if (p < Pt_)
320  {
321  if (debug)
322  {
324  << "Pressure below triple point pressure: "
325  << "p = " << p << " < Pt = " << Pt_ << nl << endl;
326  }
327  return -1;
328  }
329 
330  // Set initial upper and lower bounds
331  scalar Thi = Tc_;
332  scalar Tlo = Tt_;
333 
334  // Initialise T as boiling temperature under normal conditions
335  scalar T = Tb_;
336 
337  while ((Thi - Tlo) > 1.0e-4)
338  {
339  if ((pv(p, T) - p) <= 0.0)
340  {
341  Tlo = T;
342  }
343  else
344  {
345  Thi = T;
346  }
347 
348  T = (Thi + Tlo)*0.5;
349  }
350 
351  return T;
352 }
353 
354 
356 {
357 
358  os << W_ << token::SPACE
359  << Tc_ << token::SPACE
360  << Pc_ << token::SPACE
361  << Vc_ << token::SPACE
362  << Zc_ << token::SPACE
363  << Tt_ << token::SPACE
364  << Pt_ << token::SPACE
365  << Tb_ << token::SPACE
366  << dipm_ << token::SPACE
367  << omega_<< token::SPACE
368  << delta_;
369 }
370 
371 
372 // ************************************************************************* //
const double e
Elementary charge.
Definition: doubleFloat.H:78
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual scalar h(scalar p, scalar T) const
Liquid enthalpy [J/kg] - reference to 298.15 K.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
virtual void writeData(Ostream &os) const
Write the function coefficients.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:633
virtual scalar hl(scalar p, scalar T) const
Heat of vapourisation [J/kg].
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
virtual scalar mu(scalar p, scalar T) const
Liquid viscosity [Pa s].
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
virtual scalar Kg(scalar p, scalar T) const
Vapour thermal conductivity [W/(m K)].
virtual scalar Cpg(scalar p, scalar T) const
Ideal gas heat capacity [J/(kg K)].
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.
stressControl lookup("compactNormalStress") >> compactNormalStress
A class for handling words, derived from string.
Definition: word.H:59
virtual scalar sigma(scalar p, scalar T) const
Surface tension [N/m].
The thermophysical properties of a liquidProperties.
virtual scalar Cp(scalar p, scalar T) const
Liquid heat capacity [J/(kg K)].
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
virtual scalar rho(scalar p, scalar T) const
Liquid rho [kg/m^3].
virtual scalar pv(scalar p, scalar T) const
Vapour pressure [Pa].
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual scalar K(scalar p, scalar T) const
Liquid thermal conductivity [W/(m K)].
virtual scalar pvInvert(scalar p) const
Invert the vapour pressure relationship to retrieve the.
static autoPtr< liquidProperties > New(Istream &is)
Return a pointer to a new liquidProperties created from input.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual scalar mug(scalar p, scalar T) const
Vapour viscosity [Pa s].
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
virtual scalar D(scalar p, scalar T) const
Vapour diffussivity [m2/s].
volScalarField & p
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451
#define InfoInFunction
Report an information message using Foam::Info.