OpenCAEPoro  v0.5.0
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 {
21  numPhase = 2;
22  numCom = 2;
23  BOMixtureInit(rs_param);
24 
25  PVTW.Setup(rs_param.PVTW_T.data[i]);
26  PVDO.Setup(rs_param.PVDO_T.data[i]);
27 
28  data.resize(5, 0);
29  cdata.resize(5, 0);
30 
31  phaseExist[0] = OCP_TRUE;
32  phaseExist[1] = OCP_TRUE;
33 
34  xij[0 * 2 + 0] = 1;
35  xij[0 * 2 + 1] = 0;
36  xij[1 * 2 + 0] = 0;
37  xij[1 * 2 + 1] = 1;
38 }
39 
40 void BOMixture_OW::Flash(const OCP_DBL& Pin, const OCP_DBL& Tin, const OCP_DBL* Niin)
41 {
42  FlashIMPEC(Pin, Tin, Niin, 0, 0, 0);
43 }
44 
45 void BOMixture_OW::InitFlashIMPEC(const OCP_DBL& Pin,
46  const OCP_DBL& Pbbin,
47  const OCP_DBL& Tin,
48  const OCP_DBL* Sjin,
49  const OCP_DBL& Vpore,
50  const OCP_DBL* Ziin,
51  const OCP_USI& bId)
52 {
53  P = Pin;
54  S[1] = Sjin[1];
55  // Water Properties
56  PVTW.Eval_All(0, P, data, cdata);
57  OCP_DBL Pw0 = data[0];
58  OCP_DBL bw0 = data[1];
59  OCP_DBL cbw = data[2];
60  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
61  OCP_DBL bwp = -cbw * bw0;
62 
63  mu[1] = data[3];
64  xi[1] = 1 / (bw * CONV1);
65  rho[1] = std_RhoW / bw;
66 
67  Ni[1] = Vpore * S[1] * xi[1];
68 
69  // Oil Properties
70  PVDO.Eval_All(0, P, data, cdata);
71  OCP_DBL bo = data[1];
72  OCP_DBL bop = cdata[1];
73 
74  mu[0] = data[2];
75  xi[0] = 1 / (CONV1 * bo);
76  rho[0] = std_RhoO / bo;
77  Ni[0] = Vpore * (1 - S[1]) * xi[0];
78 
79  vj[0] = CONV1 * Ni[0] * bo;
80  vj[1] = CONV1 * Ni[1] * bw;
81  vf = vj[0] + vj[1];
82  S[0] = vj[0] / vf;
83  S[1] = vj[1] / vf;
84  vfi[0] = CONV1 * bo;
85  vfi[1] = CONV1 * bw;
86  vfP = CONV1 * Ni[0] * bop + CONV1 * Ni[1] * bwp;
87 }
88 
89 void BOMixture_OW::InitFlashFIM(const OCP_DBL& Pin,
90  const OCP_DBL& Pbbin,
91  const OCP_DBL& Tin,
92  const OCP_DBL* Sjin,
93  const OCP_DBL& Vpore,
94  const OCP_DBL* Ziin,
95  const OCP_USI& bId)
96 {
97  P = Pin;
98  S[1] = Sjin[1];
99  // Water Properties
100  PVTW.Eval_All(0, P, data, cdata);
101  OCP_DBL Pw0 = data[0];
102  OCP_DBL bw0 = data[1];
103  OCP_DBL cbw = data[2];
104  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
105  xi[1] = 1 / (bw * CONV1);
106  Ni[1] = Vpore * S[1] * xi[1];
107 
108  // Oil Properties
109  PVDO.Eval_All(0, P, data, cdata);
110  OCP_DBL bo = data[1];
111 
112  xi[0] = 1 / (CONV1 * bo);
113  Ni[0] = Vpore * (1 - S[1]) * xi[0];
114 
115  FlashFIM(Pin, Tin, &Ni[0], 0, 0, 0, 0);
116 }
117 
119  const OCP_DBL& Tin,
120  const OCP_DBL* Niin,
121  const USI& lastNP,
122  const OCP_DBL* xijin,
123  const OCP_USI& bId)
124 {
125 
126  P = Pin;
127  Ni[0] = Niin[0];
128  Ni[1] = Niin[1];
129 
130  // Water Properties
131  PVTW.Eval_All(0, P, data, cdata);
132  OCP_DBL Pw0 = data[0];
133  OCP_DBL bw0 = data[1];
134  OCP_DBL cbw = data[2];
135  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
136  OCP_DBL bwp = -cbw * bw0;
137 
138  mu[1] = data[3];
139  xi[1] = 1 / (bw * CONV1);
140  rho[1] = std_RhoW / bw;
141 
142  // Oil Properties
143  PVDO.Eval_All(0, P, data, cdata);
144  OCP_DBL bo = data[1];
145  OCP_DBL bop = cdata[1];
146 
147  mu[0] = data[2];
148  xi[0] = 1 / (CONV1 * bo);
149  rho[0] = std_RhoO / bo;
150 
151  vj[0] = CONV1 * Ni[0] * bo;
152  vj[1] = CONV1 * Ni[1] * bw;
153  vf = vj[0] + vj[1];
154  S[0] = vj[0] / vf;
155  S[1] = vj[1] / vf;
156  vfi[0] = CONV1 * bo;
157  vfi[1] = CONV1 * bw;
158  vfP = CONV1 * Ni[0] * bop + CONV1 * Ni[1] * bwp;
159 }
160 
162  const OCP_DBL& Tin,
163  const OCP_DBL* Niin,
164  const OCP_DBL* Sjin,
165  const USI& lastNP,
166  const OCP_DBL* xijin,
167  const OCP_USI& bId)
168 {
169  fill(dXsdXp.begin(), dXsdXp.end(), 0.0);
170  fill(pSderExist.begin(), pSderExist.end(), OCP_TRUE);
171  fill(pVnumCom.begin(), pVnumCom.end(), 0);
172 
173  P = Pin;
174  Ni[0] = Niin[0];
175  Ni[1] = Niin[1];
176  Nt = Ni[0] + Ni[1];
177 
178  // Water Properties
179  PVTW.Eval_All(0, P, data, cdata);
180  OCP_DBL Pw0 = data[0];
181  OCP_DBL bw0 = data[1];
182  OCP_DBL cbw = data[2];
183  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
184  OCP_DBL bwp = -cbw * bw0;
185 
186  mu[1] = data[3];
187  xi[1] = 1 / (bw * CONV1);
188  rho[1] = std_RhoW / bw;
189 
190  muP[1] = cdata[3];
191  xiP[1] = -bwp / (bw * bw * CONV1);
192  rhoP[1] = CONV1 * xiP[1] * std_RhoW;
193 
194  // Oil Properties
195  PVDO.Eval_All(0, P, data, cdata);
196  OCP_DBL bo = data[1];
197  OCP_DBL bop = cdata[1];
198 
199  mu[0] = data[2];
200  xi[0] = 1 / (CONV1 * bo);
201  rho[0] = std_RhoO / bo;
202 
203  muP[0] = cdata[2];
204  xiP[0] = -xi[0] * bop / bo;
205  rhoP[0] = -rho[0] * bop / bo;
206 
207  vj[0] = CONV1 * Ni[0] * bo;
208  vj[1] = CONV1 * Ni[1] * bw;
209  vf = vj[0] + vj[1];
210  S[0] = vj[0] / vf;
211  S[1] = vj[1] / vf;
212  vfi[0] = CONV1 * bo;
213  vfi[1] = CONV1 * bw;
214  vfP = CONV1 * Ni[0] * bop + CONV1 * Ni[1] * bwp;
215 
216  dXsdXp[0] = (CONV1 * Ni[0] * bop - S[0] * vfP) / vf; // dSo / dP
217  dXsdXp[1] = (CONV1 * bo - S[0] * vfi[0]) / vf; // dSo / dNo
218  dXsdXp[2] = -S[0] * vfi[1] / vf; // dSo / dNw
219 
220  dXsdXp[3] = (CONV1 * Ni[1] * bwp - S[1] * vfP) / vf; // dSw / dP
221  dXsdXp[4] = -S[1] * vfi[0] / vf; // dSw / dNo
222  dXsdXp[5] = (CONV1 * bw - S[1] * vfi[1]) / vf; // dSw / dNw
223 }
224 
226  const OCP_DBL& Tin,
227  const OCP_DBL* Ziin,
228  const USI& tarPhase)
229 {
230  if (tarPhase == WATER) {
231  // inj fluid is water
232  PVTW.Eval_All(0, Pin, data, cdata);
233  OCP_DBL Pw0 = data[0];
234  OCP_DBL bw0 = data[1];
235  OCP_DBL cbw = data[2];
236  OCP_DBL bw = bw0 * (1 - cbw * (Pin - Pw0));
237  OCP_DBL xiw = 1 / (CONV1 * bw);
238  return xiw;
239  } else {
240  OCP_ABORT("Wrong tarPhase!");
241  }
242 }
243 
245  const OCP_DBL& Pbb,
246  const OCP_DBL& Tin,
247  const OCP_DBL* Ziin,
248  const USI& tarPhase)
249 {
250  if (tarPhase == OIL) {
251  OCP_DBL bo = PVDO.Eval(0, Pin, 1);
252  return std_RhoO / bo;
253  } else if (tarPhase == WATER) {
254  PVTW.Eval_All(0, Pin, data, cdata);
255  OCP_DBL Pw0 = data[0];
256  OCP_DBL bw0 = data[1];
257  OCP_DBL cbw = data[2];
258  OCP_DBL bw = bw0 * (1 - cbw * (Pin - Pw0));
259  return std_RhoW / bw;
260  } else {
261  OCP_ABORT("Wrong tarPhase!");
262  }
263 }
264 
266  const vector<SolventINJ>& sols,
267  const OCP_DBL& Psurf,
268  const OCP_DBL& Tsurf)
269 {
270  const USI wellType = opt.WellType();
271  if (wellType == INJ) {
272  const string fluidName = opt.InjFluidType();
273  opt.SetInjFactor(1.0);
274 
275  if (fluidName == "WAT") {
276  vector<OCP_DBL> tmpZi({0, 1});
277  opt.SetInjZi(tmpZi);
278  opt.SetInjProdPhase(WATER);
279  } else {
280  OCP_ABORT("WRONG Injecting Fluid!");
281  }
282  } else if (wellType == PROD) {
283  vector<OCP_DBL> tmpWght(2, 0);
284  switch (opt.OptMode()) {
285  case BHP_MODE:
286  break;
287  case ORATE_MODE:
288  tmpWght[0] = 1;
289  break;
290  case WRATE_MODE:
291  tmpWght[1] = 1;
292  break;
293  case LRATE_MODE:
294  tmpWght[0] = tmpWght[1] = 1;
295  break;
296  default:
297  OCP_ABORT("WRONG Opt Mode!");
298  break;
299  }
300  opt.SetProdPhaseWeight(tmpWght);
301  } else {
302  OCP_ABORT("Wrong Well Type!");
303  }
304 }
305 
306 /*----------------------------------------------------------------------------*/
307 /* Brief Change History of This File */
308 /*----------------------------------------------------------------------------*/
309 /* Author Date Actions */
310 /*----------------------------------------------------------------------------*/
311 /* Shizhe Li Oct/01/2021 Create file */
312 /*----------------------------------------------------------------------------*/
MixtureBO class declaration.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:27
const OCP_DBL CONV1
1 bbl = CONV1 ft3
Definition: OCPConst.hpp:63
const USI LRATE_MODE
Well option = fixed fluid rate???
Definition: OCPConst.hpp:134
const USI WRATE_MODE
Well option = fixed water rate.
Definition: OCPConst.hpp:133
const USI WATER
Fluid type = water.
Definition: OCPConst.hpp:93
const USI BLKOIL_OW
black oil model with oil and water
Definition: OCPConst.hpp:99
const USI ORATE_MODE
Well option = fixed oil rate.
Definition: OCPConst.hpp:131
const USI OIL
Fluid type = oil.
Definition: OCPConst.hpp:91
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:25
const USI PROD
Well type = producer.
Definition: OCPConst.hpp:123
const USI INJ
Well type = injector.
Definition: OCPConst.hpp:122
const USI BHP_MODE
Well option = fixed bottom-hole-pressure.
Definition: OCPConst.hpp:135
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
OCP_DBL RhoPhase(const OCP_DBL &Pin, const OCP_DBL &Pbb, const OCP_DBL &Tin, const OCP_DBL *Ziin, const USI &tarPhase) override
return mass density of phase
OCP_DBL XiPhase(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin, const USI &tarPhase) override
return mass density of phase
void FlashFIM(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin, const OCP_DBL *Sjin, const USI &lastNP, const OCP_DBL *xijin, const OCP_USI &bId) override
Flash calculation with moles of components and Calculate the derivative.
void Flash(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin) override
flash calculation with saturation of phases.
void FlashIMPEC(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin, const USI &lastNP, const OCP_DBL *xijin, const OCP_USI &bId) override
Flash calculation with moles of components.
void SetupWellOpt(WellOpt &opt, const vector< SolventINJ > &sols, const OCP_DBL &Psurf, const OCP_DBL &Tsurf) override
OCP_DBL std_RhoW
The density of water at surface conditions : lb/ft3.
Definition: MixtureBO.hpp:77
OCP_DBL std_RhoO
< others.
Definition: MixtureBO.hpp:67
vector< OCP_DBL > rhoP
d rho / dP: numphase
Definition: Mixture.hpp:265
USI numCom
num of components.
Definition: Mixture.hpp:242
vector< OCP_DBL > dXsdXp
derivatives of second variables wrt. primary variables
Definition: Mixture.hpp:275
vector< OCP_DBL > rho
mass density of phase: numPhase
Definition: Mixture.hpp:254
vector< OCP_DBL > mu
viscosity of phase: numPhase
Definition: Mixture.hpp:256
OCP_DBL P
pressure when flash calculation.
Definition: Mixture.hpp:243
vector< OCP_BOOL > pSderExist
Existence of derivative of phase saturation.
Definition: Mixture.hpp:286
USI numPhase
num of phases.
Definition: Mixture.hpp:241
vector< OCP_DBL > vj
volume of phase: numPhase;
Definition: Mixture.hpp:251
OCP_DBL vfP
Definition: Mixture.hpp:259
vector< OCP_DBL > S
saturation of phase: numPhase
Definition: Mixture.hpp:250
vector< OCP_DBL > xij
Nij / nj: numPhase*numCom.
Definition: Mixture.hpp:253
OCP_DBL Nt
Total moles of Components.
Definition: Mixture.hpp:247
vector< OCP_DBL > Ni
moles of component: numCom
Definition: Mixture.hpp:248
vector< OCP_DBL > vfi
Definition: Mixture.hpp:262
vector< OCP_BOOL > phaseExist
existence of phase: numPhase
Definition: Mixture.hpp:249
vector< OCP_DBL > xiP
d xi / dP: numphase
Definition: Mixture.hpp:268
OCP_DBL vf
volume of total fluids.
Definition: Mixture.hpp:246
vector< USI > pVnumCom
num of variable components in the phase
Definition: Mixture.hpp:287
vector< OCP_DBL > muP
d mu / dP: numPhase
Definition: Mixture.hpp:271
USI mixtureType
Definition: Mixture.hpp:238
vector< OCP_DBL > xi
molar density of phase: numPhase
Definition: Mixture.hpp:255
USI Eval_All(const USI &j, const OCP_DBL &val, vector< OCP_DBL > &outdata, vector< OCP_DBL > &slope)
Careful: the memory outdata and slope have not be allocated before.
Definition: OCPTable.cpp:47
void Setup(const vector< vector< OCP_DBL >> &src)
Setup tables from existing data of table.
Definition: OCPTable.cpp:27
OCP_DBL Eval(const USI &j, const OCP_DBL &val, const USI &destj)
Definition: OCPTable.cpp:126
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.