1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "liquidMixture.H"
28 #include "dictionary.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 const Foam::scalar Foam::liquidMixture::TrMax = 0.999;
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 Foam::liquidMixture::liquidMixture
39 const dictionary& thermophysicalProperties
42 components_(thermophysicalProperties.lookup("liquidComponents")),
43 properties_(components_.size())
45 // use sub-dictionary "liquidProperties" if possible to avoid
46 // collisions with identically named gas-phase entries
47 // (eg, H2O liquid vs. gas)
48 forAll(components_, i)
50 const dictionary* subDictPtr = thermophysicalProperties.subDictPtr
60 liquid::New(subDictPtr->lookup(components_[i]))
68 liquid::New(thermophysicalProperties.lookup(components_[i]))
75 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
77 Foam::autoPtr<Foam::liquidMixture> Foam::liquidMixture::New
79 const dictionary& thermophysicalProperties
82 return autoPtr<liquidMixture>(new liquidMixture(thermophysicalProperties));
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 Foam::scalar Foam::liquidMixture::Tc
97 forAll(properties_, i)
99 scalar x1 = x[i]*properties_[i].Vc();
101 vTc += x1*properties_[i].Tc();
108 Foam::scalar Foam::liquidMixture::Tpc
114 forAll(properties_, i)
116 Tpc += x[i]*properties_[i].Tc();
123 Foam::scalar Foam::liquidMixture::Ppc
130 forAll(properties_, i)
132 Vc += x[i]*properties_[i].Vc();
133 Zc += x[i]*properties_[i].Zc();
136 return specie::RR*Zc*Tpc(x)/Vc;
140 Foam::scalar Foam::liquidMixture::omega
146 forAll(properties_, i)
148 omega += x[i]*properties_[i].omega();
155 Foam::scalarField Foam::liquidMixture::Xs
160 const scalarField& xg,
161 const scalarField& xl
164 scalarField xs(xl.size(), 0.0);
169 scalar Ti = min(TrMax*properties_[i].Tc(), Tl);
170 xs[i] = properties_[i].pv(p, Ti)*xl[i]/p;
176 Foam::scalar Foam::liquidMixture::W
182 forAll(properties_, i)
184 W += x[i]*properties_[i].W();
191 Foam::scalarField Foam::liquidMixture::Y
196 scalarField Y(X/W(X));
200 Y[i] *= properties_[i].W();
207 Foam::scalarField Foam::liquidMixture::X
212 scalarField X(Y.size());
216 Winv += Y[i]/properties_[i].W();
217 X[i] = Y[i]/properties_[i].W();
224 Foam::scalar Foam::liquidMixture::rho
233 forAll(properties_, i)
237 scalar Ti = min(TrMax*properties_[i].Tc(), T);
238 scalar rho = SMALL + properties_[i].rho(p, Ti);
239 v += x[i]*properties_[i].W()/rho;
247 Foam::scalar Foam::liquidMixture::pv
256 forAll(properties_, i)
260 scalar Ti = min(TrMax*properties_[i].Tc(), T);
261 pv += x[i]*properties_[i].pv(p, Ti)*properties_[i].W();
269 Foam::scalar Foam::liquidMixture::hl
278 forAll(properties_, i)
282 scalar Ti = min(TrMax*properties_[i].Tc(), T);
283 hl += x[i]*properties_[i].hl(p, Ti)*properties_[i].W();
291 Foam::scalar Foam::liquidMixture::cp
300 forAll(properties_, i)
304 scalar Ti = min(TrMax*properties_[i].Tc(), T);
305 cp += x[i]*properties_[i].cp(p, Ti)*properties_[i].W();
313 Foam::scalar Foam::liquidMixture::sigma
320 // sigma is based on surface mole fractions
321 // which is estimated from Raoult's Law
323 scalarField Xs(x.size(), 0.0);
325 forAll(properties_, i)
327 scalar Ti = min(TrMax*properties_[i].Tc(), T);
328 scalar Pvs = properties_[i].pv(p, Ti);
329 scalar xs = x[i]*Pvs/p;
334 forAll(properties_, i)
338 scalar Ti = min(TrMax*properties_[i].Tc(), T);
339 sigma += (Xs[i]/XsSum)*properties_[i].sigma(p, Ti);
347 Foam::scalar Foam::liquidMixture::mu
356 forAll(properties_, i)
360 scalar Ti = min(TrMax*properties_[i].Tc(), T);
361 mu += x[i]*log(properties_[i].mu(p, Ti));
369 Foam::scalar Foam::liquidMixture::K
376 // calculate superficial volume fractions phii
377 scalarField phii(x.size(), 0.0);
380 forAll(properties_, i)
382 scalar Ti = min(TrMax*properties_[i].Tc(), T);
384 scalar Vi = properties_[i].W()/properties_[i].rho(p, Ti);
396 forAll(properties_, i)
398 scalar Ti = min(TrMax*properties_[i].Tc(), T);
400 forAll(properties_, j)
402 scalar Tj = min(TrMax*properties_[j].Tc(), T);
407 1.0/properties_[i].K(p, Ti)
408 + 1.0/properties_[j].K(p, Tj)
410 K += phii[i]*phii[j]*Kij;
418 Foam::scalar Foam::liquidMixture::D
428 forAll(properties_, i)
432 scalar Ti = min(TrMax*properties_[i].Tc(), T);
433 Dinv += x[i]/properties_[i].D(p, Ti);
441 // ************************************************************************* //