homogeneousCondensation.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"
28 #include "multicomponentThermo.H"
31 
32 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
40 }
41 }
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 void Foam::fv::homogeneousCondensation::readCoeffs(const dictionary& dict)
46 {
47  saturationModel_.reset
48  (
49  saturationPressureModel::New("pSat", dict).ptr()
50  );
51 }
52 
53 
55 Foam::fv::homogeneousCondensation::dAndMDotByAlphaSolution() const
56 {
57  #define infoFieldVariable(field, print) infoField(#field, field, print)
58 
62 
63  const ThermoRefPair<multicomponentThermo> multicomponentThermos =
64  this->multicomponentThermos(true, false);
65 
66  const multicomponentThermo& thermoGas = multicomponentThermos.first();
67 
68  const volScalarField& p = this->p();
69  const volScalarField& T = thermoGas.T();
70  infoFieldVariable(p, debug);
71  infoFieldVariable(T, debug);
72 
73  // Phase molecular masses and densities
74  const volScalarField::Internal WGas(vfToVif(thermoGas.W()));
75  const volScalarField::Internal rhoGas(vfToVif(thermoGas.rho()));
76  const volScalarField::Internal WLiquid
77  (
78  multicomponentThermos.valid().second()
80  (
81  "W",
82  mesh(),
83  multicomponentThermos.second().Wi(specieis().second())
84  )
85  : vfToVif(thermos().second().W())
86  );
87  const volScalarField::Internal rhoLiquid
88  (
89  multicomponentThermos.valid().second()
90  ? vfToVif(multicomponentThermos.second().rhoi(specieis().second(), p, T))
91  : vfToVif(thermos().second().rho())
92  );
93  infoFieldVariable(WGas, debug);
94  infoFieldVariable(rhoGas, debug);
95  infoFieldVariable(WLiquid, debug);
96  infoFieldVariable(rhoLiquid, debug);
97 
98  // Surface tension
99  const volScalarField::Internal sigma(this->sigma());
100  infoFieldVariable(sigma, debug);
101 
102  // Mole fraction of nucleating specie
103  const volScalarField::Internal Xi
104  (
105  thermoGas.Y()[specieis().first()]*WGas/thermoGas.Wi(specieis().first())
106  );
107 
108  // Saturation pressure and concentration
109  const volScalarField::Internal pSat(saturationModel_->pSat(T()));
110  const volScalarField::Internal cSat(pSat/p()*rhoGas/WGas);
111  infoFieldVariable(pSat, debug);
112  infoFieldVariable(cSat, debug);
113 
114  // Supersaturation of the nucleating specie
115  const volScalarField::Internal S(Xi*p()/pSat);
116  infoFieldVariable(S, true);
117 
118  // Mass and diameter of one molecule in the liquid
119  const volScalarField::Internal mMolc(WLiquid/NNA);
120  const volScalarField::Internal dMolc(cbrt(6/pi*(mMolc/rhoLiquid)));
121  infoFieldVariable(mMolc, debug);
122  infoFieldVariable(dMolc, debug);
123 
124  // Diameter and mass of a nucleus
125  tmp<volScalarField::Internal> td =
126  4*sigma*mMolc/rhoLiquid/(k*T()*log(max(S, 1 + small)));
127  const volScalarField::Internal d = td();
128  const volScalarField::Internal m(pi/6*pow3(d)*rhoLiquid);
129  infoFieldVariable(d, true);
130  infoField("m/mMolc", m/mMolc, debug);
131 
132  // Free energy cost of a nucleus
133  const volScalarField::Internal deltaPhiStar(pi/3*sigma*sqr(d));
134  infoFieldVariable(deltaPhiStar, debug);
135 
136  // ?
137  const volScalarField::Internal betaIStar1
138  (
139  sqrt(6*k*T()*(1/mMolc + 1/m))*sqr(dMolc/2 + d/2)
140  );
141  infoFieldVariable(betaIStar1, debug);
142 
143  // Number-based nucleation rate; i.e., number of nuclei created per second
144  // per unit volume
146  (
147  betaIStar1
148  *sqr(cSat*NNA)
149  *exp(-deltaPhiStar/(k*T()))
150  *sqrt(sigma/(k*T()))
151  *2*mMolc/(pi*sqr(d)*rhoLiquid)
152  );
153  infoFieldVariable(J, debug);
154 
155  return Pair<tmp<volScalarField::Internal>>(td, J*m);
156 
157  #undef infoFieldVariable
158 }
159 
160 
161 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
162 
164 (
165  const word& name,
166  const word& modelType,
167  const fvMesh& mesh,
168  const dictionary& dict
169 )
170 :
171  homogeneousNucleation(name, modelType, mesh, dict),
172  saturationModel_(nullptr)
173 {
174  readCoeffs(coeffs(dict));
175 }
176 
177 
178 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
179 
181 {
183  {
184  readCoeffs(coeffs(dict));
185  return true;
186  }
187  else
188  {
189  return false;
190  }
191 }
192 
193 
194 // ************************************************************************* //
label k
Macros for easy insertion into run-time selection tables.
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const GeoMesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
DimensionedField< Type, GeoMesh, PrimitiveField > Internal
Type of the internal field from which this GeometricField is derived.
An ordered pair of two objects of type <Type> with first() and second() elements.
Definition: Pair.H:67
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
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 liquid droplets out of a gaseous mixture.
virtual bool read(const dictionary &dict)
Read source dictionary.
homogeneousCondensation(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Base class for homogeneous nucleation models based on classical nucleation theory.
virtual bool read(const dictionary &dict)
Read source dictionary.
static autoPtr< saturationPressureModel > New(const word &name, const dictionary &dict)
Select with name within a dictionary.
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Fundamental dimensioned constants.
#define infoFieldVariable(field, print)
rho
Definition: pEqn.H:1
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 > &)
Namespace for OpenFOAM.
dimensionedScalar exp(const dimensionedScalar &ds)
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
dimensionedScalar log(const dimensionedScalar &ds)
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
scalarList W(const fluidMulticomponentThermo &thermo)
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
void pow3(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void cbrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
labelList fv(nPoints)
dictionary dict
volScalarField & p