OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
MixtureThermal.hpp
Go to the documentation of this file.
1 
12 #ifndef __MIXTURETHERMAL_HEADER__
13 #define __MIXTURETHERMAL_HEADER__
14 
15 #include <cmath>
16 
17 // OpenCAEPoro header files
18 #include "Mixture.hpp"
19 #include "OCPTable.hpp"
20 
23 class MixtureThermal : public Mixture
24 {
25 public:
26  MixtureThermal() = default;
27  void Allocate()
28  {
29  Ni.resize(numCom);
30  phaseExist.resize(numPhase);
31  S.resize(numPhase);
32  vj.resize(numPhase);
33  nj.resize(numPhase);
34  xij.resize(numPhase * numCom);
35  rho.resize(numPhase);
36  xi.resize(numPhase);
37  mu.resize(numPhase);
38  vfi.resize(numCom);
39  rhoP.resize(numPhase);
40  rhoT.resize(numPhase);
41  rhox.resize(numPhase * numCom);
42  xiP.resize(numPhase);
43  xiT.resize(numPhase);
44  xix.resize(numPhase * numCom);
45  muP.resize(numPhase);
46  muT.resize(numPhase);
47  mux.resize(numPhase * numCom);
48  dXsdXp.resize((numCom + 1) * numPhase * (numCom + 2));
49  Ufi.resize(numCom);
50  H.resize(numPhase);
51  HT.resize(numPhase);
52  Hx.resize(numPhase * numCom);
53  }
54  void SetupOptionalFeatures(OptionalFeatures& optFeatures,
55  const OCP_USI& numBulk) override{};
56  // usless in Thermal model
57  OCP_DBL GetErrorPEC() override
58  {
59  OCP_ABORT("Should not be used in Thermal mode!");
60  return 0;
61  }
62  void OutMixtureIters() const override{};
63 };
64 
66 {
67 public:
68  MixtureThermal_K01() = default;
69  MixtureThermal_K01(const ParamReservoir& param, const USI& tarId);
70  void Flash(const OCP_DBL& Pin, const OCP_DBL& Tin, const OCP_DBL* Niin) override;
72  void InitFlashIMPEC(const OCP_DBL& Pin,
73  const OCP_DBL& Pbbin,
74  const OCP_DBL& Tin,
75  const OCP_DBL* Sjin,
76  const OCP_DBL& Vpore,
77  const OCP_DBL* Ziin,
78  const OCP_USI& bId) override;
79  void InitFlashFIM(const OCP_DBL& Pin,
80  const OCP_DBL& Pbbin,
81  const OCP_DBL& Tin,
82  const OCP_DBL* Sjin,
83  const OCP_DBL& Vpore,
84  const OCP_DBL* Ziin,
85  const OCP_USI& bId) override;
86  void InitFlashFIMn(const OCP_DBL& Pin,
87  const OCP_DBL& Pbbin,
88  const OCP_DBL& Tin,
89  const OCP_DBL* Sjin,
90  const OCP_DBL& Vpore,
91  const OCP_DBL* Ziin,
92  const OCP_USI& bId) override{};
94  void FlashIMPEC(const OCP_DBL& Pin,
95  const OCP_DBL& Tin,
96  const OCP_DBL* Niin,
97  const USI& lastNP,
98  const OCP_DBL* xijin,
99  const OCP_USI& bId) override;
101  void FlashFIM(const OCP_DBL& Pin,
102  const OCP_DBL& Tin,
103  const OCP_DBL* Niin,
104  const OCP_DBL* Sjin,
105  const USI& lastNP,
106  const OCP_DBL* xijin,
107  const OCP_USI& bId) override;
108  void FlashFIMn(const OCP_DBL& Pin,
109  const OCP_DBL& Tin,
110  const OCP_DBL* Niin,
111  const OCP_DBL* Sjin,
112  const OCP_DBL* xijin,
113  const OCP_DBL* njin,
114  const USI* phaseExistin,
115  const USI& lastNP,
116  const OCP_USI& bId) override{};
119  OCP_DBL XiPhase(const OCP_DBL& Pin,
120  const OCP_DBL& Tin,
121  const OCP_DBL* Ziin,
122  const USI& tarPhase) override;
123 
125  OCP_DBL RhoPhase(const OCP_DBL& Pin,
126  const OCP_DBL& Pbb,
127  const OCP_DBL& Tin,
128  const OCP_DBL* Ziin,
129  const USI& tarPhase) override;
130 
131  // for Well
132  void CalProdWeight(const OCP_DBL& Pin,
133  const OCP_DBL& Tin,
134  const OCP_DBL* Niin,
135  const vector<OCP_DBL>& prodPhase,
136  vector<OCP_DBL>& prodWeight) override;
137 
138  void CalProdRate(const OCP_DBL& Pin,
139  const OCP_DBL& Tin,
140  const OCP_DBL* Niin,
141  vector<OCP_DBL>& prodRate) override;
142 
143  void SetupWellOpt(WellOpt& wellopt,
144  const vector<SolventINJ>& sols,
145  const OCP_DBL& Psurf,
146  const OCP_DBL& Tsurf) override;
147  OCP_DBL CalInjWellEnthalpy(const OCP_DBL& Tin, const OCP_DBL* Ziin) override;
148 
149 protected:
150  void CalEnthalpy();
151 
152 protected:
155 
156  vector<OCP_DBL> MWc;
157  vector<OCP_DBL> MWp;
158  vector<OCP_DBL> Tcrit;
159  vector<OCP_DBL> xi_ref;
161  vector<OCP_DBL> cp;
162  vector<OCP_DBL> ct1;
163  vector<OCP_DBL> ct2;
164  vector<OCP_DBL> cpt;
166  OCP_BOOL liquid_based{OCP_TRUE};
167  OCP_BOOL gas_based{OCP_FALSE};
168  OCP_BOOL simple_hvap{OCP_FALSE};
170  vector<OCP_DBL> cpl1;
172  vector<OCP_DBL> cpl2;
174  vector<OCP_DBL> cpl3;
176  vector<OCP_DBL> cpl4;
178  vector<OCP_DBL> cpg1;
180  vector<OCP_DBL> cpg2;
182  vector<OCP_DBL> cpg3;
184  vector<OCP_DBL> cpg4;
186  vector<OCP_DBL>
188  vector<OCP_DBL> hvr;
189  vector<OCP_DBL> ev;
190  vector<OCP_DBL>
192  vector<OCP_DBL>
194  vector<OCP_DBL> avg;
195  vector<OCP_DBL> bvg;
198  vector<OCP_DBL> data;
200  vector<OCP_DBL> cdata;
202 };
203 
204 #endif /* end if __MIXTURETHERMAL_HEADER__ */
205 
206 /*----------------------------------------------------------------------------*/
207 /* Brief Change History of This File */
208 /*----------------------------------------------------------------------------*/
209 /* Author Date Actions */
210 /*----------------------------------------------------------------------------*/
211 /* Shizhe Li NOV/10/2022 Create file */
212 /*----------------------------------------------------------------------------*/
Mixture class declaration.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:27
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:25
const OCP_DBL TEMPERATURE_STD
Standard temperature: F.
Definition: OCPConst.hpp:60
unsigned int OCP_BOOL
OCP_BOOL in OCP.
Definition: OCPConst.hpp:29
const OCP_DBL PRESSURE_STD
14.6959 psia = 1 atm
Definition: OCPConst.hpp:59
OCPTable class declaration.
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
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 > bvg
Coefficients Bk in gas viscosity correlation formulae.
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.
vector< OCP_DBL > avg
Coefficients Ak in gas viscosity correlation formulae.
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
USI numPhase
num of phases.
Definition: Mixture.hpp:241
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
vector< OCP_DBL > rhox
d rho[j] / d x[i][j]: numphase * numCom
Definition: Mixture.hpp:267
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
vector< OCP_DBL > xiT
d xi j / dT: numPhase
Definition: Mixture.hpp:269
vector< OCP_DBL > nj
mole number of phase j
Definition: Mixture.hpp:252
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
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
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
vector< OCP_DBL > xi
molar density of phase: numPhase
Definition: Mixture.hpp:255