20 BOMixtureInit(rs_param);
36 for (
USI i = 0; i < 3; i++)
Ni[i] = 0;
37 fill(
xij.begin(),
xij.end(), 0.0);
49 OCP_DBL bw = bw0 * (1 - cbw * (
P - Pw0));
55 Ni[2] = Vpore *
S[2] *
xi[2];
59 if (1 -
S[1] -
S[2] <
TINY) {
64 }
else if (
S[1] <
TINY)
93 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
117 xi[1] = 1 / 1000 / bg;
119 Ni[1] = Vpore *
S[1] *
xi[1];
122 v[1] = 1000 *
Ni[1] * bg;
130 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
149 OCP_DBL bo = bosat * (1 - cbosat * (
P - Pbb));
151 OCP_DBL dBo_drs = bo / bosat * cdata[2] +
152 bosat * (cdata[4] * (Pbb -
P) + cbosat * cdata[0]);
155 Ni[0] = Vpore * (1 -
S[1] -
S[2]) / (
CONV1 * bo);
157 xi[0] = (1 + rs) / (
CONV1 * bo);
159 mu[0] = muosat * (1 + cmuosat * (
P - Pbb));
161 xij[0 * 3 + 0] =
Ni[0] / (
Ni[0] +
Ni[1]);
162 xij[0 * 3 + 1] = 1 -
xij[0 * 3 + 0];
193 Ni[0] = Vpore * (1 -
S[1] -
S[2]) / (
CONV1 * bo);
194 xi[0] = (1 + rs) / (
CONV1 * bo);
201 Ni[1] = Vpore *
S[1] / bg / 1000 +
Ni[0] * rs;
206 xij[0 * 3 + 0] = 1 / (1 + rs);
207 xij[0 * 3 + 1] = 1 -
xij[0 * 3 + 0];
213 v[1] = 1000 * (
Ni[1] - rs *
Ni[0]) * bg;
216 vf =
v[0] +
v[1] +
v[2];
221 1000 * (-crs *
Ni[0] * bg + (
Ni[1] - rs *
Ni[0]) * cbg) +
223 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
238 fill(
xij.begin(),
xij.end(), 0.0);
252 OCP_DBL bw = bw0 * (1 - cbw * (
P - Pw0));
263 if (
Ni[1] <=
Ni[0] * Rs_sat)
267 }
else if (
Ni[1] <=
Ni[0] * Rs_sat)
296 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
320 xi[1] = 1 / 1000 / bg;
325 v[1] = 1000 * (
Ni[1] - rs *
Ni[0]) * bg;
339 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
349 xij[0 * 3 + 0] =
Ni[0] / (
Ni[0] +
Ni[1]);
350 xij[0 * 3 + 1] = 1 -
xij[0 * 3 + 0];
362 OCP_DBL bo = bosat * (1 - cbosat * (
P - pbb));
364 OCP_DBL dBo_drs = bo / bosat * cdata[2] +
365 bosat * (cdata[4] * (pbb -
P) + cbosat * cdata[0]);
367 mu[0] = muosat * (1 + cmuosat * (
P - pbb));
368 xi[0] = (1 + rs) / (
CONV1 * bo);
398 xi[0] = (1 + rs) / (
CONV1 * bo);
411 xij[0 * 3 + 0] = 1 / (1 + rs);
412 xij[0 * 3 + 1] = 1 -
xij[0 * 3 + 0];
417 v[1] = 1000 * (
Ni[1] - rs *
Ni[0]) * bg;
419 vf =
v[0] +
v[1] +
v[2];
424 1000 * (-crs *
Ni[0] * bg + (
Ni[1] - rs *
Ni[0]) * cbg) +
426 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
439 for (
USI j = 0; j < 3; j++) {
443 fill(
xij.begin(),
xij.end(), 0.0);
444 fill(
rhox.begin(),
rhox.end(), 0.0);
445 fill(
xix.begin(),
xix.end(), 0.0);
446 fill(
mux.begin(),
mux.end(), 0.0);
462 OCP_DBL bw = bw0 * (1 - cbw * (
P - Pw0));
477 if (
Ni[1] <=
Ni[0] * Rs_sat)
483 else if (
Ni[1] <=
Ni[0] * Rs_sat)
512 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
553 xi[1] = 1 / 1000 / bg;
557 xiP[1] = -cdata[1] / (
CONV1 * data[1] * data[1]);
562 v[1] = 1000 * (
Ni[1] - rs *
Ni[0]) * bg;
576 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
586 dXsdXp[1 * 4 + 1] = (-1000 * rs * bg -
S[1] *
vfi[0]) /
vf;
603 xij[0 * 3 + 0] =
Ni[0] / (
Ni[0] +
Ni[1]);
604 xij[0 * 3 + 1] = 1 -
xij[0 * 3 + 0];
616 OCP_DBL bo = bosat * (1 - cbosat * (
P - pbb));
618 OCP_DBL dBo_drs = (1 - cbosat * (
P - pbb)) * cdata[2] +
619 bosat * (cdata[4] * (pbb -
P) + cbosat * cdata[0]);
621 mu[0] = muosat * (1 + cmuosat * (
P - pbb));
622 xi[0] = (1 + rs) / (
CONV1 * bo);
625 muP[0] = muosat * cmuosat;
626 xiP[0] = -(1 + rs) * bop / (
CONV1 * bo * bo);
629 OCP_DBL muo_rs =
mu[0] / muosat * cdata[3] + muosat * (cdata[5] * (
P - pbb) - cmuosat * cdata[0]);
665 mux[0] = -muo_rs *
xij[1] / tmp;
668 xix[0] = -xio_rs *
xij[1] / tmp;
671 rhox[0] = -rhoo_rs *
xij[1] / tmp;
701 xi[0] = (1 + rs) / (
CONV1 * bo);
705 xiP[0] = (crs * bo - (1 + rs) * cbosat) / (bo * bo) /
CONV1;
718 xiP[1] = -cdata[1] / (
CONV1 * data[1] * data[1]);
722 xij[0 * 3 + 0] = 1 / (1 + rs);
723 xij[0 * 3 + 1] = 1 -
xij[0 * 3 + 0];
728 v[1] = 1000 * (
Ni[1] - rs *
Ni[0]) * bg;
730 vf =
v[0] +
v[1] +
v[2];
735 1000 * (-crs *
Ni[0] * bg + (
Ni[1] - rs *
Ni[0]) * cbg) +
737 vfi[0] =
CONV1 * bo - 1000 * rs * bg;
747 dXsdXp[1 * 4 + 0] = (1000 * (
Ni[1] - rs *
Ni[0]) * cbg - 1000 *
Ni[0] * bg * crs -
S[1] *
vfp) /
vf;
748 dXsdXp[1 * 4 + 1] = (-1000 * rs * bg -
S[1] *
vfi[0]) /
vf;
757 dXsdXp[3 * 4 + 0] = -crs / ((1 + rs) * (1 + rs));
777 if (Ziin[1] > 1 -
TINY) {
783 }
else if (Ziin[2] > 1 -
TINY) {
790 OCP_DBL bw = bw0 * (1 - cbw * (
P - Pw0));
801 if (Ziin[1] > 1 -
TINY) {
806 }
else if (Ziin[2] > 1 -
TINY) {
813 OCP_DBL bw = bw0 * (1 - cbw * (
P - Pw0));
824 PVCO.
Eval_All(0, Pbbin, data, cdata);
828 OCP_DBL bo = bosat * (1 - cbosat * (Pin - Pbbin));
851 OCP_DBL bw = (bw0 * (1 - cbw * (Pin - Pw0)));
MixtureBO class declaration.
const OCP_DBL TINY
Small constant.
unsigned int USI
Generic unsigned integer.
double OCP_DBL
Double precision.
const OCP_DBL CONV1
1 bbl = CONV1 ft3
const USI PHASE_ODGW
Phase type = oil-dry gas-water.
const USI PHASE_W
Phase type = water only.
const USI PHASE_OW
Phase type = oil-water.
const USI PHASE_GW
Phase type = gas-water.
#define OCP_ABORT(msg)
Abort if critical error happens.
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 GammaPhaseG(const OCP_DBL &Pin) override
return gamma of gas phase, gamma equals to mass density times gravity factor.
OCP_DBL XiPhase(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin) override
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 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.
OCP_DBL std_GammaO
std_RhoO * gravity factor.
OCP_DBL std_RhoW
mass density of water phase in standard condition.
OCP_DBL std_RhoG
mass density of gas phase in standard condition.
OCP_DBL std_RhoO
< others.
OCP_DBL std_GammaW
std_RhoW * gravity factor.
OCP_DBL std_GammaG
std_RhoG * gravity factor.
vector< OCP_DBL > rhoP
d rho / dP: numphase
vector< USI > pEnumCom
see pEnumCom in bulk
USI numCom
num of components.
vector< OCP_DBL > dXsdXp
the derivates of second variables wrt. primary variables
vector< OCP_DBL > rho
mass density of phase: numPhase
vector< OCP_DBL > mu
viscosity of phase: numPhase
vector< bool > phaseExist
existence of phase: numPhase
OCP_DBL P
pressure when flash calculation.
vector< OCP_DBL > xix
d xi[j] / d x[i][j]: numphase * numCom
vector< OCP_DBL > rhox
d rho[j] / d x[i][j]: numphase * numCom
vector< OCP_DBL > v
volume of phase: numPhase;
vector< OCP_DBL > S
saturation of phase: numPhase
OCP_DBL Nt
Total moles of Components.
vector< OCP_DBL > Ni
moles of component: numCom
vector< OCP_DBL > xiP
d xi / dP: numphase
OCP_DBL vf
volume of total fluids.
vector< OCP_DBL > muP
d mu / dP: numPhase
vector< OCP_DBL > mux
d mu[j] / d x[i][j]: numphase * numCom
vector< OCP_DBL > xi
molar density of phase: numPhase
USI Eval_All(const USI &j, const OCP_DBL &val, vector< OCP_DBL > &outdata, vector< OCP_DBL > &slope)
void Setup(const vector< vector< OCP_DBL >> &src)
Setup tables from existing data of table.
bool IsEmpty() const
judge if table is empty.
OCP_DBL Eval(const USI &j, const OCP_DBL &val, const USI &destj)
TableSet PVDG_T
Table set of PVDG.
TableSet PVTW_T
Table set of PVTW.
TableSet PVCO_T
Table set of PVCO.
vector< vector< vector< OCP_DBL > > > data
All table with the same name.