standardPhaseChange.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-2018 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "standardPhaseChange.H"
30 #include "thermoSingleLayer.H"
31 #include "zeroField.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace regionModels
38 {
39 namespace surfaceFilmModels
40 {
41 
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 
44 defineTypeNameAndDebug(standardPhaseChange, 0);
45 
47 (
48  phaseChangeModel,
49  standardPhaseChange,
50  dictionary
51 );
52 
53 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
54 
56 (
57  const scalar Re,
58  const scalar Sc
59 ) const
60 {
61  if (Re < 5.0E+05)
62  {
63  return 0.664*sqrt(Re)*cbrt(Sc);
64  }
65  else
66  {
67  return 0.037*pow(Re, 0.8)*cbrt(Sc);
68  }
69 }
70 
71 
72 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
73 
75 (
77  const dictionary& dict
78 )
79 :
80  phaseChangeModel(typeName, film, dict),
81  deltaMin_(coeffDict_.get<scalar>("deltaMin")),
82  L_(coeffDict_.get<scalar>("L")),
83  TbFactor_(coeffDict_.lookupOrDefault<scalar>("TbFactor", 1.1)),
84  YInfZero_(coeffDict_.lookupOrDefault<Switch>("YInfZero", false))
85 {}
86 
87 
88 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
89 
90 template<class YInfType>
92 (
93  const scalar dt,
94  scalarField& availableMass,
95  scalarField& dMass,
96  scalarField& dEnergy,
97  YInfType YInf
98 )
99 {
100  const thermoSingleLayer& film = filmType<thermoSingleLayer>();
101 
102  // Set local thermo properties
103  const SLGThermo& thermo = film.thermo();
104  const filmThermoModel& filmThermo = film.filmThermo();
105  const label vapId = thermo.carrierId(filmThermo.name());
106 
107  // Retrieve fields from film model
108  const scalarField& delta = film.delta();
109  const scalarField& pInf = film.pPrimary();
110  const scalarField& T = film.T();
111  const scalarField& hs = film.hs();
112  const scalarField& rho = film.rho();
113  const scalarField& rhoInf = film.rhoPrimary();
114  const scalarField& muInf = film.muPrimary();
115  const scalarField& magSf = film.magSf();
116  const vectorField dU(film.UPrimary() - film.Us());
117  const scalarField limMass
118  (
119  max(scalar(0), availableMass - deltaMin_*rho*magSf)
120  );
121 
122  // Molecular weight of vapour [kg/kmol]
123  const scalar Wvap = thermo.carrier().W(vapId);
124 
125  // Molecular weight of liquid [kg/kmol]
126  const scalar Wliq = filmThermo.W();
127 
128  forAll(dMass, celli)
129  {
130  scalar dm = 0;
131 
132  if (delta[celli] > deltaMin_)
133  {
134  // Cell pressure [Pa]
135  const scalar pc = pInf[celli];
136 
137  // Calculate the boiling temperature
138  const scalar Tb = filmThermo.Tb(pc);
139 
140  // Local temperature - impose lower limit of 200 K for stability
141  const scalar Tloc = min(TbFactor_*Tb, max(200.0, T[celli]));
142 
143  // Saturation pressure [Pa]
144  const scalar pSat = filmThermo.pv(pc, Tloc);
145 
146  // Latent heat [J/kg]
147  const scalar hVap = filmThermo.hl(pc, Tloc);
148 
149  // Calculate mass transfer
150  if (pSat >= 0.95*pc)
151  {
152  // Boiling
153  const scalar Cp = filmThermo.Cp(pc, Tloc);
154  const scalar Tcorr = max(0.0, T[celli] - Tb);
155  const scalar qCorr = limMass[celli]*Cp*(Tcorr);
156  dm = qCorr/hVap;
157  }
158  else
159  {
160  // Primary region density [kg/m3]
161  const scalar rhoInfc = rhoInf[celli];
162 
163  // Primary region viscosity [Pa.s]
164  const scalar muInfc = muInf[celli];
165 
166  // Reynolds number
167  const scalar Re = rhoInfc*mag(dU[celli])*L_/muInfc;
168 
169  // Vapour mass fraction at interface
170  const scalar Ys = Wliq*pSat/(Wliq*pSat + Wvap*(pc - pSat));
171 
172  // Vapour diffusivity [m2/s]
173  const scalar Dab = filmThermo.D(pc, Tloc);
174 
175  // Schmidt number
176  const scalar Sc = muInfc/(rhoInfc*(Dab + ROOTVSMALL));
177 
178  // Sherwood number
179  const scalar Sh = this->Sh(Re, Sc);
180 
181  // Mass transfer coefficient [m/s]
182  const scalar hm = Sh*Dab/(L_ + ROOTVSMALL);
183 
184  // Add mass contribution to source
185  dm = dt*magSf[celli]*rhoInfc*hm*(Ys - YInf[celli])/(1.0 - Ys);
186  }
187 
188  dMass[celli] += min(limMass[celli], max(dm, 0));
189 
190  // Heat is assumed to be removed by heat-transfer to the wall
191  // so the energy remains unchanged by the phase-change.
192  dEnergy[celli] += dm*hs[celli];
193  // dEnergy[celli] += dm*(hs[celli] + hVap);
194  }
195  }
196 }
197 
198 
200 (
201  const scalar dt,
202  scalarField& availableMass,
203  scalarField& dMass,
204  scalarField& dEnergy
205 )
206 {
207  if (YInfZero_)
208  {
209  correctModel(dt, availableMass, dMass, dEnergy, zeroField());
210  }
211  else
212  {
213  const thermoSingleLayer& film = filmType<thermoSingleLayer>();
214  const label vapId = film.thermo().carrierId(film.filmThermo().name());
215  const scalarField& YInf = film.YPrimary()[vapId];
216 
217  correctModel(dt, availableMass, dMass, dEnergy, YInf);
218  }
219 }
220 
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace surfaceFilmModels
225 } // End namespace regionModels
226 } // End namespace Foam
227 
228 // ************************************************************************* //
Foam::regionModels::surfaceFilmModels::filmThermoModel::Cp
virtual scalar Cp(const scalar p, const scalar T) const =0
Return specific heat capacity [J/kg/K].
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:70
Foam::regionModels::surfaceFilmModels::thermoSingleLayer::hs
virtual const volScalarField & hs() const
Return the film sensible enthalpy [J/kg].
Definition: thermoSingleLayer.C:703
Foam::regionModels::surfaceFilmModels::filmThermoModel::hl
virtual scalar hl(const scalar p, const scalar T) const =0
Return latent heat [J/kg].
Foam::regionModels::surfaceFilmModels::thermoSingleLayer::YPrimary
const PtrList< volScalarField > & YPrimary() const
Specie mass fractions [0-1].
Definition: thermoSingleLayerI.H:130
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::Us
virtual const volVectorField & Us() const
Return the film surface velocity [m/s].
Definition: kinematicSingleLayer.C:987
Foam::SLGThermo
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package,...
Definition: SLGThermo.H:64
Foam::regionModels::surfaceFilmModels::filmThermoModel::W
virtual scalar W() const =0
Return molecular weight [kg/kmol].
Foam::regionModels::surfaceFilmModels::filmThermoModel::name
virtual const word & name() const =0
Return the specie name.
Foam::vtk::Tools::zeroField
vtkSmartPointer< vtkFloatArray > zeroField(const word &name, const label size)
Create named field initialized to zero.
Definition: foamVtkToolsTemplates.C:258
standardPhaseChange.H
Foam::regionModels::surfaceFilmModels::thermoSingleLayer::thermo
const SLGThermo & thermo() const
Return const reference to the SLGThermo object.
Definition: thermoSingleLayerI.H:44
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::UPrimary
const volVectorField & UPrimary() const
Velocity [m/s].
Definition: kinematicSingleLayerI.H:151
Foam::regionModels::surfaceFilmModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(surfaceFilmRegionModel, kinematicSingleLayer, mesh)
rho
rho
Definition: readInitialConditions.H:96
Foam::regionModels::surfaceFilmModels::standardPhaseChange::standardPhaseChange
standardPhaseChange(const standardPhaseChange &)=delete
No copy construct.
Foam::regionModels::surfaceFilmModels::filmThermoModel::Tb
virtual scalar Tb(const scalar p) const =0
Return boiling temperature [K].
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
thermoSingleLayer.H
zeroField.H
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::rhoPrimary
const volScalarField & rhoPrimary() const
Density [kg/m3].
Definition: kinematicSingleLayerI.H:163
Foam::regionModels::surfaceFilmModels::thermoSingleLayer
Thermodynamic form of single-cell layer surface film model.
Definition: thermoSingleLayer.H:67
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::Field< scalar >
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel
Base class for surface film models.
Definition: surfaceFilmRegionModel.H:55
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::filmThermo
const filmThermoModel & filmThermo() const
Film thermo.
Definition: kinematicSingleLayerI.H:175
Foam::regionModels::surfaceFilmModels::standardPhaseChange::Sh
scalar Sh(const scalar Re, const scalar Sc) const
Return Sherwood number as a function of Reynolds and Schmidt numbers.
Definition: standardPhaseChange.C:56
Foam::regionModels::singleLayerRegion::magSf
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
Definition: singleLayerRegion.C:222
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::regionModels::surfaceFilmModels::standardPhaseChange::correctModel
void correctModel(const scalar dt, scalarField &availableMass, scalarField &dMass, scalarField &dEnergy, YInfType YInf)
Definition: standardPhaseChange.C:92
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::pPrimary
const volScalarField & pPrimary() const
Pressure [Pa].
Definition: kinematicSingleLayerI.H:157
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::regionModels::surfaceFilmModels::thermoSingleLayer::T
virtual const volScalarField & T() const
Return the film mean temperature [K].
Definition: thermoSingleLayer.C:685
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::muPrimary
const volScalarField & muPrimary() const
Viscosity [Pa.s].
Definition: kinematicSingleLayerI.H:169
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::regionModels::surfaceFilmModels::filmThermoModel::pv
virtual scalar pv(const scalar p, const scalar T) const =0
Return vapour pressure [Pa].
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::regionModels::surfaceFilmModels::filmThermoModel::D
virtual scalar D(const scalar p, const scalar T) const =0
Return diffusivity [m2/s].
Foam::regionModels::surfaceFilmModels::defineTypeNameAndDebug
defineTypeNameAndDebug(kinematicSingleLayer, 0)
Foam::regionModels::surfaceFilmModels::filmThermoModel
Base class for film thermo models.
Definition: filmThermoModel.H:56
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::delta
const volScalarField & delta() const
Return const access to the film thickness [m].
Definition: kinematicSingleLayerI.H:85
Foam::SLGThermo::carrierId
label carrierId(const word &cmptName, bool allowNotFound=false) const
Index of carrier component.
Definition: SLGThermo.C:150
Foam::Re
scalarField Re(const UList< complex > &cf)
Extract real component.
Definition: complexField.C:159
Cp
const volScalarField & Cp
Definition: EEqn.H:7
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::rho
virtual const volScalarField & rho() const
Return the film density [kg/m3].
Definition: kinematicSingleLayer.C:1011
Foam::cbrt
dimensionedScalar cbrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:155
Foam::regionModels::surfaceFilmModels::phaseChangeModel
Base class for surface film phase change models.
Definition: phaseChangeModel.H:57