liquidProperties.C
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) 2011-2019 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 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32  defineTypeNameAndDebug(liquidProperties, 0);
33  defineRunTimeSelectionTable(liquidProperties,);
34  defineRunTimeSelectionTable(liquidProperties, dictionary);
35 }
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 (
41  scalar W,
42  scalar Tc,
43  scalar Pc,
44  scalar Vc,
45  scalar Zc,
46  scalar Tt,
47  scalar Pt,
48  scalar Tb,
49  scalar dipm,
50  scalar omega,
51  scalar delta
52 )
53 :
55  Tc_(Tc),
56  Pc_(Pc),
57  Vc_(Vc),
58  Zc_(Zc),
59  Tt_(Tt),
60  Pt_(Pt),
61  Tb_(Tb),
62  dipm_(dipm),
63  omega_(omega),
64  delta_(delta)
65 {}
66 
67 
69 :
71  Tc_(dict.lookup<scalar>("Tc")),
72  Pc_(dict.lookup<scalar>("Pc")),
73  Vc_(dict.lookup<scalar>("Vc")),
74  Zc_(dict.lookup<scalar>("Zc")),
75  Tt_(dict.lookup<scalar>("Tt")),
76  Pt_(dict.lookup<scalar>("Pt")),
77  Tb_(dict.lookup<scalar>("Tb")),
78  dipm_(dict.lookup<scalar>("dipm")),
79  omega_(dict.lookup<scalar>("omega")),
80  delta_(dict.lookup<scalar>("delta"))
81 {}
82 
83 
84 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
85 
87 (
88  const word& name
89 )
90 {
91  if (debug)
92  {
93  InfoInFunction << "Constructing liquidProperties" << endl;
94  }
95 
96  ConstructorTable::iterator cstrIter = ConstructorTablePtr_->find(name);
97 
98  if (cstrIter == ConstructorTablePtr_->end())
99  {
101  << "Unknown liquidProperties type "
102  << name << nl << nl
103  << "Valid liquidProperties types are:" << nl
104  << ConstructorTablePtr_->sortedToc()
105  << exit(FatalError);
106  }
107 
108  return autoPtr<liquidProperties>(cstrIter()());
109 }
110 
111 
113 (
114  const dictionary& dict
115 )
116 {
117  if (debug)
118  {
119  InfoInFunction << "Constructing liquidProperties" << endl;
120  }
121 
122  // If the type is not specified use the entry name as the liquid type name
123  const word& liquidPropertiesTypeName =
124  dict.found("type") ? dict.lookup("type") : dict.dictName();
125 
126  dictionaryConstructorTable::iterator cstrIter =
127  dictionaryConstructorTablePtr_->find(liquidPropertiesTypeName);
128 
129  if (cstrIter == dictionaryConstructorTablePtr_->end())
130  {
132  << "Unknown liquidProperties type "
133  << liquidPropertiesTypeName << nl << nl
134  << "Valid liquidProperties types are:" << nl
135  << dictionaryConstructorTablePtr_->sortedToc()
136  << exit(FatalError);
137  }
138 
139  return autoPtr<liquidProperties>(cstrIter()(dict));
140 }
141 
142 
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 
145 Foam::scalar Foam::liquidProperties::S(scalar p, scalar T) const
146 {
148  return 0;
149 }
150 
151 
152 Foam::scalar Foam::liquidProperties::pvInvert(scalar p) const
153 {
154  // Check for critical and solid phase conditions
155  if (p >= Pc_)
156  {
157  return Tc_;
158  }
159  else if (p < Pt_)
160  {
161  if (debug)
162  {
164  << "Pressure below triple point pressure: "
165  << "p = " << p << " < Pt = " << Pt_ << nl << endl;
166  }
167  return -1;
168  }
169 
170  // Set initial upper and lower bounds
171  scalar Thi = Tc_;
172  scalar Tlo = Tt_;
173 
174  // Initialise T as boiling temperature under normal conditions
175  scalar T = Tb_;
176 
177  while ((Thi - Tlo) > 1.0e-4)
178  {
179  if ((pv(p, T) - p) <= 0)
180  {
181  Tlo = T;
182  }
183  else
184  {
185  Thi = T;
186  }
187 
188  T = (Thi + Tlo)*0.5;
189  }
190 
191  return T;
192 }
193 
194 
196 {
198  dict.readIfPresent("Tc", Tc_);
199  dict.readIfPresent("Pc", Pc_);
200  dict.readIfPresent("Vc", Vc_);
201  dict.readIfPresent("Zc", Zc_);
202  dict.readIfPresent("Tt", Tt_);
203  dict.readIfPresent("Pt", Pt_);
204  dict.readIfPresent("Tb", Tb_);
205  dict.readIfPresent("dipm", dipm_);
206  dict.readIfPresent("omega", omega_);
207  dict.readIfPresent("delta", delta_);
208 }
209 
210 
212 {
214  writeEntry(os, "Tc", Tc_);
215  writeEntry(os, "Pc", Pc_);
216  writeEntry(os, "Vc", Vc_);
217  writeEntry(os, "Zc", Zc_);
218  writeEntry(os, "Tt", Tt_);
219  writeEntry(os, "Pt", Pt_);
220  writeEntry(os, "Tb", Tb_);
221  writeEntry(os, "dipm", dipm_);
222  writeEntry(os, "omega", omega_);
223  writeEntry(os, "delta", delta_);
224 }
225 
226 
227 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
228 
230 {
231  l.write(os);
232  return os;
233 }
234 
235 
236 // ************************************************************************* //
Base-class for thermophysical properties of solids, liquids and gases providing an interface compatib...
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
virtual scalar pvInvert(scalar p) const
Invert the vapour pressure relationship to retrieve the.
void readIfPresent(const dictionary &dict)
Read and set the properties present it the given dictionary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
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.
void readIfPresent(const dictionary &dict)
Read and set the properties present it the given dictionary.
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:123
stressControl lookup("compactNormalStress") >> compactNormalStress
A class for handling words, derived from string.
Definition: word.H:59
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
The thermophysical properties of a liquid.
virtual scalar pv(scalar p, scalar T) const =0
Vapour pressure [Pa].
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
virtual void write(Ostream &os) const =0
Write the function coefficients.
defineTypeNameAndDebug(combustionModel, 0)
static autoPtr< liquidProperties > New(const word &name)
Return a pointer to a new liquidProperties created from name.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
#define WarningInFunction
Report a warning using Foam::Warning.
Ostream & operator<<(Ostream &, const ensightPart &)
scalar S(const scalar p, const scalar T) const
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
volScalarField & p
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
virtual void write(Ostream &os) const =0
Write the function coefficients.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812
#define InfoInFunction
Report an information message using Foam::Info.