[05910c]: / src / thermophysicalModels / specie / equationOfState / mixtureRedlichKwong / mixtureRedlichKwongI.H  Maximize  Restore  History

Download this file

209 lines (166 with data), 6.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut f��r Thermodynamik
Technische Universit��t Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "mixtureRedlichKwong.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
// CL: needed for operator*
inline mixtureRedlichKwong::mixtureRedlichKwong
(
const redlichKwong& rK,
label numOfComp,
DynamicList<scalar> weigths,
DynamicList<mixtureRedlichKwong*> mixtureComponents,
scalar a,
scalar b,
scalar rhostd
)
:
redlichKwong(rK),
numOfComp(numOfComp),
weigths(weigths),
mixtureComponents(mixtureComponents)
{
a_=a;
b_=b;
rhostd_=rhostd;
}
// Construct from components
// CL: needed for operator+
inline mixtureRedlichKwong::mixtureRedlichKwong
(
const redlichKwong& rK,
label numOfComp,
DynamicList<scalar> weigths,
DynamicList<mixtureRedlichKwong*> mixtureComponents
)
:
redlichKwong(rK),
numOfComp(numOfComp),
weigths(weigths),
mixtureComponents(mixtureComponents)
{
//CL: update model coefficients
updateModelCoefficients();
rhostd_=this->rho(Pstd, Tstd, Pstd/(Tstd*this->R()));
}
// Construct as named copy
inline mixtureRedlichKwong::mixtureRedlichKwong(const word& name, const mixtureRedlichKwong& rK)
:
redlichKwong(name, rK)
{}
// Construct and return a clone
inline autoPtr<mixtureRedlichKwong> mixtureRedlichKwong::clone() const
{
return autoPtr<mixtureRedlichKwong>(new mixtureRedlichKwong(*this));
}
// Selector from Istream
inline autoPtr<mixtureRedlichKwong> mixtureRedlichKwong::New(Istream& is)
{
return autoPtr<mixtureRedlichKwong>(new mixtureRedlichKwong(is));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//CL: updates the coefficents of the model after the final construction of the mixture
//CL: uses the van der waals mixing rule
inline void mixtureRedlichKwong::updateModelCoefficients() const
{
label i,j;
a_=0;
b_=0;
for (i=0;i<numOfComp;i++)
{
//CL: getting a for the mixture
//CL: using van der waals mixing rule
//CL: TODO: Include possibility to use coupling cofficients k_ij (see paper reference)
for (j=0;j<numOfComp;j++)
{
a_=a_+weigths[i]*weigths[j]*pow(mixtureComponents[i]->a()*mixtureComponents[j]->a(),0.5)*this->W()*this->W();
}
//CL: getting b for the mixture
//CL: using van der waals mixing rule
b_=b_+weigths[i]*mixtureComponents[i]->b()*this->W();
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void mixtureRedlichKwong::operator+=(const mixtureRedlichKwong& rK)
{
//CL: Resizes the DynamicList if number of compontens is larger than the DynamicList
if((weigths.size()<numOfComp+1)||(mixtureComponents.size()<numOfComp+1))
{
weigths.setSize(2*numOfComp);
mixtureComponents.setSize(2*numOfComp);
}
//Cl: oldClass+=rK
//CL: Saving the object pointer and weigths of rK (which is @ mixtureComponents[0] and weigths[0]) at the numOfComp's value of the oldClass
weigths[numOfComp]=rK.weigths[0];
mixtureComponents[numOfComp]=rK.mixtureComponents[0];
redlichKwong::operator+=(rK);
//CL: increase number of Components by 1
numOfComp=numOfComp+1;
//CL: update model coefficients
updateModelCoefficients();
rhostd_=this->rho(Pstd, Tstd, Pstd/(Tstd*this->R()));
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
inline mixtureRedlichKwong operator+
(
const mixtureRedlichKwong& rK1,
const mixtureRedlichKwong& rK2
)
{
//CL:save both a pointer to the objector rK1 and rK2 and the weights in the new object
DynamicList<scalar> weigths=rK1.weigths;
DynamicList<mixtureRedlichKwong*> mixtureComponents=rK1.mixtureComponents;
//CL: Resizes the DynamicList if number of compontens is larger than the DynamicList
if((weigths.size()<rK1.numOfComp+1)||(mixtureComponents.size()<rK1.numOfComp+1))
{
weigths.setSize(2*rK1.numOfComp);
mixtureComponents.setSize(2*rK1.numOfComp);
}
//CL: Getting the new weigths and mixtureComponents lists,
//CL: Saving the object pointer and weigths of rK2 (which is @ mixtureComponents[0] and weigths[0]) at the numOfComp's value of the new object
weigths[rK1.numOfComp]=rK2.weigths[0];
mixtureComponents[rK1.numOfComp]=rK2.mixtureComponents[0];
return mixtureRedlichKwong(static_cast<const redlichKwong&>(rK1)+static_cast<const redlichKwong&>(rK2),
rK1.numOfComp+1, weigths, mixtureComponents);
}
inline mixtureRedlichKwong operator*
(
const scalar s,
const mixtureRedlichKwong& rK
)
{
//CL: saving the "concentraction" of the component of the mixture in the vector weights
DynamicList<scalar> weigths=rK.weigths;
weigths[rK.numOfComp-1]=s*rK.nMoles();
return mixtureRedlichKwong(s*static_cast<const redlichKwong&>(rK), rK.numOfComp, weigths, rK.mixtureComponents,rK.a_,rK.b_,rK.rhostd_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //