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-2023 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_ = composition().species()[species1Name_];
91  species2Index_ = composition().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  false
143  ).ptr()
144  );
145  speciesModel2_.reset
146  (
148  (
149  dict.subDict(species2Name_),
150  interface,
151  false
152  ).ptr()
153  );
154 }
155 
156 
157 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
158 
160 {}
161 
162 
163 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
164 
166 (
167  const volScalarField& Tf
168 )
169 {
170  const volScalarField W(thermo().W());
171 
172  const volScalarField X1
173  (
174  composition().Y(species1Index_)
175  *W
177  (
178  "W",
180  composition().Wi(species1Index_)
181  )
182  );
183 
184  const volScalarField X2
185  (
186  composition().Y(species2Index_)
187  *W
189  (
190  "W",
192  composition().Wi(species2Index_)
193  )
194  );
195 
196  const volScalarField alpha12(alpha12_ + Tf*beta12_);
197  const volScalarField alpha21(alpha21_ + Tf*beta21_);
198 
199  const volScalarField tau12(saturationModel12_->lnPSat(Tf));
200  const volScalarField tau21(saturationModel21_->lnPSat(Tf));
201 
202  const volScalarField G12(exp(- alpha12*tau12));
203  const volScalarField G21(exp(- alpha21*tau21));
204 
205  gamma1_ =
206  exp
207  (
208  sqr(X2)
209  *(
210  tau21*sqr(G21)/max(sqr(X1 + X2*G21), small)
211  + tau12*G12/max(sqr(X2 + X1*G12), small)
212  )
213  );
214  gamma2_ =
215  exp
216  (
217  sqr(X1)
218  *(
219  tau12*sqr(G12)/max(sqr(X2 + X1*G12), small)
220  + tau21*G21/max(sqr(X1 + X2*G21), small)
221  )
222  );
223 }
224 
225 
228 (
229  const word& speciesName,
230  const volScalarField& Tf
231 ) const
232 {
233  if (speciesName == species1Name_)
234  {
235  return
236  otherComposition().Y(speciesName)
237  *speciesModel1_->Yf(speciesName, Tf)
238  *gamma1_;
239  }
240  else if (speciesName == species2Name_)
241  {
242  return
243  otherComposition().Y(speciesName)
244  *speciesModel2_->Yf(speciesName, Tf)
245  *gamma2_;
246  }
247  else
248  {
249  return
250  composition().Y(speciesName)
251  *(scalar(1) - Yf(species1Name_, Tf) - Yf(species2Name_, Tf));
252  }
253 }
254 
255 
258 (
259  const word& speciesName,
260  const volScalarField& Tf
261 ) const
262 {
263  if (speciesName == species1Name_)
264  {
265  return
266  otherComposition().Y(speciesName)
267  *speciesModel1_->YfPrime(speciesName, Tf)
268  *gamma1_;
269  }
270  else if (speciesName == species2Name_)
271  {
272  return
273  otherComposition().Y(speciesName)
274  *speciesModel2_->YfPrime(speciesName, Tf)
275  *gamma2_;
276  }
277  else
278  {
279  return
280  - composition().Y(speciesName)
281  *(YfPrime(species1Name_, Tf) + YfPrime(species2Name_, Tf));
282  }
283 }
284 
285 
286 // ************************************************************************* //
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
const speciesTable & species() const
Return the table of species.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Generic base class for interface composition models. These models describe the composition in phase 1...
const sidedPhaseInterface & interface() const
Return the interface.
static autoPtr< interfaceCompositionModel > New(const dictionary &dict, const phaseInterface &interface, const bool outer=true)
const basicSpecieMixture & composition() const
Return the composition.
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.
Class to represent an interface between phases. Derivations can further specify the configuration of ...
static autoPtr< saturationPressureModel > New(const dictionary &dict)
Select with dictionary.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
addToRunTimeSelectionTable(interfaceCompositionModel, Henry, dictionary)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensionedScalar exp(const dimensionedScalar &ds)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimless
const dimensionSet dimTemperature
scalarList W(const fluidMulticomponentThermo &thermo)
const dimensionSet dimMoles
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const dimensionSet dimMass
error FatalError
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary dict
basicSpecieMixture & composition
PtrList< volScalarField > & Y
fluidMulticomponentThermo & thermo
Definition: createFields.H:31