OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
Public Member Functions | List of all members
MixtureComp Class Reference
Inheritance diagram for MixtureComp:
Mixture

Public Member Functions

OCP_DBL GetErrorPEC () override
 
OCP_ULL GetSSMSTAiters () override
 
OCP_ULL GetNRSTAiters () override
 
OCP_ULL GetSSMSPiters () override
 
OCP_ULL GetNRSPiters () override
 
OCP_ULL GetRRiters () override
 
OCP_ULL GetSSMSTAcounts () override
 
OCP_ULL GetNRSTAcounts () override
 
OCP_ULL GetSSMSPcounts () override
 
OCP_ULL GetNRSPcounts () override
 
OCP_ULL GetRRcounts () override
 
 MixtureComp (const ParamReservoir &rs_param, const USI &i)
 
 MixtureComp (const EoSparam &param, const USI &i)
 
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.
 
void InitFlashDer (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
 
void InitFlashDer_n (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
 
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 CalFlash (const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin)
 
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.
 
void FlashDeriv_n (const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Niin, const OCP_DBL *Sjin, const OCP_DBL *xijin, const OCP_DBL *njin, const USI &ftype, const USI *phaseExistin, const USI &lastNP, const OCP_DBL *lastKs) override
 
OCP_DBL XiPhase (const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin) override
 
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 GammaPhaseG (const OCP_DBL &Pin) override
 return gamma of gas phase, gamma equals to mass density times gravity factor.
 
OCP_DBL GammaPhaseW (const OCP_DBL &Pin) override
 return gamma of water phase, gamma equals to mass density times gravity factor.
 
OCP_DBL GammaPhaseOG (const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin) override
 
void setPT (const OCP_DBL &p, const OCP_DBL &t)
 
void setZi (const OCP_DBL *Ziin)
 
void setZi ()
 
void setNi (const OCP_DBL *Niin)
 
void CallId ()
 
USI GetFtype () override
 
void CalSurfaceTension ()
 
OCP_DBL GetSurTen () override
 
void AllocateEoS ()
 
void SolEoS (OCP_DBL &ZjT, const OCP_DBL &AjT, const OCP_DBL &BjT) const
 
void CalAiBi ()
 
void CalAjBj (OCP_DBL &AjT, OCP_DBL &BjT, const vector< OCP_DBL > &xj) const
 
void CalAjBj (OCP_DBL &AjT, OCP_DBL &BjT, const OCP_DBL *xj) const
 
USI CubicRoot (const OCP_DBL &a, const OCP_DBL &b, const OCP_DBL &c, const bool &NTflag=false) const
 Result is stored in Ztmp.
 
void PrintZtmp ()
 test
 
void AllocatePhase ()
 
void CalFugPhi (vector< OCP_DBL > &phiT, vector< OCP_DBL > &fugT, const vector< OCP_DBL > &xj)
 
void CalFugPhi (OCP_DBL *phiT, OCP_DBL *fugT, const OCP_DBL *xj)
 
void CalFugPhi (OCP_DBL *fugT, const OCP_DBL *xj)
 
void CalFugPhiAll ()
 
void CalMW ()
 
void CalVfXiRho ()
 
void CalSaturation ()
 
USI FindMWmax ()
 
void x2n ()
 x[j][i] -> n[j][i]
 
void PrintX ()
 
void AllocateMethod ()
 
void PhaseEquilibrium ()
 
void CalKwilson ()
 
bool PhaseStable ()
 
bool StableSSM (const USI &Id)
 strict SSM
 
bool StableSSM01 (const USI &Id)
 relaxable SSM
 
bool StableNR (const USI &Id)
 
void CalFugXSTA ()
 Calculate d ln(Fug) / dx for Y.
 
void AssembleJmatSTA ()
 
bool CheckSplit ()
 
void PhaseSplit ()
 
void SplitSSM (const bool &flag)
 
void SplitSSM2 (const bool &flag)
 
void SplitSSM3 (const bool &flag)
 
void RachfordRice2 ()
 Used when NP = 2.
 
void RachfordRice2P ()
 Used when NP = 2, improved RachfordRice2.
 
void RachfordRice3 ()
 Used when NP > 2.
 
void UpdateXRR ()
 Update X according to RR.
 
void SplitBFGS ()
 Use BFGS to calculate phase splitting.
 
void SplitNR ()
 Use NR to calculate phase splitting.
 
void CalResSP ()
 
void CalFugNAll (const bool &Znflag=true)
 
void PrintFugN ()
 
void AssembleJmatSP ()
 
void CalPhiNSTA ()
 Calculate d ln phi[i][j] / d n[k][j].
 
void AssembleSkipMatSTA ()
 
OCP_DBL CalStepNRsp ()
 
OCP_SIN GetMinEigenSkip () override
 
bool GetFlagSkip () override
 
void AllocateOthers ()
 
void IdentifyPhase ()
 
void CopyPhase ()
 Copy the basic properties from MixtureComp to Mixture.
 
void CalViscosity ()
 
void CalViscoLBC ()
 
void CalViscoHZYT ()
 
void CalFugXAll ()
 
void CalFugPAll (const bool &Zpflag=true)
 
void CalVjpVfpVfx_partial ()
 
void CalXiPNX_partial ()
 
void CalRhoPX_partial ()
 
void CalMuPX_partial ()
 
void CalMuPXLBC_partial ()
 
void CalXiRhoMuPN_pfullx ()
 
void CaldXsdXpAPI04 ()
 
void CaldXsdXp04 ()
 
void CalRhoPNX_full ()
 
void CalXiPNX_full01 ()
 
void CalRhoPNX_full01 ()
 
void CalMuPX_full01 ()
 
void CalMuPXLBC_full01 ()
 
void CalVfiVfp_full01 ()
 
void AssembleMatVfiVfp_full01 ()
 
void AssembleRhsVfiVfp_full01 ()
 
void CaldXsdXp01 ()
 
void CaldXsdXpAPI01 ()
 
void CalXiPNX_full02 ()
 
void CalVfiVfp_full02 ()
 
void AssembleMatVfiVfp_full02 ()
 
void AssembleRhsVfiVfp_full02 ()
 
void CaldXsdXpAPI02 ()
 
void CaldXsdXpAPI02p ()
 
void CalVjpVfpVfn_partial ()
 
void CalXiPn_partial ()
 
void CalRhoPn_partial ()
 
void CalMuPn_partial ()
 
void CalMuPnLBC_partial ()
 
void CalXiRhoMuPN_pfullxn (const bool &xflag=true)
 
void CaldXsdXpAPI03 ()
 
void CaldXsdXp03 ()
 
void CalVfiVfp_full03 ()
 
void CalKeyDerx ()
 
void CalKeyDern ()
 
- Public Member Functions inherited from Mixture
void Allocate ()
 Allocate memory for common variables for basic class.
 
virtual void SetPVTW ()
 
USI GetType () const
 return type of mixture.
 
virtual bool IsEmpty_PVDG () const
 Check whether Table PVDG is empty, it will only be used in black oil model.
 
void CheckNi (const OCP_DBL *Ni)
 

Additional Inherited Members

- Protected Attributes inherited from Mixture
USI mixtureType
 
USI numPhase
 num of phases.
 
USI numCom
 num of components.
 
OCP_DBL P
 pressure when flash calculation.
 
OCP_DBL T
 temperature when flash calculation.
 
vector< OCP_DBLNi
 moles of component: numCom
 
vector< bool > phaseExist
 existence of phase: numPhase
 
vector< OCP_DBLS
 saturation of phase: numPhase
 
vector< OCP_DBLrho
 mass density of phase: numPhase
 
vector< OCP_DBLxi
 molar density of phase: numPhase
 
vector< OCP_DBLxij
 
vector< OCP_DBLnj
 mole number of phase j
 
vector< OCP_DBLmu
 viscosity of phase: numPhase
 
vector< OCP_DBLv
 volume of phase: numPhase;
 
OCP_DBL vf
 volume of total fluids.
 
OCP_DBL Nt
 Total moles of Components.
 
vector< vector< OCP_DBL > > vji
 dvj / dNi, used in 2 hydrocarbon phase in EOS; or dvj / dnij
 
vector< OCP_DBLvjp
 dvj / dp, used in 2 hydrocarbon phase in EOS
 
OCP_DBL vfp
 
vector< OCP_DBLvfi
 
vector< OCP_DBLmuP
 d mu / dP: numPhase
 
vector< OCP_DBLxiP
 d xi / dP: numphase
 
vector< OCP_DBLrhoP
 d rho / dP: numphase
 
vector< OCP_DBLmuN
 d mu[j] / d N[i]: numphase * numCom
 
vector< OCP_DBLxiN
 d xi[j] / d N[i]: numphase * numCom
 
vector< OCP_DBLrhoN
 d rho[j] / d N[i]: numphase * numCom
 
vector< OCP_DBLmux
 d mu[j] / d x[i][j]: numphase * numCom
 
vector< OCP_DBLxix
 d xi[j] / d x[i][j]: numphase * numCom
 
vector< OCP_DBLrhox
 d rho[j] / d x[i][j]: numphase * numCom
 
vector< OCP_DBLdXsdXp
 the derivates of second variables wrt. primary variables
 
vector< USIpEnumCom
 see pEnumCom in bulk
 
vector< OCP_DBLres
 residual of a set of equations
 
OCP_DBL resPc
 a precalculated value
 
vector< OCP_DBLkeyDer
 d (xij*xi/mu) / dP or dNk
 

Detailed Description

Definition at line 127 of file MixtureComp.hpp.

Member Function Documentation

◆ FlashDeriv_n()

void MixtureComp::FlashDeriv_n ( const OCP_DBL Pin,
const OCP_DBL Tin,
const OCP_DBL Niin,
const OCP_DBL Sjin,
const OCP_DBL xijin,
const OCP_DBL njin,
const USI ftype,
const USI phaseExistin,
const USI lastNP,
const OCP_DBL lastKs 
)
overridevirtual

Becareful if NP > 2 (temp)

Implements Mixture.

Definition at line 514 of file MixtureComp.cpp.

518 {
519  inputNP = 0;
520  for (USI j = 0; j < numPhase; j++) {
521  if (phaseExistin[j] == 1)
522  inputNP++;
523  }
524  inputNP--;
525 
526 
527  if (inputNP == 1 || true) {
528  ftype = myftype;
529  lNP = lastNP;
530  if (lNP == 2) {
531  Dcopy(NC, &lKs[0], lastKs);
532  }
533  CalFlash(Pin, Tin, Niin);
534  }
535  else {
537  NP = inputNP;
538  P = Pin; T = Tin;
539  setNi(Niin);
540  CalAiBi();
541  Nh = Dnorm1(NC, &Ni[0]);
542  for (USI j = 0; j < NP; j++) {
543  phaseExist[j] = phaseExistin[j];
544  S[j] = Sjin[j];
545  nu[j] = njin[j];
546  nj[j] = njin[j];
547  Dcopy(NC, &x[j][0], &xijin[j * numCom]);
548  Dcopy(NC, &xij[j * numCom], &xijin[j * numCom]);
549  }
550  CalFugPhiAll();
551  S[numPhase - 1] = Sjin[numPhase - 1];
552  phaseLabel[0] = OIL; phaseLabel[1] = GAS;
553  CalMW();
554  CalVfXiRho();
555  CalViscosity();
556  CopyPhase();
557  CalSurfaceTension();
558  }
559 
560 
561  CalVjpVfpVfn_partial();
562 
563  // Water Properties
564  USI Wpid = numPhase - 1;
565  USI Wcid = numCom - 1;
566  phaseExist[Wpid] = true;
567  xij[Wpid * numCom + Wcid] = 1.0;
568  nj[Wpid] = Ni[Wcid];
569  Nt = Nh + Ni[Wcid];
570  PVTW.Eval_All(0, P, data, cdata);
571  OCP_DBL Pw0 = data[0];
572  OCP_DBL bw0 = data[1];
573  OCP_DBL cbw = data[2];
574  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
575  OCP_DBL bwp = -cbw * bw0;
576  mu[Wpid] = data[3];
577  xi[Wpid] = 1 / (CONV1 * bw);
578  rho[Wpid] = std_RhoW / bw;
579  muP[Wpid] = cdata[3];
580  xiP[Wpid] = -bwp / (bw * bw * CONV1);
581  rhoP[Wpid] = CONV1 * xiP[Wpid] * std_RhoW;
582  v[Wpid] = CONV1 * Ni[Wcid] * bw;
583  vfi[Wcid] = CONV1 * bw;
584  const OCP_DBL vwp = CONV1 * Ni[Wcid] * bwp;
585  vf += v[Wpid];
586  vfp += vwp;
587  vji[numPhase - 1][numCom - 1] = vfi[Wcid];
588  vjp[numPhase - 1] = vwp;
589 
590  CalSaturation();
591 
592  // calculate diff
593  if (inputNP == NP && NP == 2 && false) {
594  cout << scientific << setprecision(3);
595  cout << "--------- " << NP << " --------- " << inputNP << endl;
596  for (USI j = 0; j < NP; j++) {
597  USI j1 = phaseLabel[j];
598  cout << setw(10) << S[j1] - Sjin[j1] << " "
599  << setw(10) << (nj[j1] - njin[j1]) / njin[j1] << " ";
600  for (USI i = 0; i < NC; i++) {
601  cout << setw(10) << xij[j1 * numCom + i] - xijin[j1 * numCom + i] << " ";
602  }
603  cout << endl;
604  }
605  cout << S[2] - Sjin[2] << endl;
606  }
607 
608 
609  CaldXsdXpAPI03();
610  CalXiPn_partial();
611  CalRhoPn_partial();
612  CalMuPn_partial();
613  CalVfiVfp_full03();
614 
615  // Calculate pEnumCom
616  fill(pEnumCom.begin(), pEnumCom.end(), 0.0);
617  if (phaseExist[0]) pEnumCom[0] = NC;
618  if (phaseExist[1]) pEnumCom[1] = NC;
619 
620 }
double Dnorm1(const int &N, double *x)
Computes the L1-norm of a vector.
Definition: DenseMat.cpp:50
void Dcopy(const int &N, double *dst, const double *src)
Calculate the minimal eigenvalue for sysmetric matrix with mkl lapack.
Definition: DenseMat.cpp:37
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:22
const USI GAS
Fluid type = gas.
Definition: OCPConst.hpp:83
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:26
const OCP_DBL CONV1
1 bbl = CONV1 ft3
Definition: OCPConst.hpp:59
const USI OIL
Fluid type = oil.
Definition: OCPConst.hpp:82
void CopyPhase()
Copy the basic properties from MixtureComp to Mixture.
vector< OCP_DBL > rhoP
d rho / dP: numphase
Definition: Mixture.hpp:187
vector< USI > pEnumCom
see pEnumCom in bulk
Definition: Mixture.hpp:196
USI numCom
num of components.
Definition: Mixture.hpp:157
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
vector< OCP_DBL > vjp
dvj / dp, used in 2 hydrocarbon phase in EOS
Definition: Mixture.hpp:178
USI numPhase
num of phases.
Definition: Mixture.hpp:156
vector< vector< OCP_DBL > > vji
dvj / dNi, used in 2 hydrocarbon phase in EOS; or dvj / dnij
Definition: Mixture.hpp:177
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 > nj
mole number of phase j
Definition: Mixture.hpp:168
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

References CONV1, CopyPhase(), Dcopy(), Dnorm1(), OCPTable::Eval_All(), GAS, Mixture::mu, Mixture::muP, Mixture::Ni, Mixture::nj, Mixture::Nt, Mixture::numCom, Mixture::numPhase, OIL, Mixture::pEnumCom, Mixture::phaseExist, Mixture::rho, Mixture::rhoP, Mixture::S, Mixture::v, Mixture::vf, Mixture::vfi, Mixture::vfp, Mixture::vji, Mixture::vjp, Mixture::xi, Mixture::xij, and Mixture::xiP.

◆ GammaPhaseOG()

OCP_DBL MixtureComp::GammaPhaseOG ( const OCP_DBL Pin,
const OCP_DBL Tin,
const OCP_DBL Ziin 
)
overridevirtual

return gamma of hydrocarbon mixture, gamma equals to mass density times gravity factor.

Implements Mixture.

Definition at line 704 of file MixtureComp.cpp.

706 {
707  // assume that only single phase exists here, no matter it's oil or gas
708  OCP_DBL rhotmp = RhoPhase(Pin, Tin, Ziin);
709  return rhotmp * GRAVITY_FACTOR;
710 }
const OCP_DBL GRAVITY_FACTOR
0.00694444 ft2 psi / lb
Definition: OCPConst.hpp:52
OCP_DBL RhoPhase(const OCP_DBL &Pin, const OCP_DBL &Tin, const OCP_DBL *Ziin) override
return mass density of phase.

References GRAVITY_FACTOR, and RhoPhase().

◆ XiPhase()

OCP_DBL MixtureComp::XiPhase ( const OCP_DBL Pin,
const OCP_DBL Tin,
const OCP_DBL Ziin 
)
overridevirtual

Return molar density of phase, it's used to calculate the molar density of injection fluids in injection wells.

Implements Mixture.

Definition at line 644 of file MixtureComp.cpp.

646 {
647  // assume that only single phase exists here
648  if (Ziin[numCom - 1] > 1 - 1e-6) {
649  // water phase
650  PVTW.Eval_All(0, Pin, data, cdata);
651  OCP_DBL Pw0 = data[0];
652  OCP_DBL bw0 = data[1];
653  OCP_DBL cbw = data[2];
654  OCP_DBL bw = bw0 * (1 - cbw * (P - Pw0));
655  OCP_DBL xitmp = 1 / (CONV1 * bw);
656  return xitmp;
657  } else {
658  // hydrocarbon phase
659  setPT(Pin, Tin);
660  setZi(Ziin);
661  NP = 1;
662  CalAiBi();
663  CalAjBj(Aj[0], Bj[0], zi);
664  SolEoS(Zj[0], Aj[0], Bj[0]);
665  OCP_DBL vtmp = Zj[0] * GAS_CONSTANT * T / P;
666  for (USI i = 0; i < NC; i++) {
667  vtmp -= zi[i] * Vshift[i];
668  }
669  OCP_DBL xitmp = 1 / vtmp;
670  return xitmp;
671  }
672 }
const OCP_DBL GAS_CONSTANT
Gas Constant.
Definition: OCPConst.hpp:35

References CONV1, OCPTable::Eval_All(), GAS_CONSTANT, and Mixture::numCom.


The documentation for this class was generated from the following files: