OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
MixtureBO2_OW.cpp
Go to the documentation of this file.
1 
12 #include "MixtureBO.hpp"
13 
15  // BOMixture_OW
17 
18 BOMixture_OW::BOMixture_OW(const ParamReservoir& rs_param, const USI& i)
19 {
20  BOMixtureInit(rs_param);
21 
22  PVTW.Setup(rs_param.PVTW_T.data[i]);
23  PVDO.Setup(rs_param.PVDO_T.data[i]);
24 
25  data.resize(5, 0);
26  cdata.resize(5, 0);
27 }
28 
29 void BOMixture_OW::InitFlash(const OCP_DBL& Pin, const OCP_DBL& Pbbin, const OCP_DBL& Tin,
30  const OCP_DBL* Sjin, const OCP_DBL& Vpore,
31  const OCP_DBL* Ziin)
32 {
33  phaseExist[0] = true;
34  phaseExist[1] = true;
35 
36  P = Pin;
37  S[1] = Sjin[1];
38  // Water Properties
39  PVTW.Eval_All(0, P, data, cdata);
40  OCP_DBL Pw0 = data[0];
41  OCP_DBL bw0 = data[1];
42  OCP_DBL cbw = data[2];
43  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
44  OCP_DBL bwp = -cbw * bw0;
45 
46  mu[1] = data[3];
47  xi[1] = 1 / (bw * CONV1);
48  rho[1] = std_RhoW / bw;
49 
50  Ni[1] = Vpore * S[1] * xi[1];
51 
52  // Oil Properties
53  PVDO.Eval_All(0, P, data, cdata);
54  OCP_DBL bo = data[1];
55  OCP_DBL bop = cdata[1];
56 
57  mu[0] = data[2];
58  xi[0] = 1 / (CONV1 * bo);
59  rho[0] = std_RhoO / bo;
60  Ni[0] = Vpore * (1 - S[1]) * xi[0];
61 
62  xij[0 * 2 + 0] = 1;
63  xij[0 * 2 + 1] = 0;
64  xij[1 * 2 + 0] = 0;
65  xij[1 * 2 + 1] = 1;
66 
67  v[0] = CONV1 * Ni[0] * bo;
68  v[1] = CONV1 * Ni[1] * bw;
69  vf = v[0] + v[1];
70  S[0] = v[0] / vf;
71  S[1] = v[1] / vf;
72  vfi[0] = CONV1 * bo;
73  vfi[1] = CONV1 * bw;
74  vfp = CONV1 * Ni[0] * bop + CONV1 * Ni[1] * bwp;
75 }
76 
77 void BOMixture_OW::Flash(const OCP_DBL& Pin, const OCP_DBL& Tin, const OCP_DBL* Niin, const USI& ftype, const USI& lastNP,
78  const OCP_DBL* lastKs)
79 {
80  phaseExist[0] = true;
81  phaseExist[1] = true;
82 
83  P = Pin;
84  Ni[0] = Niin[0];
85  Ni[1] = Niin[1];
86 
87  // Water Properties
88  PVTW.Eval_All(0, P, data, cdata);
89  OCP_DBL Pw0 = data[0];
90  OCP_DBL bw0 = data[1];
91  OCP_DBL cbw = data[2];
92  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
93  OCP_DBL bwp = -cbw * bw0;
94 
95  mu[1] = data[3];
96  xi[1] = 1 / (bw * CONV1);
97  rho[1] = std_RhoW / bw;
98 
99  // Oil Properties
100  PVDO.Eval_All(0, P, data, cdata);
101  OCP_DBL bo = data[1];
102  OCP_DBL bop = cdata[1];
103 
104  mu[0] = data[2];
105  xi[0] = 1 / (CONV1 * bo);
106  rho[0] = std_RhoO / bo;
107 
108  xij[0 * 2 + 0] = 1;
109  xij[0 * 2 + 1] = 0;
110  xij[1 * 2 + 0] = 0;
111  xij[1 * 2 + 1] = 1;
112 
113  v[0] = CONV1 * Ni[0] * bo;
114  v[1] = CONV1 * Ni[1] * bw;
115  vf = v[0] + v[1];
116  S[0] = v[0] / vf;
117  S[1] = v[1] / vf;
118  vfi[0] = CONV1 * bo;
119  vfi[1] = CONV1 * bw;
120  vfp = CONV1 * Ni[0] * bop + CONV1 * Ni[1] * bwp;
121 }
122 
123 void BOMixture_OW::FlashDeriv(const OCP_DBL& Pin, const OCP_DBL& Tin,
124  const OCP_DBL* Niin, const USI& ftype, const USI& lastNP,
125  const OCP_DBL* lastKs)
126 {
127  phaseExist[0] = true;
128  phaseExist[1] = true;
129  fill(dXsdXp.begin(), dXsdXp.end(), 0.0);
130  fill(pEnumCom.begin(), pEnumCom.end(), 0);
131 
132  P = Pin;
133  Ni[0] = Niin[0];
134  Ni[1] = Niin[1];
135  Nt = Ni[0] + Ni[1];
136 
137  // Water Properties
138  PVTW.Eval_All(0, P, data, cdata);
139  OCP_DBL Pw0 = data[0];
140  OCP_DBL bw0 = data[1];
141  OCP_DBL cbw = data[2];
142  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
143  OCP_DBL bwp = -cbw * bw0;
144 
145  mu[1] = data[3];
146  xi[1] = 1 / (bw * CONV1);
147  rho[1] = std_RhoW / bw;
148 
149  muP[1] = cdata[3];
150  xiP[1] = -bwp / (bw * bw * CONV1);
151  rhoP[1] = CONV1 * xiP[1] * std_RhoW;
152 
153  // Oil Properties
154  PVDO.Eval_All(0, P, data, cdata);
155  OCP_DBL bo = data[1];
156  OCP_DBL bop = cdata[1];
157 
158  mu[0] = data[2];
159  xi[0] = 1 / (CONV1 * bo);
160  rho[0] = std_RhoO / bo;
161 
162  muP[0] = cdata[2];
163  xiP[0] = -xi[0] * bop / bo;
164  rhoP[0] = -rho[0] * bop / bo;
165 
166  xij[0 * 2 + 0] = 1;
167  xij[0 * 2 + 1] = 0;
168  xij[1 * 2 + 0] = 0;
169  xij[1 * 2 + 1] = 1;
170 
171  v[0] = CONV1 * Ni[0] * bo;
172  v[1] = CONV1 * Ni[1] * bw;
173  vf = v[0] + v[1];
174  S[0] = v[0] / vf;
175  S[1] = v[1] / vf;
176  vfi[0] = CONV1 * bo;
177  vfi[1] = CONV1 * bw;
178  vfp = CONV1 * Ni[0] * bop + CONV1 * Ni[1] * bwp;
179 
180  dXsdXp[0] = (CONV1 * Ni[0] * bop - S[0] * vfp) / vf; // dSo / dP
181  dXsdXp[1] = (CONV1 * bo - S[0] * vfi[0]) / vf; // dSo / dNo
182  dXsdXp[2] = -S[0] * vfi[1] / vf; // dSo / dNw
183 
184  dXsdXp[3] = (CONV1 * Ni[1] * bwp - S[1] * vfp) / vf; // dSw / dP
185  dXsdXp[4] = -S[1] * vfi[0] / vf; // dSw / dNo
186  dXsdXp[5] = (CONV1 * bw - S[1] * vfi[1]) / vf; // dSw / dNw
187 
188 
189 }
190 
191 OCP_DBL BOMixture_OW::XiPhase(const OCP_DBL& Pin, const OCP_DBL& Tin, const OCP_DBL* Ziin)
192 {
193  if (Ziin[1] > 1 - TINY) {
194  // inj fluid is water
195  PVTW.Eval_All(0, Pin, data, cdata);
196  OCP_DBL Pw0 = data[0];
197  OCP_DBL bw0 = data[1];
198  OCP_DBL cbw = data[2];
199  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
200  OCP_DBL xiw = 1 / (CONV1 * bw);
201  return xiw;
202  } else {
203  OCP_ABORT("Wrong Zi!");
204  }
205 }
206 
207 OCP_DBL BOMixture_OW::RhoPhase(const OCP_DBL& Pin, const OCP_DBL& Tin, const OCP_DBL* Ziin)
208 {
209  if (Ziin[1] > 1 - TINY) {
210  // inj fluid is water
211 
212  PVTW.Eval_All(0, Pin, data, cdata);
213  OCP_DBL Pw0 = data[0];
214  OCP_DBL bw0 = data[1];
215  OCP_DBL cbw = data[2];
216  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
217  OCP_DBL rhow = std_RhoW / bw;
218  return rhow;
219  } else {
220  OCP_ABORT("Wrong Zi!");
221  }
222 }
223 
225 {
226  OCP_DBL bo = PVDO.Eval(0, Pin, 1);
227  OCP_DBL gammaO = std_GammaO / bo;
228 
229  return gammaO;
230 }
231 
233 {
234 
235  PVTW.Eval_All(0, Pin, data, cdata);
236  OCP_DBL Pw0 = data[0];
237  OCP_DBL bw0 = data[1];
238  OCP_DBL cbw = data[2];
239  OCP_DBL bw = (bw0 * (1 - cbw * (Pin - Pw0)));
240 
241  return std_GammaW / bw;
242 }
243 /*----------------------------------------------------------------------------*/
244 /* Brief Change History of This File */
245 /*----------------------------------------------------------------------------*/
246 /* Author Date Actions */
247 /*----------------------------------------------------------------------------*/
248 /* Shizhe Li Oct/01/2021 Create file */
249 /*----------------------------------------------------------------------------*/
MixtureBO class declaration.
const OCP_DBL TINY
Small constant.
Definition: OCPConst.hpp:36
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:22
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:26
const OCP_DBL CONV1
1 bbl = CONV1 ft3
Definition: OCPConst.hpp:59
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
void InitFlash(const OCP_DBL &Pin, const OCP_DBL &Pbbin, const OCP_DBL &Tin, const OCP_DBL *Sjin, const OCP_DBL &Vpore, const OCP_DBL *Ziin) override
flash calculation with saturation of phases.
OCP_DBL XiPhase(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin) override
OCP_DBL GammaPhaseW(const OCP_DBL &Pin) override
return gamma of water phase, gamma equals to mass density times gravity factor.
OCP_DBL RhoPhase(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin) override
return mass density of phase.
OCP_DBL GammaPhaseO(const OCP_DBL &Pin, const OCP_DBL &Pbbin) override
return gamma of oil phase, gamma equals to mass density times gravity factor.
void Flash(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin, const USI &ftype, const USI &lastNP, const OCP_DBL *lastKs) override
Flash calculation with moles of components.
void FlashDeriv(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin, const USI &ftype, const USI &lastNP, const OCP_DBL *lastKs) override
Flash calculation with moles of components and Calculate the derivative.
OCP_DBL std_GammaO
std_RhoO * gravity factor.
Definition: MixtureBO.hpp:76
OCP_DBL std_RhoW
mass density of water phase in standard condition.
Definition: MixtureBO.hpp:79
OCP_DBL std_RhoO
< others.
Definition: MixtureBO.hpp:75
OCP_DBL std_GammaW
std_RhoW * gravity factor.
Definition: MixtureBO.hpp:80
vector< OCP_DBL > rhoP
d rho / dP: numphase
Definition: Mixture.hpp:187
vector< USI > pEnumCom
see pEnumCom in bulk
Definition: Mixture.hpp:196
vector< OCP_DBL > dXsdXp
the derivates of second variables wrt. primary variables
Definition: Mixture.hpp:195
vector< OCP_DBL > rho
mass density of phase: numPhase
Definition: Mixture.hpp:164
vector< OCP_DBL > mu
viscosity of phase: numPhase
Definition: Mixture.hpp:169
vector< bool > phaseExist
existence of phase: numPhase
Definition: Mixture.hpp:162
OCP_DBL P
pressure when flash calculation.
Definition: Mixture.hpp:158
vector< OCP_DBL > v
volume of phase: numPhase;
Definition: Mixture.hpp:170
vector< OCP_DBL > S
saturation of phase: numPhase
Definition: Mixture.hpp:163
vector< OCP_DBL > xij
Definition: Mixture.hpp:166
OCP_DBL Nt
Total moles of Components.
Definition: Mixture.hpp:173
vector< OCP_DBL > Ni
moles of component: numCom
Definition: Mixture.hpp:161
vector< OCP_DBL > vfi
Definition: Mixture.hpp:182
vector< OCP_DBL > xiP
d xi / dP: numphase
Definition: Mixture.hpp:186
OCP_DBL vf
volume of total fluids.
Definition: Mixture.hpp:172
OCP_DBL vfp
Definition: Mixture.hpp:180
vector< OCP_DBL > muP
d mu / dP: numPhase
Definition: Mixture.hpp:185
vector< OCP_DBL > xi
molar density of phase: numPhase
Definition: Mixture.hpp:165
USI Eval_All(const USI &j, const OCP_DBL &val, vector< OCP_DBL > &outdata, vector< OCP_DBL > &slope)
Definition: OCPTable.cpp:53
void Setup(const vector< vector< OCP_DBL >> &src)
Setup tables from existing data of table.
Definition: OCPTable.cpp:32
OCP_DBL Eval(const USI &j, const OCP_DBL &val, const USI &destj)
Definition: OCPTable.cpp:135
TableSet PVDO_T
Table set of PVDO.
TableSet PVTW_T
Table set of PVTW.
vector< vector< vector< OCP_DBL > > > data
All table with the same name.