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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "liquidProperties.H"
30 #include "HashTable.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(liquidProperties, 0);
37  defineRunTimeSelectionTable(liquidProperties,);
38  defineRunTimeSelectionTable(liquidProperties, dictionary);
39 }
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  scalar W,
46  scalar Tc,
47  scalar Pc,
48  scalar Vc,
49  scalar Zc,
50  scalar Tt,
51  scalar Pt,
52  scalar Tb,
53  scalar dipm,
54  scalar omega,
55  scalar delta
56 )
57 :
59  Tc_(Tc),
60  Pc_(Pc),
61  Vc_(Vc),
62  Zc_(Zc),
63  Tt_(Tt),
64  Pt_(Pt),
65  Tb_(Tb),
66  dipm_(dipm),
67  omega_(omega),
68  delta_(delta)
69 {}
70 
71 
73 :
75  Tc_(dict.get<label>("Tc")),
76  Pc_(dict.get<label>("Pc")),
77  Vc_(dict.get<label>("Vc")),
78  Zc_(dict.get<label>("Zc")),
79  Tt_(dict.get<label>("Tt")),
80  Pt_(dict.get<label>("Pt")),
81  Tb_(dict.get<label>("Tb")),
82  dipm_(dict.get<label>("dipm")),
83  omega_(dict.get<label>("omega")),
84  delta_(dict.get<label>("delta"))
85 {}
86 
87 
88 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
89 
91 (
92  const word& name
93 )
94 {
95  if (debug)
96  {
97  InfoInFunction << "Constructing liquidProperties" << endl;
98  }
99 
100  auto cstrIter = ConstructorTablePtr_->cfind(name);
101 
102  if (!cstrIter.found())
103  {
105  (
106  "liquidProperties",
107  name,
108  *ConstructorTablePtr_
109  ) << exit(FatalError);
110  }
111 
112  return autoPtr<liquidProperties>(cstrIter()());
113 }
114 
115 
117 (
118  const dictionary& dict
119 )
120 {
121  if (debug)
122  {
123  InfoInFunction << "Constructing liquidProperties" << endl;
124  }
125 
126  const word liquidType(dict.dictName());
127 
128  if (dict.found("defaultCoeffs"))
129  {
130  // Backward-compatibility
131 
132  if (dict.get<bool>("defaultCoeffs"))
133  {
134  return New(liquidType);
135  }
136 
137  auto cstrIter = dictionaryConstructorTablePtr_->cfind(liquidType);
138 
139  if (!cstrIter.found())
140  {
142  (
143  dict,
144  "liquidProperties",
145  liquidType,
146  *dictionaryConstructorTablePtr_
147  ) << exit(FatalIOError);
148  }
149 
151  (
152  cstrIter()
153  (
154  dict.optionalSubDict(liquidType + "Coeffs")
155  )
156  );
157  }
158 
159  auto cstrIter = dictionaryConstructorTablePtr_->cfind(liquidType);
160 
161  if (!cstrIter.found())
162  {
164  (
165  dict,
166  "liquidProperties",
167  liquidType,
168  *dictionaryConstructorTablePtr_
169  ) << exit(FatalIOError);
170  }
171 
172  return autoPtr<liquidProperties>(cstrIter()(dict));
173 }
174 
175 
176 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
177 
178 Foam::scalar Foam::liquidProperties::S(scalar p, scalar T) const
179 {
181  return 0;
182 }
183 
184 
185 Foam::scalar Foam::liquidProperties::pvInvert(scalar p) const
186 {
187  // Check for critical and solid phase conditions
188  if (p >= Pc_)
189  {
190  return Tc_;
191  }
192  else if (p < Pt_)
193  {
194  if (debug)
195  {
197  << "Pressure below triple point pressure: "
198  << "p = " << p << " < Pt = " << Pt_ << nl << endl;
199  }
200  return -1;
201  }
202 
203  // Set initial upper and lower bounds
204  scalar Thi = Tc_;
205  scalar Tlo = Tt_;
206 
207  // Initialise T as boiling temperature under normal conditions
208  scalar T = Tb_;
209 
210  while ((Thi - Tlo) > 1.0e-4)
211  {
212  if ((pv(p, T) - p) <= 0)
213  {
214  Tlo = T;
215  }
216  else
217  {
218  Thi = T;
219  }
220 
221  T = (Thi + Tlo)*0.5;
222  }
223 
224  return T;
225 }
226 
227 
229 {
231  dict.readIfPresent("Tc", Tc_);
232  dict.readIfPresent("Pc", Pc_);
233  dict.readIfPresent("Vc", Vc_);
234  dict.readIfPresent("Zc", Zc_);
235  dict.readIfPresent("Tt", Tt_);
236  dict.readIfPresent("Pt", Pt_);
237  dict.readIfPresent("Tb", Tb_);
238  dict.readIfPresent("dipm", dipm_);
239  dict.readIfPresent("omega", omega_);
240  dict.readIfPresent("delta", delta_);
241 }
242 
243 
245 {
247  os << token::SPACE
248  << Tc_ << token::SPACE
249  << Pc_ << token::SPACE
250  << Vc_ << token::SPACE
251  << Zc_ << token::SPACE
252  << Tt_ << token::SPACE
253  << Pt_ << token::SPACE
254  << Tb_ << token::SPACE
255  << dipm_ << token::SPACE
256  << omega_<< token::SPACE
257  << delta_;
258 }
259 
260 
261 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
262 
264 {
265  l.writeData(os);
266  return os;
267 }
268 
269 
270 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:316
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
HashTable.H
Foam::liquidProperties::New
static autoPtr< liquidProperties > New(const word &name)
Return a pointer to a new liquidProperties created from name.
Definition: liquidProperties.C:91
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionary.C:359
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::liquidProperties::writeData
virtual void writeData(Ostream &os) const =0
Write the function coefficients.
Definition: liquidProperties.C:244
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:419
Foam::thermophysicalProperties
Base-class for thermophysical properties of solids, liquids and gases providing an interface compatib...
Definition: thermophysicalProperties.H:55
Foam::liquidProperties
The thermophysical properties of a liquid.
Definition: liquidProperties.H:51
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:44
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:380
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
delta
scalar delta
Definition: LISASMDCalcMethod2.H:8
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::thermophysicalProperties::writeData
virtual void writeData(Ostream &os) const =0
Write the function coefficients.
Definition: thermophysicalProperties.C:115
Foam::liquidProperties::S
scalar S(const scalar p, const scalar T) const
Definition: liquidProperties.C:178
Foam::liquidProperties::pvInvert
virtual scalar pvInvert(scalar p) const
Invert the vapour pressure relationship to retrieve the.
Definition: liquidProperties.C:185
Foam::dictionary::dictName
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionary.H:458
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
FatalErrorInLookup
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:359
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
liquidProperties.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr< Foam::liquidProperties >
Foam::liquidProperties::readIfPresent
void readIfPresent(const dictionary &dict)
Read and set the properties present it the given dictionary.
Definition: liquidProperties.C:228
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::thermophysicalProperties::readIfPresent
void readIfPresent(const dictionary &dict)
Read and set the properties present it the given dictionary.
Definition: thermophysicalProperties.C:109
Foam::token::SPACE
Space [isspace].
Definition: token.H:112
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::dictionary::optionalSubDict
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition: dictionary.C:640
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:417