Loading...
Searching...
No Matches
diffusionGasEvaporation.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) 2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
29#include "constants.H"
30#include "cutCellIso.H"
32#include "fvcGrad.H"
33
34using namespace Foam::constant;
35
36// * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
37
38template<class Thermo, class OtherThermo>
39void Foam::meltingEvaporationModels::
40diffusionGasEvaporation<Thermo, OtherThermo>::updateInterface
41(
42 const volScalarField& T
43)
44{
45 const fvMesh& mesh = this->mesh_;
46
47 const volScalarField& alpha = this->pair().from();
48
50 (
52 );
53
55
56 forAll(interfaceArea_, celli)
57 {
58 const label status = cutCell.calcSubCell(celli, isoAlpha_);
59 interfaceArea_[celli] = 0;
60 if (status == 0) // cell is cut
61 {
62 interfaceArea_[celli] = mag(cutCell.faceArea())/mesh.V()[celli];
63 }
64 }
66
67
68// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69
70template<class Thermo, class OtherThermo>
73(
74 const dictionary& dict,
75 const phasePair& pair
76)
77:
78 InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
79 saturationModelPtr_
80 (
82 (
83 dict.subDict("saturationPressure"),
84 this->mesh_
85 )
86 ),
87 isoAlpha_(dict.getOrDefault<scalar>("isoAlpha", 0.5)),
88 C_("C", dimless, dict),
89 Tactivate_("Tactivate", dimTemperature, 0, dict),
90 interfaceArea_
91 (
93 (
94 "interfaceArea",
95 this->mesh_.time().timeName(),
96 this->mesh_,
97 IOobject::NO_READ,
98 IOobject::NO_WRITE
99 ),
100 this->mesh_,
102 ),
103 mDotc_
104 (
106 (
107 "mDotc",
108 this->mesh_.time().timeName(),
109 this->mesh_,
110 IOobject::NO_READ,
111 IOobject::AUTO_WRITE
112 ),
113 this->mesh_,
115 )
116{}
118
119// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
120
121template<class Thermo, class OtherThermo>
124::Kexp
125(
126 const volScalarField& T
127)
128{
129 const fvMesh& mesh = this->mesh_;
130
131 const word speciesName(IOobject::member(this->transferSpecie()));
132
133 const typename OtherThermo::thermoType& vapourThermo =
134 this->getLocalThermo
135 (
136 speciesName,
137 this->toThermo_
138 );
139
140 const volScalarField& from = this->pair().from();
141 const volScalarField& to = this->pair().to();
142
143 const volScalarField& Yv = this->toThermo_.composition().Y(speciesName);
144
145 updateInterface(T);
146
147 auto tRhog = volScalarField::New
148 (
149 "tRhog",
151 mesh,
153 );
154 auto& rhog = tRhog.ref();
155
156 rhog = this->pair().to().rho();
157
158 auto tDvg = volScalarField::New
159 (
160 "tDvg",
162 mesh,
164 );
165 auto& Dvg = tDvg.ref();
166
167 Dvg = this->Dto(speciesName);
168
169 tmp<volScalarField> tpSat = saturationModelPtr_->pSat(T);
170
171 const volScalarField XvSat(tpSat()/this->toThermo_.p());
172
173 const dimensionedScalar Wv("Wv", dimMass/dimMoles, vapourThermo.W());
174 const volScalarField YvSat
175 (
176 XvSat
177 *(
178 Wv/(XvSat*Wv + (1-XvSat)*this->toThermo_.W())
179 )
180 );
181
182 const volScalarField Ygm(max(from*YvSat + to*Yv, Zero));
183
184 const multiphaseInterSystem& fluid = this->fluid();
185
186 tmp<volVectorField> tnHatInt(fluid.nVolHatfv(to, from));
187
188 const volScalarField gradYgm(fvc::grad(Ygm) & tnHatInt());
189
190 mDotc_ =
191 -pos(T - Tactivate_)
192 *C_*rhog*Dvg*gradYgm*interfaceArea_
193 /(1 - YvSat);
194
195 if (debug && mesh.time().writeTime())
196 {
197 volScalarField pSat("pSat", saturationModelPtr_->pSat(T));
198 pSat.write();
199
200 volScalarField YvSat1("YvSat", YvSat);
201 YvSat1.write();
202
203 volScalarField YgmDebug("Ygm", Ygm);
204 YgmDebug.write();
205
206 volScalarField gradYgmD("gradYgm", gradYgm);
207 gradYgmD.write();
208
209 volVectorField nHatIntD("nHatInt", tnHatInt());
210 nHatIntD.write();
211 }
221(
222 label variable,
223 const volScalarField& refValue
224)
226 return nullptr;
227}
228
229
230template<class Thermo, class OtherThermo>
233KSu
234(
235 label variable,
236 const volScalarField& refValue
237)
238{
239 return nullptr;
240}
241
242
243//************************************************************************ //
twoPhaseSystem & fluid
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
@ NO_REGISTER
Do not request registration (bool: false).
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
static word member(const word &name)
Return member (name without the extension).
Definition IOobject.C:313
Base class for interface composition models, templated on the two thermodynamic models either side of...
virtual tmp< volScalarField > Dto(const word &speciesName) const
Specie mass diffusivity for specie in a multicomponent.
InterfaceCompositionModel(const dictionary &dict, const phasePair &pair)
Construct from components.
const OtherThermo & toThermo_
Other Thermo (to).
const pureMixture< ThermoType >::thermoType & getLocalThermo(const word &speciesName, const pureMixture< ThermoType > &globalThermo) const
Get a reference to the local thermo for a pure mixture.
static FOAM_NO_DANGLING_REFERENCE const volPointInterpolation & New(const fvMesh &mesh, Args &&... args)
Class for cutting a cell, celli, of an fvMesh, mesh_, at its intersection with an isosurface defined ...
Definition cutCellIso.H:75
Service routines for cutting a cell, celli, of an fvMesh, mesh_, at its intersection with a surface.
Definition cutCell.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Gas diffusion based evaporation/condensation mass transfer model.
virtual tmp< volScalarField > KSu(label modelVariable, const volScalarField &field)
Explicit mass transfer coefficient.
virtual tmp< volScalarField > KSp(label modelVariable, const volScalarField &field)
Implicit mass transfer coefficient.
const word transferSpecie() const
Return the transferring species name.
const multiphaseInterSystem & fluid() const
Return the multiphaseInterSystem this interface belongs to.
static autoPtr< interfaceCompositionModel > New(const dictionary &dict, const phasePair &pair)
const word & variable() const
Returns the variable on which the model is based.
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition phasePair.H:52
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
A class for managing temporary objects.
Definition tmp.H:75
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition tmp.H:215
A class for handling words, derived from Foam::string.
Definition word.H:66
const volScalarField & T
mesh interpolate(rAU)
dynamicFvMesh & mesh
Calculate the gradient of the given field.
word timeName
Definition getTimeIndex.H:3
Different types of constants.
Namespace for handling debugging switches.
Definition debug.C:45
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition fvcGrad.C:47
dimensionedScalar pos(const dimensionedScalar &ds)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
GeometricField< vector, fvPatchField, volMesh > volVectorField
const dimensionSet dimless
Dimensionless.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
const dimensionSet dimMoles(0, 0, 0, 0, 1, 0, 0)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimDensity
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
volScalarField & alpha
dictionary dict
dimensionedScalar rhog("rhog", dimDensity, transportProperties)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299