OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

liquidMixture.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "liquidMixture.H"
00028 #include "dictionary.H"
00029 #include "specie.H"
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 const Foam::scalar Foam::liquidMixture::TrMax = 0.999;
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 Foam::liquidMixture::liquidMixture
00038 (
00039     const dictionary& thermophysicalProperties
00040 )
00041 :
00042     components_(thermophysicalProperties.lookup("liquidComponents")),
00043     properties_(components_.size())
00044 {
00045     // use sub-dictionary "liquidProperties" if possible to avoid
00046     // collisions with identically named gas-phase entries
00047     // (eg, H2O liquid vs. gas)
00048     forAll(components_, i)
00049     {
00050         const dictionary* subDictPtr = thermophysicalProperties.subDictPtr
00051         (
00052             "liquidProperties"
00053         );
00054 
00055         if (subDictPtr)
00056         {
00057             properties_.set
00058             (
00059                 i,
00060                 liquid::New(subDictPtr->lookup(components_[i]))
00061             );
00062         }
00063         else
00064         {
00065             properties_.set
00066             (
00067                 i,
00068                 liquid::New(thermophysicalProperties.lookup(components_[i]))
00069             );
00070         }
00071     }
00072 }
00073 
00074 
00075 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00076 
00077 Foam::autoPtr<Foam::liquidMixture> Foam::liquidMixture::New
00078 (
00079     const dictionary& thermophysicalProperties
00080 )
00081 {
00082     return autoPtr<liquidMixture>(new liquidMixture(thermophysicalProperties));
00083 }
00084 
00085 
00086 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00087 
00088 Foam::scalar Foam::liquidMixture::Tc
00089 (
00090     const scalarField& x
00091 ) const
00092 {
00093 
00094     scalar vTc = 0.0;
00095     scalar vc = 0.0;
00096 
00097     forAll(properties_, i)
00098     {
00099         scalar x1 = x[i]*properties_[i].Vc();
00100         vc += x1;
00101         vTc += x1*properties_[i].Tc();
00102     }
00103 
00104     return vTc/vc;
00105 }
00106 
00107 
00108 Foam::scalar Foam::liquidMixture::Tpc
00109 (
00110     const scalarField& x
00111 ) const
00112 {
00113     scalar Tpc = 0.0;
00114     forAll(properties_, i)
00115     {
00116         Tpc += x[i]*properties_[i].Tc();
00117     }
00118 
00119     return Tpc;
00120 }
00121 
00122 
00123 Foam::scalar Foam::liquidMixture::Ppc
00124 (
00125     const scalarField& x
00126 ) const
00127 {
00128     scalar Vc = 0.0;
00129     scalar Zc = 0.0;
00130     forAll(properties_, i)
00131     {
00132         Vc += x[i]*properties_[i].Vc();
00133         Zc += x[i]*properties_[i].Zc();
00134     }
00135 
00136     return specie::RR*Zc*Tpc(x)/Vc;
00137 }
00138 
00139 
00140 Foam::scalar Foam::liquidMixture::omega
00141 (
00142     const scalarField& x
00143 ) const
00144 {
00145     scalar omega = 0.0;
00146     forAll(properties_, i)
00147     {
00148         omega += x[i]*properties_[i].omega();
00149     }
00150 
00151     return omega;
00152 }
00153 
00154 
00155 Foam::scalarField Foam::liquidMixture::Xs
00156 (
00157     const scalar p,
00158     const scalar Tg,
00159     const scalar Tl,
00160     const scalarField& xg,
00161     const scalarField& xl
00162 ) const
00163 {
00164     scalarField xs(xl.size(), 0.0);
00165 
00166     // Raoult's Law
00167     forAll(xs, i)
00168     {
00169         scalar Ti = min(TrMax*properties_[i].Tc(), Tl);
00170         xs[i] = properties_[i].pv(p, Ti)*xl[i]/p;
00171     }
00172     return xs;
00173 }
00174 
00175 
00176 Foam::scalar Foam::liquidMixture::W
00177 (
00178     const scalarField& x
00179 ) const
00180 {
00181     scalar W = 0.0;
00182     forAll(properties_, i)
00183     {
00184         W += x[i]*properties_[i].W();
00185     }
00186 
00187     return W;
00188 }
00189 
00190 
00191 Foam::scalarField Foam::liquidMixture::Y
00192 (
00193     const scalarField& X
00194 ) const
00195 {
00196     scalarField Y(X/W(X));
00197 
00198     forAll(Y, i)
00199     {
00200         Y[i] *= properties_[i].W();
00201     }
00202 
00203     return Y;
00204 }
00205 
00206 
00207 Foam::scalarField Foam::liquidMixture::X
00208 (
00209     const scalarField& Y
00210 ) const
00211 {
00212     scalarField X(Y.size());
00213     scalar Winv = 0.0;
00214     forAll(X, i)
00215     {
00216         Winv += Y[i]/properties_[i].W();
00217         X[i] = Y[i]/properties_[i].W();
00218     }
00219 
00220     return X/Winv;
00221 }
00222 
00223 
00224 Foam::scalar Foam::liquidMixture::rho
00225 (
00226     const scalar p,
00227     const scalar T,
00228     const scalarField& x
00229 ) const
00230 {
00231     scalar v = 0.0;
00232 
00233     forAll(properties_, i)
00234     {
00235         if (x[i] > SMALL)
00236         {
00237             scalar Ti = min(TrMax*properties_[i].Tc(), T);
00238             scalar rho = SMALL + properties_[i].rho(p, Ti);
00239             v += x[i]*properties_[i].W()/rho;
00240         }
00241     }
00242 
00243     return W(x)/v;
00244 }
00245 
00246 
00247 Foam::scalar Foam::liquidMixture::pv
00248 (
00249     const scalar p,
00250     const scalar T,
00251     const scalarField& x
00252 ) const
00253 {
00254     scalar pv = 0.0;
00255 
00256     forAll(properties_, i)
00257     {
00258         if (x[i] > SMALL)
00259         {
00260             scalar Ti = min(TrMax*properties_[i].Tc(), T);
00261             pv += x[i]*properties_[i].pv(p, Ti)*properties_[i].W();
00262         }
00263     }
00264 
00265     return pv/W(x);
00266 }
00267 
00268 
00269 Foam::scalar Foam::liquidMixture::hl
00270 (
00271     const scalar p,
00272     const scalar T,
00273     const scalarField& x
00274 ) const
00275 {
00276     scalar hl = 0.0;
00277 
00278     forAll(properties_, i)
00279     {
00280         if (x[i] > SMALL)
00281         {
00282             scalar Ti = min(TrMax*properties_[i].Tc(), T);
00283             hl += x[i]*properties_[i].hl(p, Ti)*properties_[i].W();
00284         }
00285     }
00286 
00287     return hl/W(x);
00288 }
00289 
00290 
00291 Foam::scalar Foam::liquidMixture::cp
00292 (
00293     const scalar p,
00294     const scalar T,
00295     const scalarField& x
00296 ) const
00297 {
00298     scalar cp = 0.0;
00299 
00300     forAll(properties_, i)
00301     {
00302         if (x[i] > SMALL)
00303         {
00304             scalar Ti = min(TrMax*properties_[i].Tc(), T);
00305             cp += x[i]*properties_[i].cp(p, Ti)*properties_[i].W();
00306         }
00307     }
00308 
00309     return cp/W(x);
00310 }
00311 
00312 
00313 Foam::scalar Foam::liquidMixture::sigma
00314 (
00315     const scalar p,
00316     const scalar T,
00317     const scalarField& x
00318 ) const
00319 {
00320     // sigma is based on surface mole fractions
00321     // which is estimated from Raoult's Law
00322     scalar sigma = 0.0;
00323     scalarField Xs(x.size(), 0.0);
00324     scalar XsSum = 0.0;
00325     forAll(properties_, i)
00326     {
00327         scalar Ti = min(TrMax*properties_[i].Tc(), T);
00328         scalar Pvs = properties_[i].pv(p, Ti);
00329         scalar xs = x[i]*Pvs/p;
00330         XsSum += xs;
00331         Xs[i] = xs;
00332     }
00333 
00334     forAll(properties_, i)
00335     {
00336         if (Xs[i] > SMALL)
00337         {
00338             scalar Ti = min(TrMax*properties_[i].Tc(), T);
00339             sigma += (Xs[i]/XsSum)*properties_[i].sigma(p, Ti);
00340         }
00341     }
00342 
00343     return sigma;
00344 }
00345 
00346 
00347 Foam::scalar Foam::liquidMixture::mu
00348 (
00349     const scalar p,
00350     const scalar T,
00351     const scalarField& x
00352 ) const
00353 {
00354     scalar mu = 0.0;
00355 
00356     forAll(properties_, i)
00357     {
00358         if (x[i] > SMALL)
00359         {
00360             scalar Ti = min(TrMax*properties_[i].Tc(), T);
00361             mu += x[i]*log(properties_[i].mu(p, Ti));
00362         }
00363     }
00364 
00365     return exp(mu);
00366 }
00367 
00368 
00369 Foam::scalar Foam::liquidMixture::K
00370 (
00371     const scalar p,
00372     const scalar T,
00373     const scalarField& x
00374 ) const
00375 {
00376     // calculate superficial volume fractions phii
00377     scalarField phii(x.size(), 0.0);
00378     scalar pSum = 0.0;
00379 
00380     forAll(properties_, i)
00381     {
00382         scalar Ti = min(TrMax*properties_[i].Tc(), T);
00383 
00384         scalar Vi = properties_[i].W()/properties_[i].rho(p, Ti);
00385         phii[i] = x[i]*Vi;
00386         pSum += phii[i];
00387     }
00388 
00389     forAll(phii, i)
00390     {
00391         phii[i] /= pSum;
00392     }
00393 
00394     scalar K = 0.0;
00395 
00396     forAll(properties_, i)
00397     {
00398         scalar Ti = min(TrMax*properties_[i].Tc(), T);
00399 
00400         forAll(properties_, j)
00401         {
00402             scalar Tj = min(TrMax*properties_[j].Tc(), T);
00403 
00404             scalar Kij =
00405                 2.0
00406                /(
00407                     1.0/properties_[i].K(p, Ti)
00408                   + 1.0/properties_[j].K(p, Tj)
00409                 );
00410             K += phii[i]*phii[j]*Kij;
00411         }
00412     }
00413 
00414     return K;
00415 }
00416 
00417 
00418 Foam::scalar Foam::liquidMixture::D
00419 (
00420     const scalar p,
00421     const scalar T,
00422     const scalarField& x
00423 ) const
00424 {
00425     // Blanc's law
00426     scalar Dinv = 0.0;
00427 
00428     forAll(properties_, i)
00429     {
00430         if (x[i] > SMALL)
00431         {
00432             scalar Ti = min(TrMax*properties_[i].Tc(), T);
00433             Dinv += x[i]/properties_[i].D(p, Ti);
00434         }
00435     }
00436 
00437     return 1.0/Dinv;
00438 }
00439 
00440 
00441 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd