OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
MixtureThermal_k.cpp
1 
12 // OpenCAEPoro header files
13 #include "MixtureThermal.hpp"
14 #include "OCPTable.hpp"
15 
16 MixtureThermal_K01::MixtureThermal_K01(const ParamReservoir& param, const USI& tarId)
17 {
19  numPhase = 2;
20  numCom = param.numCom; // water is included
21  Allocate();
22 
23  if (param.comsParam.molden.activity)
24  xi_ref = param.comsParam.molden.data[tarId];
25  else
26  OCP_ABORT("ACF hasn't been input!");
27  if (param.comsParam.avisc.activity || param.comsParam.bvisc.activity) {
28  if (param.comsParam.avisc.activity)
29  avisc = param.comsParam.avisc.data[tarId];
30  else
31  avisc.resize(numCom, 0);
32  if (param.comsParam.bvisc.activity)
33  bvisc = param.comsParam.bvisc.data[tarId];
34  else
35  bvisc.resize(numCom, 0);
36  useViscTab = OCP_FALSE;
37  } else {
38  if (param.comsParam.viscTab.data.size() <= tarId) {
39  OCP_ABORT("VISCTAB hasn't been input for " + to_string(tarId + 1) +
40  " th Region!");
41  }
42  useViscTab = OCP_TRUE;
43  visc.Setup(param.comsParam.viscTab.data[tarId]);
44  // unit convert: F -> R
45  for (auto& v : visc.GetCol(0)) {
46  v += CONV5;
47  }
48  }
49 
50  if (param.comsParam.cp.activity)
51  cp = param.comsParam.cp.data[tarId];
52  else
53  cp.resize(numCom, 0);
54 
55  if (param.comsParam.ct1.activity)
56  ct1 = param.comsParam.ct1.data[tarId];
57  else
58  ct1.resize(numCom, 0);
59 
60  if (param.comsParam.ct2.activity)
61  ct2 = param.comsParam.ct2.data[tarId];
62  else
63  ct2.resize(numCom, 0);
64 
65  if (param.comsParam.cpt.activity)
66  cpt = param.comsParam.cpt.data[tarId];
67  else
68  cpt.resize(numCom, 0);
69 
70  if (param.comsParam.cpl1.activity)
71  cpl1 = param.comsParam.cpl1.data[tarId];
72  else
73  cpl1.resize(numCom, 0);
74 
75  if (param.comsParam.cpl2.activity)
76  cpl2 = param.comsParam.cpl2.data[tarId];
77  else
78  cpl2.resize(numCom, 0);
79 
80  if (param.comsParam.cpl3.activity)
81  cpl3 = param.comsParam.cpl3.data[tarId];
82  else
83  cpl3.resize(numCom, 0);
84 
85  if (param.comsParam.cpl4.activity)
86  cpl4 = param.comsParam.cpl4.data[tarId];
87  else
88  cpl4.resize(numCom, 0);
89 
90  if (param.comsParam.cpg1.activity)
91  cpg1 = param.comsParam.cpg1.data[tarId];
92  else
93  cpg1.resize(numCom, 0);
94 
95  if (param.comsParam.cpg2.activity)
96  cpg2 = param.comsParam.cpg2.data[tarId];
97  else
98  cpg2.resize(numCom, 0);
99 
100  if (param.comsParam.cpg3.activity)
101  cpg3 = param.comsParam.cpg3.data[tarId];
102  else
103  cpg3.resize(numCom, 0);
104 
105  if (param.comsParam.cpg4.activity)
106  cpg4 = param.comsParam.cpg4.data[tarId];
107  else
108  cpg4.resize(numCom, 0);
109 
110  if (param.comsParam.hvapr.activity)
111  hvapr = param.comsParam.hvapr.data[tarId];
112  else
113  hvapr.resize(numCom, 0);
114 
115  if (param.comsParam.hvr.activity)
116  hvr = param.comsParam.hvr.data[tarId];
117  else
118  hvr.resize(numCom, 0);
119 
120  if (param.comsParam.ev.activity)
121  ev = param.comsParam.ev.data[tarId];
122  else
123  ev.resize(numCom, 0);
124 
125  if (param.comsParam.Tc.activity)
126  Tcrit = param.comsParam.Tc.data[tarId];
127  else
128  OCP_ABORT("TCRIT hasn't been input!");
129 
130  if (param.comsParam.MW.activity)
131  MWc = param.comsParam.MW.data[tarId];
132  else
133  OCP_ABORT("MW hasn't been input!");
134 
135  Tref = param.comsParam.Tref[tarId] + CONV5;
136  Pref = param.comsParam.Pref[tarId];
137 
138  dXsdXp.resize((numCom + 2) * (numPhase + numPhase * numCom));
139  MWp.resize(numPhase);
140 
141  data.resize(3, 0);
142  cdata.resize(3, 0);
143 
144  // Init
145  phaseExist[0] = true;
146  phaseExist[1] = true;
147 
148  MWp[0] = MWc[0];
149  MWp[1] = MWc[1];
150 
151  xij[0 * 2 + 0] = 1;
152  xij[0 * 2 + 1] = 0;
153  xij[1 * 2 + 0] = 0;
154  xij[1 * 2 + 1] = 1;
155 
156  // d mu / dP
157  fill(rhox.begin(), rhox.end(), 0.0);
158  fill(xix.begin(), xix.end(), 0.0);
159  fill(muP.begin(), muP.end(), 0.0);
160  fill(mux.begin(), mux.end(), 0.0);
161 }
162 
164  const OCP_DBL& Tin,
165  const OCP_DBL* Niin)
166 {
167  FlashIMPEC(Pin, Tin, Niin, 0, 0, 0);
168 }
169 
171  const OCP_DBL& Pbbin,
172  const OCP_DBL& Tin,
173  const OCP_DBL* Sjin,
174  const OCP_DBL& Vpore,
175  const OCP_DBL* Ziin,
176  const OCP_USI& bId)
177 {
178  // assign value
179  P = Pin;
180  T = Tin + CONV5;
181  const OCP_DBL dP = P - Pref;
182  const OCP_DBL dT = T - Tref;
183  S[1] = Sjin[1];
184  S[0] = 1 - S[1];
185 
186  // phase molar density
187  xi[0] = xi_ref[0] *
188  exp(cp[0] * dP - ct1[0] * dT - ct2[0] / 2 * pow(dT, 2) + cpt[0] * dP * dT);
189  xi[1] = xi_ref[1] *
190  exp(cp[1] * dP - ct1[1] * dT - ct2[1] / 2 * pow(dT, 2) + cpt[1] * dP * dT);
191 
192  // components moles
193  Ni[0] = Vpore * S[0] * xi[0];
194  Ni[1] = Vpore * S[1] * xi[1];
195 }
196 
197 void MixtureThermal_K01::InitFlashFIM(const OCP_DBL& Pin,
198  const OCP_DBL& Pbbin,
199  const OCP_DBL& Tin,
200  const OCP_DBL* Sjin,
201  const OCP_DBL& Vpore,
202  const OCP_DBL* Ziin,
203  const OCP_USI& bId)
204 {
205  InitFlashIMPEC(Pin, Pbbin, Tin, Sjin, Vpore, Ziin, bId);
206 
207  FlashFIM(Pin, Tin, &Ni[0], 0, 0, 0, bId);
208 }
209 
211  const OCP_DBL& Tin,
212  const OCP_DBL* Niin,
213  const USI& lastNP,
214  const OCP_DBL* xijin,
215  const OCP_USI& bId)
216 {
217  // assign Value
218  P = Pin;
219  T = Tin + CONV5;
220  const OCP_DBL dP = P - Pref;
221  const OCP_DBL dT = T - Tref;
222  Ni[0] = Niin[0];
223  Ni[1] = Niin[1];
224 
225  // phase viscosity
226  if (useViscTab) {
227  visc.Eval_All(0, T, data, cdata);
228  mu[0] = data[1];
229  mu[1] = data[2];
230  } else {
231  mu[0] = avisc[0] * exp(bvisc[0] / T);
232  mu[1] = avisc[1] * exp(bvisc[1] / T);
233  }
234 
235  // phase molar density
236  xi[0] = xi_ref[0] *
237  exp(cp[0] * dP - ct1[0] * dT - ct2[0] / 2 * pow(dT, 2) + cpt[0] * dP * dT);
238  xi[1] = xi_ref[1] *
239  exp(cp[1] * dP - ct1[1] * dT - ct2[1] / 2 * pow(dT, 2) + cpt[1] * dP * dT);
240 
241  // phase mass density
242  rho[0] = MWp[0] * xi[0];
243  rho[1] = MWp[1] * xi[1];
244 
245  // phase volume
246  vj[0] = Ni[0] / xi[0];
247  vj[1] = Ni[1] / xi[1];
248  // total fluid volume
249  vf = vj[0] + vj[1];
250 
251  // phase saturation
252  S[0] = vj[0] / vf;
253  S[1] = vj[1] / vf;
254 
255  // d Vf / d Ni
256  vfi[0] = 1 / xi[0];
257  vfi[1] = 1 / xi[1];
258 
259  // d Vf / dP
260  const OCP_DBL xiop = xi[0] * (cp[0] + cpt[0] * dT);
261  const OCP_DBL xiwp = xi[1] * (cp[1] + cpt[1] * dT);
262  vfP = -(vj[0] * xiop / xi[0] + vj[1] * xiwp / xi[1]);
263 
264  // d Vf / dT
265  const OCP_DBL xioT = xi[0] * (-ct1[0] - ct2[0] * dT + cpt[0] * dP);
266  const OCP_DBL xiwT = xi[1] * (-ct1[1] - ct2[1] * dT + cpt[1] * dP);
267  vfT = -(vj[0] * xioT / xi[0] + vj[1] * xiwT / xi[1]);
268 }
269 
271  const OCP_DBL& Tin,
272  const OCP_DBL* Niin,
273  const OCP_DBL* Sjin,
274  const USI& lastNP,
275  const OCP_DBL* xijin,
276  const OCP_USI& bId)
277 {
278  // Assign value
279  P = Pin;
280  T = Tin + CONV5;
281  const OCP_DBL dP = P - Pref;
282  const OCP_DBL dT = T - Tref;
283  Ni[0] = Niin[0];
284  Ni[1] = Niin[1];
285  Nt = Ni[0] + Ni[1];
286 
287  // phase viscosity
288  if (useViscTab) {
289  visc.Eval_All(0, T, data, cdata);
290  mu[0] = data[1];
291  mu[1] = data[2];
292  // d mu / dT
293  muT[0] = cdata[1];
294  muT[1] = cdata[2];
295 
296  } else {
297  mu[0] = avisc[0] * exp(bvisc[0] / T);
298  mu[1] = avisc[1] * exp(bvisc[1] / T);
299  // d mu / dT
300  muT[0] = mu[0] * (-bvisc[0] / (T * T));
301  muT[1] = mu[1] * (-bvisc[1] / (T * T));
302  }
303 
304  // phase molar density
305  xi[0] = xi_ref[0] *
306  exp(cp[0] * dP - ct1[0] * dT - ct2[0] * pow(dT, 2) / 2 + cpt[0] * dP * dT);
307  xi[1] = xi_ref[1] *
308  exp(cp[1] * dP - ct1[1] * dT - ct2[1] * pow(dT, 2) / 2 + cpt[1] * dP * dT);
309  // d xi / dP
310  xiP[0] = xi[0] * (cp[0] + cpt[0] * dT);
311  xiP[1] = xi[1] * (cp[1] + cpt[1] * dT);
312  // d xi / dT
313  xiT[0] = xi[0] * (-ct1[0] - ct2[0] * dT + cpt[0] * dP);
314  xiT[1] = xi[1] * (-ct1[1] - ct2[1] * dT + cpt[1] * dP);
315 
316  // phase mass density
317  rho[0] = MWp[0] * xi[0];
318  rho[1] = MWp[1] * xi[1];
319  // d rho / d P
320  rhoP[0] = MWp[0] * xiP[0];
321  rhoP[1] = MWp[1] * xiP[1];
322  // d rho / d T
323  rhoT[0] = MWp[0] * xiT[0];
324  rhoT[1] = MWp[1] * xiT[1];
325 
326  // phase volume
327  vj[0] = Ni[0] / xi[0];
328  vj[1] = Ni[1] / xi[1];
329  // total volume
330  vf = vj[0] + vj[1];
331 
332  // phase saturation
333  S[0] = vj[0] / vf;
334  S[1] = vj[1] / vf;
335 
336  // d vf/ d Ni
337  vfi[0] = 1 / xi[0];
338  vfi[1] = 1 / xi[1];
339  // d vf / d P
340  vfP = -(vj[0] * xiP[0] / xi[0] + vj[1] * xiP[1] / xi[1]);
341  // d vf / d T
342  vfT = -(vj[0] * xiT[0] / xi[0] + vj[1] * xiT[1] / xi[1]);
343 
344  // Derivative of secondary vars with respect to primary vars
345  dXsdXp[0] = (-vj[0] * xiP[0] / xi[0] - S[0] * vfP) / vf; // dSo / dP
346  dXsdXp[1] = (1 / xi[0] - S[0] * vfi[0]) / vf; // dSo / dNo
347  dXsdXp[2] = -S[0] * vfi[1] / vf; // dSo / dNw
348  dXsdXp[3] = (-vj[0] * xiT[0] / xi[0] - S[0] * vfT) / vf; // dSo / dT
349 
350  dXsdXp[4] = -dXsdXp[0]; // dSw / dP
351  dXsdXp[5] = -dXsdXp[1]; // dSw / dNo
352  dXsdXp[6] = -dXsdXp[2]; // dSw / dNw
353  dXsdXp[7] = -dXsdXp[3]; // dSw / dT
354 
355  CalEnthalpy();
356 }
357 
358 void MixtureThermal_K01::CalEnthalpy()
359 {
360  fill(H.begin(), H.end(), 0.0);
361  fill(HT.begin(), HT.end(), 0.0);
362 
363  const OCP_DBL dT = T - Tref;
364 
365  if (liquid_based || simple_hvap) {
366  for (USI j = 0; j < numPhase; j++) {
367  for (USI i = 0; i < numCom; i++) {
368 
369  Hx[j * numCom + i] =
370  (cpl1[i] * dT + 1.0 / 2 * cpl2[i] * pow(dT, 2) +
371  1.0 / 3 * cpl3[i] * pow(dT, 3) + 1.0 / 4 * cpl4[i] * pow(dT, 4));
372 
373  H[j] += xij[j * numCom + i] * Hx[j * numCom + i];
374 
375  HT[j] +=
376  xij[j * numCom + i] * (cpl1[i] + cpl2[i] * dT +
377  cpl3[i] * pow(dT, 2) + cpl4[i] * pow(dT, 3));
378  }
379  }
380  } else if (gas_based) {
381  for (USI j = 0; j < numPhase; j++) {
382  for (USI i = 0; i < numCom; i++) {
383  Hx[j * numCom + i] = cpg1[i] * dT + 1.0 / 2 * cpg2[i] * pow(dT, 2) +
384  1.0 / 3 * cpg3[i] * pow(dT, 3) +
385  1.0 / 4 * cpg4[i] * pow(dT, 4);
386  H[j] += xij[j * numCom + i] * Hx[j * numCom + i];
387  HT[j] +=
388  xij[j * numCom + i] * (cpg1[i] + cpg2[i] * dT +
389  cpg3[i] * pow(dT, 2) + cpg4[i] * pow(dT, 3));
390 
391  if (T < Tcrit[i]) {
392  Hx[j * numCom + i] -= hvr[i] * pow((Tcrit[i] - T), ev[i]);
393 
394  H[j] -= xij[j * numCom + i] * hvr[i] * pow((Tcrit[i] - T), ev[i]);
395 
396  HT[j] += xij[j * numCom + i] * hvr[i] * ev[i] *
397  pow((Tcrit[i] - T), ev[i] - 1);
398  }
399  }
400  }
401  } else {
402  OCP_ABORT("WRONG Type !");
403  }
404 
405  // Internal energy per unit volume of fluid
406 
407  // Uf, d Uf / d T, d Uf / d P
408  Uf = -P / (GRAVITY_FACTOR * CONV6);
409  UfP = -1 / (GRAVITY_FACTOR * CONV6);
410  UfT = 0;
411 
412  for (USI j = 0; j < numPhase; j++) {
413  // Uf
414  Uf += S[j] * xi[j] * H[j];
415  // dUf / dP
416  UfP += -(vj[j] * xiP[j] / xi[j] + S[j] * vfP) / vf * xi[j] * H[j];
417  UfP += xiP[j] * S[j] * H[j];
418  // dUf / dT
419  UfT += -(vj[j] * xiT[j] / xi[j] + S[j] * vfT) / vf * xi[j] * H[j];
420  UfT += (xiT[j] * H[j] + HT[j] * xi[j]) * S[j];
421  }
422 
423  // d Uf / d Ni
424  Ufi[0] = dXsdXp[1] * xi[0] * H[0] + dXsdXp[5] * xi[1] * H[1];
425  Ufi[1] = dXsdXp[2] * xi[0] * H[0] + dXsdXp[6] * xi[1] * H[1];
426 }
427 
428 OCP_DBL MixtureThermal_K01::CalInjWellEnthalpy(const OCP_DBL& Tin, const OCP_DBL* Ziin)
429 {
430  T = Tin + CONV5;
431  const OCP_DBL dT = T - Tref;
432  vector<OCP_DBL> zi{0, 1};
433 
434  OCP_DBL Hw = 0;
435  if (liquid_based) {
436  for (USI i = 0; i < numCom; i++) {
437  Hw += zi[i] *
438  (cpl1[i] * dT + 1.0 / 2 * cpl2[i] * pow(dT, 2) +
439  1.0 / 3 * cpl3[i] * pow(dT, 3) + 1.0 / 4 * cpl4[i] * pow(dT, 4));
440  }
441  } else if (gas_based) {
442  for (USI i = 0; i < numCom; i++) {
443  Hw += zi[i] *
444  (cpg1[i] * dT + 1.0 / 2 * cpg2[i] * pow(dT, 2) +
445  1.0 / 3 * cpg3[i] * pow(dT, 3) + 1.0 / 4 * cpg4[i] * pow(dT, 4));
446  if (T < Tcrit[i]) {
447  Hw -= zi[i] * hvr[i] * pow((Tcrit[i] - T), ev[i]);
448  }
449  }
450  }
451  return Hw;
452 }
453 
455  const OCP_DBL& Tin,
456  const OCP_DBL* Ziin,
457  const USI& tarPhase)
458 {
459  P = Pin;
460  T = Tin + CONV5;
461  const OCP_DBL dP = P - Pref;
462  const OCP_DBL dT = T - Tref;
463 
464  if (tarPhase == WATER) {
465  // inj fluid is water
466  OCP_DBL xiw = xi_ref[1] * exp(cp[1] * dP - ct1[1] * dT -
467  ct2[1] * pow(dT, 2) / 2 + cpt[1] * dP * dT);
468  return xiw;
469  } else {
470  OCP_ABORT("Wrong tarPhase!");
471  }
472 }
473 
474 OCP_DBL
476  const OCP_DBL& Pbb,
477  const OCP_DBL& Tin,
478  const OCP_DBL* Ziin,
479  const USI& tarPhase)
480 {
481  P = Pin;
482  T = Tin + CONV5;
483  const OCP_DBL dP = P - Pref;
484  const OCP_DBL dT = T - Tref;
485 
486  if (tarPhase == OIL) {
487  const OCP_DBL xio = xi_ref[0] * exp(cp[0] * dP - ct1[0] * dT -
488  ct2[0] * pow(dT, 2) / 2 + cpt[0] * dP * dT);
489  return MWp[0] * xio;
490  } else if (tarPhase == WATER) {
491  // inj fluid is water
492  const OCP_DBL xiw = xi_ref[1] * exp(cp[1] * dP - ct1[1] * dT -
493  ct2[1] * pow(dT, 2) / 2 + cpt[1] * dP * dT);
494  return MWp[1] * xiw;
495  } else {
496  OCP_ABORT("Wrong tarPhase!");
497  }
498 }
499 
501  const OCP_DBL& Tin,
502  const OCP_DBL* Niin,
503  const vector<OCP_DBL>& prodPhase,
504  vector<OCP_DBL>& prodWeight)
505 {
506  P = Pin;
507  T = Tin + 460;
508  const OCP_DBL dP = P - Pref;
509  const OCP_DBL dT = T - Tref;
510  Ni[0] = Niin[0];
511  Ni[1] = Niin[1];
512  Nt = Ni[0] + Ni[1];
513 
514  // phase molar density
515  xi[0] = xi_ref[0] *
516  exp(cp[0] * dP - ct1[0] * dT - ct2[0] / 2 * pow(dT, 2) + cpt[0] * dP * dT);
517  xi[1] = xi_ref[1] *
518  exp(cp[1] * dP - ct1[1] * dT - ct2[1] / 2 * pow(dT, 2) + cpt[1] * dP * dT);
519 
520  // phase volume
521  vj[0] = Ni[0] / xi[0];
522  vj[1] = Ni[1] / xi[1];
523 
524  OCP_DBL qt = Nt;
525  vector<OCP_DBL> factor(numPhase, 0);
526  factor[0] = vj[0] / qt / CONV1; // stb / lbmol
527  factor[1] = vj[1] / qt / CONV1; // stb / lbmol
528 
529  OCP_DBL tmp = 0;
530  for (USI i = 0; i < 2; i++) {
531  tmp += factor[i] * prodPhase[i];
532  }
533  if (tmp < 1E-12 || !isfinite(tmp)) {
534  OCP_ABORT("Wrong Condition!");
535  }
536  fill(prodWeight.begin(), prodWeight.end(), tmp);
537 }
538 
540  const OCP_DBL& Tin,
541  const OCP_DBL* Niin,
542  vector<OCP_DBL>& prodRate)
543 {
544  // assign Value
545  P = Pin;
546  T = Tin + 460;
547  const OCP_DBL dP = P - Pref;
548  const OCP_DBL dT = T - Tref;
549  Ni[0] = Niin[0];
550  Ni[1] = Niin[1];
551 
552  // phase molar density
553  xi[0] = xi_ref[0] *
554  exp(cp[0] * dP - ct1[0] * dT - ct2[0] / 2 * pow(dT, 2) + cpt[0] * dP * dT);
555  xi[1] = xi_ref[1] *
556  exp(cp[1] * dP - ct1[1] * dT - ct2[1] / 2 * pow(dT, 2) + cpt[1] * dP * dT);
557 
558  // phase volume
559  vj[0] = Ni[0] / xi[0];
560  vj[1] = Ni[1] / xi[1];
561 
562  prodRate[0] = vj[0] / CONV1; // stb
563  prodRate[1] = vj[1] / CONV1; // stb
564 }
565 
567  const vector<SolventINJ>& sols,
568  const OCP_DBL& Psurf,
569  const OCP_DBL& Tsurf)
570 {
571  const USI wellType = opt.WellType();
572  if (wellType == INJ) {
573  const string fluidName = opt.InjFluidType();
574  vector<OCP_DBL> tmpZi(numCom, 0);
575  if (fluidName == "WAT") {
576  tmpZi.back() = 1;
577  opt.SetInjProdPhase(WATER);
578  // lbmol / ft3 -> lbmol / bbl for
579  // injfluid Use flash in Bulk in surface condition
580  OCP_DBL tmp = CONV1 * XiPhase(Psurf, Tsurf, &tmpZi[0], WATER);
581  opt.SetInjFactor(tmp);
582  } else {
583  OCP_ABORT("WRONG Fluid Type!");
584  }
585  opt.SetInjZi(tmpZi);
586  } else if (wellType == PROD) {
587  vector<OCP_DBL> tmpWght(numPhase, 0);
588  switch (opt.OptMode()) {
589  case ORATE_MODE:
590  tmpWght[0] = 1;
591  break;
592  case WRATE_MODE:
593  tmpWght[1] = 1;
594  break;
595  case LRATE_MODE:
596  tmpWght[0] = 1;
597  tmpWght[1] = 1;
598  break;
599  default:
600  OCP_ABORT("WRONG optMode");
601  break;
602  }
603  opt.SetProdPhaseWeight(tmpWght);
604  } else {
605  OCP_ABORT("Wrong Well Type!");
606  }
607 }
608 /*----------------------------------------------------------------------------*/
609 /* Brief Change History of This File */
610 /*----------------------------------------------------------------------------*/
611 /* Author Date Actions */
612 /*----------------------------------------------------------------------------*/
613 /* Shizhe Li NOV/10/2022 Create file */
614 /*----------------------------------------------------------------------------*/
MixtureThermal 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 OCP_DBL GRAVITY_FACTOR
0.00694444 ft2 psi / lb
Definition: OCPConst.hpp:56
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 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 OCP_DBL CONV5
0 F = CONV5 R
Definition: OCPConst.hpp:67
const USI PROD
Well type = producer.
Definition: OCPConst.hpp:123
const USI INJ
Well type = injector.
Definition: OCPConst.hpp:122
const USI THERMAL
Mixture model = ifThermal.
Definition: OCPConst.hpp:104
OCPTable class declaration.
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
Type_A_r< vector< OCP_DBL > > cpg4
Type_A_r< vector< OCP_DBL > > cpl1
Type_A_r< vector< OCP_DBL > > Tc
Critical temperature of hydrocarbon components.
Type_A_r< vector< OCP_DBL > > ev
coefficients in the vaporization enthalpy calculations
Type_A_r< vector< OCP_DBL > > MW
Molecular Weight of hydrocarbon components.
Type_A_r< vector< OCP_DBL > > cpg2
Type_A_r< vector< OCP_DBL > > avisc
coefficients in water and oil viscosity correlation formulae
Type_A_r< vector< OCP_DBL > > bvisc
coefficients in water and oil viscosity correlation formulae
vector< OCP_DBL > Pref
reference pressure
Type_A_r< vector< OCP_DBL > > cpl3
Type_A_r< vector< OCP_DBL > > cpl4
Type_A_r< vector< OCP_DBL > > hvapr
coefficients in the component gas enthalpy calculations, Btu/lbmol
Type_A_r< vector< OCP_DBL > > ct1
the first ifThermal expansion coefficient, 1/F
Type_A_r< vector< OCP_DBL > > cpt
Type_A_r< vector< OCP_DBL > > hvr
coefficients in the vaporization enthalpy calculations
Type_A_r< vector< OCP_DBL > > cpg1
Type_A_r< vector< OCP_DBL > > ct2
the second ifThermal expansion coefficient, 1/F
Type_A_r< vector< OCP_DBL > > cpg3
Type_A_r< vector< OCP_DBL > > cpl2
Type_A_r< vector< OCP_DBL > > cp
component compressibility, 1/psi
Type_A_r< vector< OCP_DBL > > molden
vector< OCP_DBL > Tref
reference temperature
vector< OCP_DBL > cpl1
vector< OCP_DBL > cpt
void CalProdWeight(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin, const vector< OCP_DBL > &prodPhase, vector< OCP_DBL > &prodWeight) override
Calculate ProdWeight for PROD well.
void SetupWellOpt(WellOpt &wellopt, const vector< SolventINJ > &sols, const OCP_DBL &Psurf, const OCP_DBL &Tsurf) override
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.
vector< OCP_DBL > MWp
Molecular Weight of phase.
vector< OCP_DBL > MWc
Molecular Weight of components.
vector< OCP_DBL > ev
Coefficients in the vaporization enthalpy calculations.
vector< OCP_DBL > ct1
The first thermal expansion coefficient, 1/F.
OCPTable visc
Viscosity-versus-temperature dependence.
OCP_DBL Tref
Reference temperature.
vector< OCP_DBL > cpl4
vector< OCP_DBL > cpg2
vector< OCP_DBL > ct2
The second thermal expansion coefficient, 1/F.
vector< OCP_DBL > Tcrit
Critical temperature of hydrocarbon components.
vector< OCP_DBL > avisc
Coefficients in water and oil viscosity correlation formulae.
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.
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_BOOL gas_based
Calculated enthalpy of fluid based gas.
OCP_DBL Pref
Reference pressure.
vector< OCP_DBL > cpl3
vector< OCP_DBL > data
vector< OCP_DBL > hvr
Coefficients in the vaporization enthalpy calculations.
vector< OCP_DBL > cdata
vector< OCP_DBL > xi_ref
vector< OCP_DBL > cpg4
OCP_DBL XiPhase(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin, const USI &tarPhase) override
vector< OCP_DBL > cpg3
void InitFlashIMPEC(const OCP_DBL &Pin, const OCP_DBL &Pbbin, const OCP_DBL &Tin, const OCP_DBL *Sjin, const OCP_DBL &Vpore, const OCP_DBL *Ziin, const OCP_USI &bId) override
flash calculation with saturation of phases.
vector< OCP_DBL > cp
Component compressibility, 1/psi.
OCP_BOOL useViscTab
If use viscosity to calculate viscosity.
vector< OCP_DBL > bvisc
Coefficients in water and oil viscosity correlation formulae.
vector< OCP_DBL > cpg1
vector< OCP_DBL > hvapr
Coefficients in the component gas enthalpy calculations, Btu/lbmol.
OCP_BOOL liquid_based
Calculated enthalpy of fluid based liquid.
void Flash(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin) override
flash calculation with saturation of phases.
vector< OCP_DBL > cpl2
void CalProdRate(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin, vector< OCP_DBL > &prodRate) override
Calculate Production rate for PROD well.
vector< OCP_DBL > rhoP
d rho / dP: numphase
Definition: Mixture.hpp:265
vector< OCP_DBL > muT
d mu j / dT: numPhase
Definition: Mixture.hpp:272
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
vector< OCP_DBL > Ufi
dUf / dNi
Definition: Mixture.hpp:280
OCP_DBL P
pressure when flash calculation.
Definition: Mixture.hpp:243
USI numPhase
num of phases.
Definition: Mixture.hpp:241
OCP_DBL vfT
d vf / dT
Definition: Mixture.hpp:261
vector< OCP_DBL > xix
d xi[j] / d x[i][j]: numphase * numCom
Definition: Mixture.hpp:270
vector< OCP_DBL > vj
volume of phase: numPhase;
Definition: Mixture.hpp:251
OCP_DBL vfP
Definition: Mixture.hpp:259
vector< OCP_DBL > rhox
d rho[j] / d x[i][j]: numphase * numCom
Definition: Mixture.hpp:267
OCP_DBL T
temperature when flash calculation.
Definition: Mixture.hpp:244
vector< OCP_DBL > Hx
d Hj / d xij
Definition: Mixture.hpp:283
vector< OCP_DBL > S
saturation of phase: numPhase
Definition: Mixture.hpp:250
vector< OCP_DBL > xij
Nij / nj: numPhase*numCom.
Definition: Mixture.hpp:253
vector< OCP_DBL > H
Enthalpy.
Definition: Mixture.hpp:281
OCP_DBL Nt
Total moles of Components.
Definition: Mixture.hpp:247
vector< OCP_DBL > xiT
d xi j / dT: numPhase
Definition: Mixture.hpp:269
vector< OCP_DBL > Ni
moles of component: numCom
Definition: Mixture.hpp:248
vector< OCP_DBL > HT
d Hj / d T
Definition: Mixture.hpp:282
vector< OCP_DBL > vfi
Definition: Mixture.hpp:262
OCP_DBL Uf
Internal energy of fluid.
Definition: Mixture.hpp:277
vector< OCP_BOOL > phaseExist
existence of phase: numPhase
Definition: Mixture.hpp:249
vector< OCP_DBL > rhoT
d rho j / dT: numPhase
Definition: Mixture.hpp:266
vector< OCP_DBL > xiP
d xi / dP: numphase
Definition: Mixture.hpp:268
OCP_DBL vf
volume of total fluids.
Definition: Mixture.hpp:246
vector< OCP_DBL > muP
d mu / dP: numPhase
Definition: Mixture.hpp:271
vector< OCP_DBL > mux
d mu[j] / d x[i][j]: numphase * numCom
Definition: Mixture.hpp:273
OCP_DBL UfP
dUf / dP
Definition: Mixture.hpp:278
OCP_DBL UfT
dUf / dT
Definition: Mixture.hpp:279
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
vector< OCP_DBL > & GetCol(const USI &j)
return the jth column in table to modify or use.
Definition: OCPTable.hpp:55
ComponentParam comsParam
information for components
vector< vector< vector< OCP_DBL > > > data
All table with the same name.
OCP_BOOL activity
If OCP_FALSE, this param is not given.
vector< T > data
Data of param.