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-2023 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 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
90 {
91  return name_;
92 }
93 
94 
95 Foam::scalar Foam::liquidProperties::s(scalar p, scalar T) const
96 {
98  return 0;
99 }
100 
101 
102 Foam::scalar Foam::liquidProperties::pvInvert(scalar p) const
103 {
104  // Check for critical and solid phase conditions
105  if (p >= Pc_)
106  {
107  return Tc_;
108  }
109  else if (p < Pt_)
110  {
111  if (debug)
112  {
114  << "Pressure below triple point pressure: "
115  << "p = " << p << " < Pt = " << Pt_ << nl << endl;
116  }
117  return -1;
118  }
119 
120  // Set initial upper and lower bounds
121  scalar Thi = Tc_;
122  scalar Tlo = Tt_;
123 
124  // Initialise T as boiling temperature under normal conditions
125  scalar T = Tb_;
126 
127  while ((Thi - Tlo) > 1.0e-4)
128  {
129  if ((pv(p, T) - p) <= 0)
130  {
131  Tlo = T;
132  }
133  else
134  {
135  Thi = T;
136  }
137 
138  T = (Thi + Tlo)*0.5;
139  }
140 
141  return T;
142 }
143 
144 
146 {
148  dict.readIfPresent("Tc", Tc_);
149  dict.readIfPresent("Pc", Pc_);
150  dict.readIfPresent("Vc", Vc_);
151  dict.readIfPresent("Zc", Zc_);
152  dict.readIfPresent("Tt", Tt_);
153  dict.readIfPresent("Pt", Pt_);
154  dict.readIfPresent("Tb", Tb_);
155  dict.readIfPresent("dipm", dipm_);
156  dict.readIfPresent("omega", omega_);
157  dict.readIfPresent("delta", delta_);
158 }
159 
160 
162 {
164  writeEntry(os, "Tc", Tc_);
165  writeEntry(os, "Pc", Pc_);
166  writeEntry(os, "Vc", Vc_);
167  writeEntry(os, "Zc", Zc_);
168  writeEntry(os, "Tt", Tt_);
169  writeEntry(os, "Pt", Pt_);
170  writeEntry(os, "Tb", Tb_);
171  writeEntry(os, "dipm", dipm_);
172  writeEntry(os, "omega", omega_);
173  writeEntry(os, "delta", delta_);
174 }
175 
176 
177 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
178 
180 {
181  l.write(os);
182  return os;
183 }
184 
185 
186 // ************************************************************************* //
scalar delta
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
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.
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.
virtual void write(Ostream &os) const =0
Write the function coefficients.
scalar s(const scalar p, const scalar T) const
Liquid entropy [J/kg/K].
virtual const word & name() const
Return the name of the liquid.
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.
Convenience class to handle the input of constant rotational speed. Reads an omega entry with default...
Definition: omega.H:54
Base-class for thermophysical properties of solids, liquids and gases providing an interface compatib...
virtual void write(Ostream &os) const =0
Write the function coefficients.
void readIfPresent(const dictionary &dict)
Read and set the properties present it the given dictionary.
A class for handling words, derived from string.
Definition: word.H:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for OpenFOAM.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
defineTypeNameAndDebug(combustionModel, 0)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
static const char nl
Definition: Ostream.H:266
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const scalarList W(::W(thermo))
dictionary dict
volScalarField & p