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-2021 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  const word& name,
42  scalar W,
43  scalar Tc,
44  scalar Pc,
45  scalar Vc,
46  scalar Zc,
47  scalar Tt,
48  scalar Pt,
49  scalar Tb,
50  scalar dipm,
51  scalar omega,
52  scalar delta
53 )
54 :
56  name_(name),
57  Tc_(Tc),
58  Pc_(Pc),
59  Vc_(Vc),
60  Zc_(Zc),
61  Tt_(Tt),
62  Pt_(Pt),
63  Tb_(Tb),
64  dipm_(dipm),
65  omega_(omega),
66  delta_(delta)
67 {}
68 
69 
71 :
73  name_(dict.dictName()),
74  Tc_(dict.lookup<scalar>("Tc")),
75  Pc_(dict.lookup<scalar>("Pc")),
76  Vc_(dict.lookup<scalar>("Vc")),
77  Zc_(dict.lookup<scalar>("Zc")),
78  Tt_(dict.lookup<scalar>("Tt")),
79  Pt_(dict.lookup<scalar>("Pt")),
80  Tb_(dict.lookup<scalar>("Tb")),
81  dipm_(dict.lookup<scalar>("dipm")),
82  omega_(dict.lookup<scalar>("omega")),
83  delta_(dict.lookup<scalar>("delta"))
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
88 
90 (
91  const word& name
92 )
93 {
94  if (debug)
95  {
96  InfoInFunction << "Constructing liquidProperties" << endl;
97  }
98 
99  ConstructorTable::iterator cstrIter = ConstructorTablePtr_->find(name);
100 
101  if (cstrIter == ConstructorTablePtr_->end())
102  {
104  << "Unknown liquidProperties type "
105  << name << nl << nl
106  << "Valid liquidProperties types are:" << nl
107  << ConstructorTablePtr_->sortedToc()
108  << exit(FatalError);
109  }
110 
111  return autoPtr<liquidProperties>(cstrIter()());
112 }
113 
114 
116 (
117  const dictionary& dict
118 )
119 {
120  if (debug)
121  {
122  InfoInFunction << "Constructing liquidProperties" << endl;
123  }
124 
125  // If the type is not specified use the name as the liquid type name
126  const word& liquidPropertiesTypeName =
127  dict.found("type") ? dict.lookup("type") : dict.dictName();
128 
129  dictionaryConstructorTable::iterator cstrIter =
130  dictionaryConstructorTablePtr_->find(liquidPropertiesTypeName);
131 
132  if (cstrIter == dictionaryConstructorTablePtr_->end())
133  {
135  << "Unknown liquidProperties type "
136  << liquidPropertiesTypeName << nl << nl
137  << "Valid liquidProperties types are:" << nl
138  << dictionaryConstructorTablePtr_->sortedToc()
139  << exit(FatalError);
140  }
141 
142  return autoPtr<liquidProperties>(cstrIter()(dict));
143 }
144 
145 
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
147 
149 {
150  return name_;
151 }
152 
153 
154 Foam::scalar Foam::liquidProperties::S(scalar p, scalar T) const
155 {
157  return 0;
158 }
159 
160 
161 Foam::scalar Foam::liquidProperties::pvInvert(scalar p) const
162 {
163  // Check for critical and solid phase conditions
164  if (p >= Pc_)
165  {
166  return Tc_;
167  }
168  else if (p < Pt_)
169  {
170  if (debug)
171  {
173  << "Pressure below triple point pressure: "
174  << "p = " << p << " < Pt = " << Pt_ << nl << endl;
175  }
176  return -1;
177  }
178 
179  // Set initial upper and lower bounds
180  scalar Thi = Tc_;
181  scalar Tlo = Tt_;
182 
183  // Initialise T as boiling temperature under normal conditions
184  scalar T = Tb_;
185 
186  while ((Thi - Tlo) > 1.0e-4)
187  {
188  if ((pv(p, T) - p) <= 0)
189  {
190  Tlo = T;
191  }
192  else
193  {
194  Thi = T;
195  }
196 
197  T = (Thi + Tlo)*0.5;
198  }
199 
200  return T;
201 }
202 
203 
205 {
207  dict.readIfPresent("Tc", Tc_);
208  dict.readIfPresent("Pc", Pc_);
209  dict.readIfPresent("Vc", Vc_);
210  dict.readIfPresent("Zc", Zc_);
211  dict.readIfPresent("Tt", Tt_);
212  dict.readIfPresent("Pt", Pt_);
213  dict.readIfPresent("Tb", Tb_);
214  dict.readIfPresent("dipm", dipm_);
215  dict.readIfPresent("omega", omega_);
216  dict.readIfPresent("delta", delta_);
217 }
218 
219 
221 {
223  writeEntry(os, "Tc", Tc_);
224  writeEntry(os, "Pc", Pc_);
225  writeEntry(os, "Vc", Vc_);
226  writeEntry(os, "Zc", Zc_);
227  writeEntry(os, "Tt", Tt_);
228  writeEntry(os, "Pt", Pt_);
229  writeEntry(os, "Tb", Tb_);
230  writeEntry(os, "dipm", dipm_);
231  writeEntry(os, "omega", omega_);
232  writeEntry(os, "delta", delta_);
233 }
234 
235 
236 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
237 
239 {
240  l.write(os);
241  return os;
242 }
243 
244 
245 // ************************************************************************* //
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:643
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:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
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
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:121
virtual const word & name() const
Return the name of the liquid.
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
liquidProperties(const word &name, 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.
#define WarningInFunction
Report a warning using Foam::Warning.
Ostream & operator<<(Ostream &, const ensightPart &)
scalar S(const scalar p, const scalar T) const
Liquid entropy [J/kg/K].
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:370
virtual void write(Ostream &os) const =0
Write the function coefficients.
const word dictName("noiseDict")
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844
#define InfoInFunction
Report an information message using Foam::Info.