Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / solvers / multiphase / interPhaseChangeFoam / phaseChangeTwoPhaseMixtures / SchnerrSauer / SchnerrSauer.C
blob3389c68464e0b71a2c49eac7fce8b48a96ffdc51
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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
19     for more details.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "SchnerrSauer.H"
27 #include "mathematicalConstants.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34 namespace phaseChangeTwoPhaseMixtures
36     defineTypeNameAndDebug(SchnerrSauer, 0);
37     addToRunTimeSelectionTable
38     (
39         phaseChangeTwoPhaseMixture,
40         SchnerrSauer,
41         components
42     );
47 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
49 Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::SchnerrSauer
51     const volVectorField& U,
52     const surfaceScalarField& phi,
53     const word& alpha1Name
56     phaseChangeTwoPhaseMixture(typeName, U, phi, alpha1Name),
58     n_(phaseChangeTwoPhaseMixtureCoeffs_.lookup("n")),
59     dNuc_(phaseChangeTwoPhaseMixtureCoeffs_.lookup("dNuc")),
60     Cc_(phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cc")),
61     Cv_(phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cv")),
63     p0_("0", pSat().dimensions(), 0.0)
65     correct();
69 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
71 Foam::tmp<Foam::volScalarField>
72 Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::rRb
74     const volScalarField& limitedAlpha1
75 ) const
77     return pow
78     (
79         ((4*constant::mathematical::pi*n_)/3)
80        *limitedAlpha1/(1.0 + alphaNuc() - limitedAlpha1),
81         1.0/3.0
82     );
86 Foam::dimensionedScalar
87 Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::alphaNuc() const
89     dimensionedScalar Vnuc = n_*constant::mathematical::pi*pow3(dNuc_)/6;
90     return Vnuc/(1 + Vnuc);
94 Foam::tmp<Foam::volScalarField>
95 Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::pCoeff
97     const volScalarField& p
98 ) const
100     volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
101     volScalarField rho
102     (
103         limitedAlpha1*rho1() + (scalar(1) - limitedAlpha1)*rho2()
104     );
106     return
107         (3*rho1()*rho2())*sqrt(2/(3*rho1()))
108        *rRb(limitedAlpha1)/(rho*sqrt(mag(p - pSat()) + 0.01*pSat()));
112 Foam::Pair<Foam::tmp<Foam::volScalarField> >
113 Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotAlphal() const
115     const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
116     volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
118     volScalarField pCoeff(this->pCoeff(p));
120     return Pair<tmp<volScalarField> >
121     (
122         Cc_*limitedAlpha1*pCoeff*max(p - pSat(), p0_),
124         Cv_*(1.0 + alphaNuc() - limitedAlpha1)*pCoeff*min(p - pSat(), p0_)
125     );
129 Foam::Pair<Foam::tmp<Foam::volScalarField> >
130 Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotP() const
132     const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
133     volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
135     volScalarField apCoeff(limitedAlpha1*pCoeff(p));
137     return Pair<tmp<volScalarField> >
138     (
139         Cc_*(1.0 - limitedAlpha1)*pos(p - pSat())*apCoeff,
141         (-Cv_)*(1.0 + alphaNuc() - limitedAlpha1)*neg(p - pSat())*apCoeff
142     );
146 void Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::correct()
150 bool Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::read()
152     if (phaseChangeTwoPhaseMixture::read())
153     {
154         phaseChangeTwoPhaseMixtureCoeffs_ = subDict(type() + "Coeffs");
156         phaseChangeTwoPhaseMixtureCoeffs_.lookup("n") >> n_;
157         phaseChangeTwoPhaseMixtureCoeffs_.lookup("dNuc") >> dNuc_;
158         phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cc") >> Cc_;
159         phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cv") >> Cv_;
161         return true;
162     }
163     else
164     {
165         return false;
166     }
170 // ************************************************************************* //