16 MixtureThermal_K01::MixtureThermal_K01(
const ParamReservoir& param,
const USI& tarId)
39 OCP_ABORT(
"VISCTAB hasn't been input for " + to_string(tarId + 1) +
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);
188 exp(
cp[0] * dP -
ct1[0] * dT -
ct2[0] / 2 * pow(dT, 2) +
cpt[0] * dP * dT);
190 exp(
cp[1] * dP -
ct1[1] * dT -
ct2[1] / 2 * pow(dT, 2) +
cpt[1] * dP * dT);
193 Ni[0] = Vpore *
S[0] *
xi[0];
194 Ni[1] = Vpore *
S[1] *
xi[1];
197 void MixtureThermal_K01::InitFlashFIM(
const OCP_DBL& Pin,
237 exp(
cp[0] * dP -
ct1[0] * dT -
ct2[0] / 2 * pow(dT, 2) +
cpt[0] * dP * dT);
239 exp(
cp[1] * dP -
ct1[1] * dT -
ct2[1] / 2 * pow(dT, 2) +
cpt[1] * dP * dT);
262 vfP = -(
vj[0] * xiop /
xi[0] +
vj[1] * xiwp /
xi[1]);
267 vfT = -(
vj[0] * xioT /
xi[0] +
vj[1] * xiwT /
xi[1]);
306 exp(
cp[0] * dP -
ct1[0] * dT -
ct2[0] * pow(dT, 2) / 2 +
cpt[0] * dP * dT);
308 exp(
cp[1] * dP -
ct1[1] * dT -
ct2[1] * pow(dT, 2) / 2 +
cpt[1] * dP * dT);
358 void MixtureThermal_K01::CalEnthalpy()
360 fill(
H.begin(),
H.end(), 0.0);
361 fill(
HT.begin(),
HT.end(), 0.0);
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));
377 cpl3[i] * pow(dT, 2) +
cpl4[i] * pow(dT, 3));
384 1.0 / 3 *
cpg3[i] * pow(dT, 3) +
385 1.0 / 4 *
cpg4[i] * pow(dT, 4);
389 cpg3[i] * pow(dT, 2) +
cpg4[i] * pow(dT, 3));
414 Uf +=
S[j] *
xi[j] *
H[j];
432 vector<OCP_DBL> zi{0, 1};
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));
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));
464 if (tarPhase ==
WATER) {
467 ct2[1] * pow(dT, 2) / 2 +
cpt[1] * dP * dT);
486 if (tarPhase ==
OIL) {
488 ct2[0] * pow(dT, 2) / 2 +
cpt[0] * dP * dT);
490 }
else if (tarPhase ==
WATER) {
493 ct2[1] * pow(dT, 2) / 2 +
cpt[1] * dP * dT);
503 const vector<OCP_DBL>& prodPhase,
504 vector<OCP_DBL>& prodWeight)
516 exp(
cp[0] * dP -
ct1[0] * dT -
ct2[0] / 2 * pow(dT, 2) +
cpt[0] * dP * dT);
518 exp(
cp[1] * dP -
ct1[1] * dT -
ct2[1] / 2 * pow(dT, 2) +
cpt[1] * dP * dT);
525 vector<OCP_DBL> factor(
numPhase, 0);
526 factor[0] =
vj[0] / qt /
CONV1;
527 factor[1] =
vj[1] / qt /
CONV1;
530 for (
USI i = 0; i < 2; i++) {
531 tmp += factor[i] * prodPhase[i];
533 if (tmp < 1E-12 || !isfinite(tmp)) {
536 fill(prodWeight.begin(), prodWeight.end(), tmp);
542 vector<OCP_DBL>& prodRate)
554 exp(
cp[0] * dP -
ct1[0] * dT -
ct2[0] / 2 * pow(dT, 2) +
cpt[0] * dP * dT);
556 exp(
cp[1] * dP -
ct1[1] * dT -
ct2[1] / 2 * pow(dT, 2) +
cpt[1] * dP * dT);
567 const vector<SolventINJ>& sols,
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") {
577 opt.SetInjProdPhase(
WATER);
581 opt.SetInjFactor(tmp);
586 }
else if (wellType ==
PROD) {
587 vector<OCP_DBL> tmpWght(
numPhase, 0);
588 switch (opt.OptMode()) {
603 opt.SetProdPhaseWeight(tmpWght);
MixtureThermal class declaration.
unsigned int USI
Generic unsigned integer.
double OCP_DBL
Double precision.
const OCP_DBL CONV1
1 bbl = CONV1 ft3
const OCP_DBL GRAVITY_FACTOR
0.00694444 ft2 psi / lb
const USI LRATE_MODE
Well option = fixed fluid rate???
const USI WRATE_MODE
Well option = fixed water rate.
const USI WATER
Fluid type = water.
const USI ORATE_MODE
Well option = fixed oil rate.
const USI OIL
Fluid type = oil.
unsigned int OCP_USI
Long unsigned integer.
const OCP_DBL CONV5
0 F = CONV5 R
const USI PROD
Well type = producer.
const USI INJ
Well type = injector.
const USI THERMAL
Mixture model = ifThermal.
OCPTable class declaration.
#define OCP_ABORT(msg)
Abort if critical error happens.
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
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 > 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 > hvr
Coefficients in the vaporization enthalpy calculations.
OCP_DBL XiPhase(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin, const USI &tarPhase) override
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 > 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.
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
vector< OCP_DBL > muT
d mu j / dT: numPhase
USI numCom
num of components.
vector< OCP_DBL > dXsdXp
derivatives of second variables wrt. primary variables
vector< OCP_DBL > rho
mass density of phase: numPhase
vector< OCP_DBL > mu
viscosity of phase: numPhase
vector< OCP_DBL > Ufi
dUf / dNi
OCP_DBL P
pressure when flash calculation.
USI numPhase
num of phases.
vector< OCP_DBL > xix
d xi[j] / d x[i][j]: numphase * numCom
vector< OCP_DBL > vj
volume of phase: numPhase;
vector< OCP_DBL > rhox
d rho[j] / d x[i][j]: numphase * numCom
OCP_DBL T
temperature when flash calculation.
vector< OCP_DBL > Hx
d Hj / d xij
vector< OCP_DBL > S
saturation of phase: numPhase
vector< OCP_DBL > xij
Nij / nj: numPhase*numCom.
vector< OCP_DBL > H
Enthalpy.
OCP_DBL Nt
Total moles of Components.
vector< OCP_DBL > xiT
d xi j / dT: numPhase
vector< OCP_DBL > Ni
moles of component: numCom
vector< OCP_DBL > HT
d Hj / d T
OCP_DBL Uf
Internal energy of fluid.
vector< OCP_BOOL > phaseExist
existence of phase: numPhase
vector< OCP_DBL > rhoT
d rho j / dT: numPhase
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)
Careful: the memory outdata and slope have not be allocated before.
void Setup(const vector< vector< OCP_DBL >> &src)
Setup tables from existing data of table.
vector< OCP_DBL > & GetCol(const USI &j)
return the jth column in table to modify or use.
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.