nonRandomTwoLiquid.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) 2015-2026 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 
26 #include "nonRandomTwoLiquid.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace interfaceCompositionModels
34 {
37  (
41  );
42 }
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const dictionary& dict,
51  const phaseInterface& interface
52 )
53 :
54  interfaceCompositionModel(dict, interface),
55  gamma1_
56  (
57  IOobject
58  (
59  IOobject::groupName("gamma1", this->interface().name()),
60  interface.mesh().time().name(),
61  interface.mesh()
62  ),
63  interface.mesh(),
65  ),
66  gamma2_
67  (
68  IOobject
69  (
70  IOobject::groupName("gamma2", this->interface().name()),
71  interface.mesh().time().name(),
72  interface.mesh()
73  ),
74  interface.mesh(),
76  ),
77  beta12_("", dimless/dimTemperature, 0),
78  beta21_("", dimless/dimTemperature, 0)
79 {
80  if (species().size() != 2)
81  {
83  << "nonRandomTwoLiquid model is suitable for two species only."
84  << exit(FatalError);
85  }
86 
87  species1Name_ = species()[0];
88  species2Name_ = species()[1];
89 
90  species1Index_ = thermo().species()[species1Name_];
91  species2Index_ = thermo().species()[species2Name_];
92 
93  alpha12_ = dimensionedScalar
94  (
95  "alpha12",
96  dimless,
97  dict.subDict(species1Name_).lookup("alpha")
98  );
99  alpha21_ = dimensionedScalar
100  (
101  "alpha21",
102  dimless,
103  dict.subDict(species2Name_).lookup("alpha")
104  );
105 
106  beta12_ = dimensionedScalar
107  (
108  "beta12",
110  dict.subDict(species1Name_).lookup("beta")
111  );
112  beta21_ = dimensionedScalar
113  (
114  "beta21",
116  dict.subDict(species2Name_).lookup("beta")
117  );
118 
119  saturationModel12_.reset
120  (
122  (
123  "interaction",
124  dict.subDict(species1Name_)
125  ).ptr()
126  );
127  saturationModel21_.reset
128  (
130  (
131  "interaction",
132  dict.subDict(species2Name_)
133  ).ptr()
134  );
135 
136  speciesModel1_.reset
137  (
139  (
140  dict.subDict(species1Name_),
141  interface
142  ).ptr()
143  );
144  speciesModel2_.reset
145  (
147  (
148  dict.subDict(species2Name_),
149  interface
150  ).ptr()
151  );
152 }
153 
154 
155 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
156 
158 {}
159 
160 
161 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
162 
164 (
165  const volScalarField& Tf
166 )
167 {
168  const volScalarField W(thermo().W());
169 
170  const volScalarField X1
171  (
172  thermo().Y(species1Index_)*W/thermo().Wi(species1Index_)
173  );
174 
175  const volScalarField X2
176  (
177  thermo().Y(species2Index_)*W/thermo().Wi(species2Index_)
178  );
179 
180  const volScalarField alpha12(alpha12_ + Tf*beta12_);
181  const volScalarField alpha21(alpha21_ + Tf*beta21_);
182 
183  const volScalarField tau12(saturationModel12_->lnPSat(Tf));
184  const volScalarField tau21(saturationModel21_->lnPSat(Tf));
185 
186  const volScalarField G12(exp(- alpha12*tau12));
187  const volScalarField G21(exp(- alpha21*tau21));
188 
189  gamma1_ =
190  exp
191  (
192  sqr(X2)
193  *(
194  tau21*sqr(G21)/max(sqr(X1 + X2*G21), small)
195  + tau12*G12/max(sqr(X2 + X1*G12), small)
196  )
197  );
198  gamma2_ =
199  exp
200  (
201  sqr(X1)
202  *(
203  tau12*sqr(G12)/max(sqr(X2 + X1*G12), small)
204  + tau21*G21/max(sqr(X1 + X2*G21), small)
205  )
206  );
207 }
208 
209 
212 (
213  const word& speciesName,
214  const volScalarField& Tf
215 ) const
216 {
217  if (speciesName == species1Name_)
218  {
219  return
220  otherMulticomponentThermo().Y(speciesName)
221  *speciesModel1_->Yf(speciesName, Tf)
222  *gamma1_;
223  }
224  else if (speciesName == species2Name_)
225  {
226  return
227  otherMulticomponentThermo().Y(speciesName)
228  *speciesModel2_->Yf(speciesName, Tf)
229  *gamma2_;
230  }
231  else
232  {
233  return
234  thermo().Y(speciesName)
235  *(scalar(1) - Yf(species1Name_, Tf) - Yf(species2Name_, Tf));
236  }
237 }
238 
239 
242 (
243  const word& speciesName,
244  const volScalarField& Tf
245 ) const
246 {
247  if (speciesName == species1Name_)
248  {
249  return
250  otherMulticomponentThermo().Y(speciesName)
251  *speciesModel1_->YfPrime(speciesName, Tf)
252  *gamma1_;
253  }
254  else if (speciesName == species2Name_)
255  {
256  return
257  otherMulticomponentThermo().Y(speciesName)
258  *speciesModel2_->YfPrime(speciesName, Tf)
259  *gamma2_;
260  }
261  else
262  {
263  return
264  - thermo().Y(speciesName)
265  *(YfPrime(species1Name_, Tf) + YfPrime(species2Name_, Tf));
266  }
267 }
268 
269 
270 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Generic base class for interface composition models. These models describe the composition in phase 1...
const sidedPhaseInterface & interface() const
Return the interface.
const rhoFluidMulticomponentThermo & thermo() const
Return the thermo.
static autoPtr< interfaceCompositionModel > New(const dictionary &dict, const phaseInterface &interface, const bool outer=false)
const hashedWordList & species() const
Return the transferring species names.
Non ideal law for the mixing of two species. A separate composition model is given for each species....
virtual void update(const volScalarField &Tf)
Update the composition.
nonRandomTwoLiquid(const dictionary &dict, const phaseInterface &interface)
Construct from a dictionary and an interface.
virtual tmp< volScalarField > Yf(const word &speciesName, const volScalarField &Tf) const
The interface species fraction.
virtual tmp< volScalarField > YfPrime(const word &speciesName, const volScalarField &Tf) const
The interface species fraction derivative w.r.t. temperature.
virtual const speciesTable & species() const =0
Return the table of species.
Class to represent an interface between phases. Derivations can further specify the configuration of ...
static autoPtr< saturationPressureModel > New(const word &name, const dictionary &dict)
Select with name within a dictionary.
A class for managing temporary objects.
Definition: tmp.H:55
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)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const dimensionSet dimless
const dimensionSet time
addToRunTimeSelectionTable(interfaceCompositionModel, Henry, dictionary)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dimensionedScalar exp(const dimensionedScalar &ds)
const dimensionSet & dimless
Definition: dimensions.C:138
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
scalarList W(const fluidMulticomponentThermo &thermo)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
const dimensionSet & dimTemperature
Definition: dimensions.C:143
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict
PtrList< volScalarField > & Y
fluidMulticomponentThermo & thermo
Definition: createFields.H:15