homogeneousLiquidPhaseSeparation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2024-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "fundamentalConstants.H"
30 #include "phaseSystem.H"
32 
33 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace fv
38 {
41  (
42  fvModel,
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
52 void Foam::fv::homogeneousLiquidPhaseSeparation::readCoeffs
53 (
54  const dictionary& dict
55 )
56 {
58 
59  solubilityCurve_.reset
60  (
62  (
63  "solubility",
66  dict
67  ).ptr()
68  );
69 }
70 
71 
73 Foam::fv::homogeneousLiquidPhaseSeparation::YSat
74 (
76 ) const
77 {
78  return
80  (
81  name() + ":YSat",
82  mesh(),
83  dimless,
84  solubilityCurve_->value(T)
85  );
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
90 
92 (
93  const word& name,
94  const word& modelType,
95  const fvMesh& mesh,
96  const dictionary& dict
97 )
98 :
99  phaseChange(name, modelType, mesh, dict, readSpecie(dict, true)),
100  fluid_
101  (
102  mesh().lookupObject<phaseSystem>(phaseSystem::propertiesName)
103  ),
104  d_
105  (
106  IOobject
107  (
108  name + ":d",
109  mesh.time().name(),
110  mesh,
111  IOobject::READ_IF_PRESENT,
112  IOobject::AUTO_WRITE
113  ),
114  mesh,
116  ),
117  mDotByAlphaSolution_
118  (
119  IOobject
120  (
121  name + ":mDotByAlpha",
122  mesh.time().name(),
123  mesh,
124  IOobject::READ_IF_PRESENT,
125  IOobject::AUTO_WRITE
126  ),
127  mesh,
129  ),
130  solubilityCurve_(nullptr)
131 {
132  readCoeffs(coeffs(dict));
133 }
134 
135 
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137 
140 {
141  return d_;
142 }
143 
144 
147 {
148  const volScalarField::Internal& alphaSolution =
149  mesh().lookupObject<volScalarField::Internal>(alphaNames().first());
150 
151  const ThermoRefPair<multicomponentThermo> multicomponentThermos =
152  this->multicomponentThermos(true, false);
153 
154  const multicomponentThermo& thermoSolution = multicomponentThermos.first();
155 
156  const volScalarField& p = this->p();
157  const volScalarField& T = thermoSolution.T();
158 
159  const volScalarField::Internal rhoPrecipitate
160  (
161  multicomponentThermos.valid().second()
162  ? vfToVif(multicomponentThermos.second().rhoi(specieis().second(), p, T))
163  : vfToVif(thermos().second().rho())
164  );
165 
167 
168  return alphaSolution*mDotByAlphaSolution_/(rhoPrecipitate*v);
169 }
170 
171 
174 {
175  const volScalarField::Internal& alphaSolution =
176  mesh().lookupObject<volScalarField::Internal>(alphaNames().first());
177 
178  return alphaSolution*mDotByAlphaSolution_;
179 }
180 
181 
184 {
185  static const dimensionedScalar mDotRootVSmall
186  (
188  rootVSmall
189  );
190 
191  const ThermoRefPair<multicomponentThermo> multicomponentThermos =
192  this->multicomponentThermos(true, false);
193 
194  const multicomponentThermo& thermoSolution = multicomponentThermos.first();
195 
196  // Solution density
197  const volScalarField::Internal rhoSolution(vfToVif(thermoSolution.rho()));
198 
199  // Mass fraction of nucleating specie
200  const volScalarField::Internal Yi = thermoSolution.Y()[specieis().first()];
201 
202  return Yi*rhoSolution/max(mDotByAlphaSolution_, mDotRootVSmall);
203 }
204 
205 
207 {
208  #define DebugField(field) \
209  DebugInfo \
210  << name() << ": " \
211  << #field << ' ' << field.dimensions() << " min/avg/max = " \
212  << gMin(field) << '/' << gAverage(field) << '/' << gMax(field) \
213  << nl;
214 
218 
219  const ThermoRefPair<multicomponentThermo> multicomponentThermos =
220  this->multicomponentThermos(true, false);
221 
222  const fluidMulticomponentThermo& thermoSolution =
223  this->fluidMulticomponentThermos(true, false).first();
224 
225  const volScalarField& p = this->p();
226  const volScalarField& T = thermoSolution.T();
227  DebugField(p);
228  DebugField(T);
229 
230  // Phase molecular masses and densities
231  const volScalarField::Internal rhoSolution(vfToVif(thermoSolution.rho()));
232  const volScalarField::Internal muSolution(vfToVif(thermoSolution.mu()));
233  const volScalarField::Internal WPrecipitate
234  (
235  multicomponentThermos.valid().second()
237  (
238  "W",
239  mesh(),
240  multicomponentThermos.second().Wi(specieis().second())
241  )
242  : vfToVif(thermos().second().W())
243  );
244  const volScalarField::Internal rhoPrecipitate
245  (
246  multicomponentThermos.valid().second()
247  ? vfToVif(multicomponentThermos.second().rhoi(specieis().second(), p, T))
248  : vfToVif(thermos().second().rho())
249  );
250  DebugField(rhoSolution);
251  DebugField(WPrecipitate);
252  DebugField(rhoPrecipitate);
253 
254  // Surface tension
256  (
257  fluid_.sigma
258  (
260  (
261  fluid_.phases()[phaseNames().first()],
262  fluid_.phases()[phaseNames().second()]
263  )
264  )
265  );
266  DebugField(sigma);
267 
268  // Mass fraction of nucleating specie
269  const volScalarField::Internal Yi = thermoSolution.Y()[specieis().first()];
270 
271  // Saturation mass fraction and concentration
272  const volScalarField::Internal solubility
273  (
275  (
276  "YSat",
277  mesh(),
278  dimless,
279  solubilityCurve_->value(T)
280  )
281  );
282  const volScalarField::Internal YSat(solubility/(solubility + 1));
283  const volScalarField::Internal cSat(YSat*rhoSolution/WPrecipitate);
284  DebugField(YSat);
285  DebugField(cSat);
286 
287  // Supersaturation of the nucleating specie
288  const volScalarField::Internal S(Yi/YSat);
289  DebugField(S);
290 
291  // Mass and volume of one molecule in the precipitate
292  const volScalarField::Internal mMolc(WPrecipitate/NNA);
293  const volScalarField::Internal vMolc(mMolc/rhoPrecipitate);
294  const volScalarField::Internal dMolc(cbrt(6/pi*vMolc));
295  DebugField(mMolc);
296  DebugField(vMolc);
297  DebugField(dMolc);
298 
299  // Diameter of nuclei
300  d_ = 4*sigma*vMolc/(k*T()*log(max(S, 1 + small)));
301  DebugField(d_);
302 
303  // ?
304  const volScalarField::Internal deltaPhiStar(pi/3*sigma*sqr(d_));
305  DebugField(deltaPhiStar);
306 
307  // Ratio of nucleus volume to molecular volume
308  const volScalarField::Internal iStar(pi/6*pow3(d_)/vMolc);
309  DebugField(iStar);
310 
311  // Number-based nucleation rate; i.e., number of nuclei created per second
312  // per unit volume
314  (
315  cSat*NNA*k*T()/(3*pi*pow3(dMolc)*muSolution)*exp(-deltaPhiStar/(k*T()))
316  );
317  DebugField(J);
318 
319  // Mass transfer rate
320  mDotByAlphaSolution_ = J*iStar*mMolc;
321  DebugField(mDotByAlphaSolution_);
322 
323  #undef DebugField
324 }
325 
326 
328 (
329  const volScalarField& alpha,
330  const volScalarField& rho,
331  fvMatrix<scalar>& eqn
332 ) const
333 {
334  const label i = index(alphaNames(), eqn.psi().name());
335 
336  // !!! Note at present multiphaseEuler cannot linearise w.r.t alphaA in the
337  // continuity equation for alphaB. So we can only create a linearised
338  // source for this model in the solution volume-fraction equation.
339 
340  if (i == 0)
341  {
342  eqn -= fvm::Sp(mDotByAlphaSolution_, eqn.psi());
343  }
344  else
345  {
347  }
348 }
349 
350 
352 {
353  if (phaseChange::read(dict))
354  {
355  readCoeffs(coeffs(dict));
356  return true;
357  }
358  else
359  {
360  return false;
361  }
362 }
363 
364 
365 // ************************************************************************* //
label k
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Mesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
static autoPtr< Function1< scalar > > New(const word &name, const Function1s::unitConversions &units, const dictionary &dict)
Select from dictionary.
Definition: Function1New.C:32
Generic GeometricField class.
DimensionedField< Type, GeoMesh, PrimitiveField > Internal
Type of the internal field from which this GeometricField is derived.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const Type & second() const
Return second.
Definition: PairI.H:121
Class containing a pair of thermo references. Handles down-casting to more specific thermo types by c...
Definition: ThermoRefPair.H:51
const Pair< bool > & valid() const
Access the validity flags.
const ThermoType & first() const
Access the first thermo.
const ThermoType & second() const
Access the second thermo.
virtual const volScalarField & T() const =0
Temperature [K].
virtual tmp< volScalarField > rho() const =0
Density [kg/m^3].
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Base-class for multi-component fluid thermodynamic properties.
virtual const volScalarField & mu() const =0
Dynamic viscosity of mixture [kg/m/s].
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
VolField< Type > & psi()
Definition: fvMatrix.H:289
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
Model for the homogeneous nucleation of a solid or liquid phase separating out of a liquid solution.
homogeneousLiquidPhaseSeparation(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
virtual tmp< DimensionedField< scalar, volMesh > > mDot() const
Return the mass transfer rate.
virtual bool read(const dictionary &dict)
Read source dictionary.
void addSup(const volScalarField &alpha, const volScalarField &rho, const volScalarField &heOrYi, fvMatrix< scalar > &eqn) const
Use phaseChange's source functions.
Definition: phaseChange.C:551
virtual tmp< DimensionedField< scalar, volMesh > > d() const
Return the diameter of nuclei.
virtual tmp< DimensionedField< scalar, volMesh > > tau() const
Return the nucleation time scale.
virtual tmp< DimensionedField< scalar, volMesh > > nDot() const
Return the number rate at which nuclei are generated.
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: massTransfer.C:225
Base class for phase change models.
Definition: phaseChange.H:61
void reReadSpecie(const dictionary &dict) const
Re-read the names of the transferring specie.
Definition: phaseChange.C:129
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: phaseChange.C:624
Base-class for multi-component thermodynamic properties.
virtual PtrList< volScalarField > & Y()=0
Access the mass-fraction fields.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Class to represent an interface between phases. Derivations can further specify the configuration of ...
Class to represent a system of phases.
Definition: phaseSystem.H:74
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Fundamental dimensioned constants.
#define DebugField(field)
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const dimensionedScalar k
Boltzmann constant.
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
const dimensionedScalar NNA
Avagadro number: default SI units: [1/kmol].
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
Namespace for OpenFOAM.
dimensionedScalar exp(const dimensionedScalar &ds)
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:59
const dimensionSet dimless
void T(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
const dimensionSet dimLength
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
const dimensionSet dimTemperature
dimensionedScalar log(const dimensionedScalar &ds)
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
const dimensionSet dimTime
scalarList W(const fluidMulticomponentThermo &thermo)
const dimensionSet dimDensity
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void pow3(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void cbrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
const unitConversion unitFraction
labelList fv(nPoints)
dictionary dict
volScalarField & p