OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
Well.hpp
Go to the documentation of this file.
1 
12 #ifndef __WELL_HEADER__
13 #define __WELL_HEADER__
14 
15 // Standard header files
16 #include <cassert>
17 
18 // OpenCAEPoro header files
19 #include "Bulk.hpp"
20 #include "DenseMat.hpp"
21 #include "Grid.hpp"
22 #include "LinearSystem.hpp"
23 #include "OCPConst.hpp"
24 #include "OCPStructure.hpp"
25 #include "ParamWell.hpp"
26 #include "WellOpt.hpp"
27 #include "WellPerf.hpp"
28 
29 using namespace std;
30 
32 // General Well Error Type
34 
35 const int WELL_SUCCESS = 10;
36 const int WELL_NEGATIVE_PRESSURE = -11;
37 const int WELL_SWITCH_TO_BHPMODE = -12;
38 const int WELL_CROSSFLOW = -13;
39 
44 class Well
45 {
46  friend class AllWells;
47  friend class Out4RPT;
48 
49  // temp
50  friend class MyMetisTest;
51 
52 public:
53  Well() = default;
54 
56  // Input Param and Setup
58 
59 public:
61  void InputPerfo(const WellParam& well);
63  void Setup(const Grid& gd, const Bulk& bk, const vector<SolventINJ>& sols);
64 
66  // Basic Well information
68 
69 protected:
70  string name;
71  string group;
72  USI I;
73  USI J;
76  vector<WellOpt> optSet;
79  vector<Perforation> perf;
80 
81  vector<Mixture*> flashCal;
82 
85 
88 
91 
92 public:
94  void InitBHP(const Bulk& myBulk) { bhp = myBulk.P[perf[0].location]; }
96  void CalWI_Peaceman(const Bulk& myBulk);
98  void CalTrans(const Bulk& myBulk);
100  void CalFlux(const Bulk& myBulk, const OCP_BOOL ReCalXi = OCP_FALSE);
102  OCP_DBL CalInjRateMaxBHP(const Bulk& myBulk);
104  OCP_DBL CalProdRateMinBHP(const Bulk& myBulk);
107  void CalInjQj(const Bulk& myBulk, const OCP_DBL& dt);
110  void CalProdQj(const Bulk& myBulk, const OCP_DBL& dt);
112  void CaldG(const Bulk& myBulk);
114  void CalInjdG(const Bulk& myBulk);
116  void CalProddG(const Bulk& myBulk);
118  void CalProddG01(const Bulk& myBulk);
120  void CalProddG02(const Bulk& myBulk);
122  void CalProdWeight(const Bulk& myBulk) const;
124  void CalReInjFluid(const Bulk& myBulk, vector<OCP_DBL>& myZi);
126  void CorrectBHP();
128  void CheckOptMode(const Bulk& myBulk);
130  OCP_INT CheckP(const Bulk& myBulk);
132  OCP_INT CheckCrossFlow(const Bulk& myBulk);
134  void CalPerfP()
135  {
136  for (USI p = 0; p < numPerf; p++) perf[p].P = bhp + dG[p];
137  }
139  void ShowPerfStatus(const Bulk& myBulk) const;
140 
141  USI PerfNum() const { return numPerf; }
142  void SetBHP(const OCP_DBL& p) { bhp = p; }
143  OCP_DBL BHP() const { return bhp; }
144  OCP_DBL DG(const USI& p) const { return dG[p]; }
145  OCP_DBL ProdWeight(const USI& i) const { return prodWeight[i]; }
146 
147  USI OptMode() const { return opt.optMode; }
149  OCP_BOOL IsOpen() const { return opt.state; }
151  USI WellType() const { return opt.type; }
152  vector<OCP_DBL> InjZi() const
153  {
154  OCP_ASSERT(opt.type == INJ, "Wrong Call");
155  return opt.injZi;
156  }
157  OCP_DBL InjZi(const USI& i) const
158  {
159  OCP_ASSERT(opt.type == INJ, "Wrong Call");
160  return opt.injZi[i];
161  }
162  OCP_DBL MaxRate() const { return opt.maxRate; }
163  OCP_DBL MaxBHP() const
164  {
165  OCP_ASSERT(opt.type == INJ, "Wrong Call");
166  return opt.maxBHP;
167  }
168  OCP_DBL MinBHP() const
169  {
170  OCP_ASSERT(opt.type == PROD, "Wrong Call");
171  return opt.minBHP;
172  }
173  OCP_DBL InjTemp() const
174  {
175  OCP_ASSERT(opt.type == INJ, "Wrong Call");
176  return opt.injTemp;
177  }
178 
179  OCP_BOOL PerfState(const USI& p) const { return perf[p].state; }
180  USI PerfLocation(const USI& p) const { return perf[p].location; }
181  OCP_DBL PerfWI(const USI& p) const { return perf[p].WI; }
182  OCP_DBL PerfMultiplier(const USI& p) const { return perf[p].multiplier; }
183  OCP_DBL PerfTransInj(const USI& p) const { return perf[p].transINJ; }
184  OCP_DBL PerfXi(const USI& p) const { return perf[p].xi; }
185  OCP_DBL PerfTransj(const USI& p, const USI& j) const { return perf[p].transj[j]; }
186  OCP_DBL PerfQi_lbmol(const USI& p, const USI& i) const
187  {
188  return perf[p].qi_lbmol[i];
189  }
190  OCP_DBL PerfProdQj_ft3(const USI& p, const USI& j) const
191  {
192  OCP_ASSERT(opt.type == PROD, "Wrong Call");
193  return perf[p].qj_ft3[j];
194  }
195  OCP_DBL PerfInjQt_ft3(const USI& p) const
196  {
197  OCP_ASSERT(opt.type == INJ, "Wrong Call");
198  return perf[p].qt_ft3;
199  }
200  OCP_DBL Qi_lbmol(const USI& i) const { return qi_lbmol[i]; }
201  OCP_BOOL IfUseUnweight() const { return ifUseUnweight; }
202 
203 protected:
205  // Well Physical information
207 
208  mutable OCP_DBL bhp;
209  vector<OCP_DBL>
210  dG;
211 
212  // Last time step
214  vector<OCP_DBL> ldG;
215 
216  // PROD/INJ Rate
217  vector<OCP_DBL> qi_lbmol;
218  vector<OCP_DBL> prodRate;
219  mutable vector<OCP_DBL> prodWeight;
220 
221  OCP_DBL WOPR{0};
222  OCP_DBL WOPT{0};
223  OCP_DBL WGPR{0};
224  OCP_DBL WGPT{0};
225  OCP_DBL WWPR{0};
226  OCP_DBL WWPT{0};
227  OCP_DBL WGIR{0};
228  OCP_DBL WGIT{0};
229  OCP_DBL WWIR{0};
230  OCP_DBL WWIT{0};
231 
232  OCP_BOOL ifUseUnweight{OCP_FALSE};
234  // IMPEC
236 
237 public:
240  void AssembleMatReinjection_IMPEC(const Bulk& myBulk,
241  LinearSystem& myLS,
242  const OCP_DBL& dt,
243  const vector<Well>& allWell,
244  const vector<USI>& injId) const;
245 
247  // FIM
249 
250 public:
253  void AssembleMatReinjection_FIM(const Bulk& myBulk,
254  LinearSystem& myLS,
255  const OCP_DBL& dt,
256  const vector<Well>& allWell,
257  const vector<USI>& injId) const;
258 
259  // for output
260  void SetPolyhedronWell(const Grid& myGrid, OCPpolyhedron& mypol);
261 };
262 
263 #endif /* end if __WELL_HEADER__ */
264 
265 /*----------------------------------------------------------------------------*/
266 /* Brief Change History of This File */
267 /*----------------------------------------------------------------------------*/
268 /* Author Date Actions */
269 /*----------------------------------------------------------------------------*/
270 /* Shizhe Li Oct/01/2021 Create file */
271 /* Chensong Zhang Oct/15/2021 Format file */
272 /*----------------------------------------------------------------------------*/
Bulk class declaration.
Operations about small dense mat.
Grid class declaration.
Linear solver class declaration.
Definition of build-in datatypes and consts.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:27
const USI PROD
Well type = producer.
Definition: OCPConst.hpp:123
const OCP_DBL TEMPERATURE_STD
Standard temperature: F.
Definition: OCPConst.hpp:60
int OCP_INT
Long integer.
Definition: OCPConst.hpp:26
const USI INJ
Well type = injector.
Definition: OCPConst.hpp:122
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
Some Structure in OpenCAEPoro.
ParamWell class declaration.
#define OCP_ASSERT(cond, msg)
Assert condition and log user messages in DEBUG mode.
Definition: UtilError.hpp:58
WellOpt class declaration.
WellPerf class declaration.
Physical information of each active reservoir bulk.
Definition: Bulk.hpp:104
vector< OCP_DBL > P
Pressure: numBulk.
Definition: Bulk.hpp:309
Definition: Grid.hpp:89
Linear solvers for discrete systems.
Record the initial grid information, all of grids are contained.
Definition: Grid.hpp:75
Collect more detailed information of each time step.
Definition: OCPOutput.hpp:211
TODO: Add Doxygen.
Definition: ParamWell.hpp:59
Definition: Well.hpp:45
USI numPerf
num of perforations belonging to this well.
Definition: Well.hpp:78
OCP_DBL numPhase
num of phases
Definition: Well.hpp:83
vector< OCP_DBL > prodWeight
maybe only a num is needed
Definition: Well.hpp:219
vector< OCP_DBL > prodRate
flow rate of volume of phase outflowing
Definition: Well.hpp:218
USI wOId
Definition: Well.hpp:89
OCP_DBL depth
reference depth of well.
Definition: Well.hpp:74
USI I
I-index of the well header.
Definition: Well.hpp:72
WellOpt opt
well control parameters, contains current control parameters.
Definition: Well.hpp:75
OCP_DBL numCom
num of components
Definition: Well.hpp:84
string name
well name
Definition: Well.hpp:70
string group
group well belongs to, it should be moved to opt if necessary!!!
Definition: Well.hpp:71
void CalPerfP()
Update pressure in Perforation after well pressure updates.
Definition: Well.hpp:134
OCP_DBL bhp
Well pressure in reference depth.
Definition: Well.hpp:208
OCP_BOOL IsOpen() const
Return the state of the well, Open or Close.
Definition: Well.hpp:149
vector< OCP_DBL > ldG
Last dG.
Definition: Well.hpp:214
OCP_DBL lbhp
Last BHP.
Definition: Well.hpp:213
USI J
J-index of the well header.
Definition: Well.hpp:73
vector< WellOpt > optSet
Definition: Well.hpp:76
vector< Mixture * > flashCal
from bulks's flashCal
Definition: Well.hpp:81
void InitBHP(const Bulk &myBulk)
Initialize the Well BHP.
Definition: Well.hpp:94
USI WellType() const
Return the type of well, Inj or Prod.
Definition: Well.hpp:151
vector< OCP_DBL > qi_lbmol
flow rate of moles of component inflowing/outflowing
Definition: Well.hpp:217
vector< OCP_DBL > dG
difference of pressure between well and perforation: numPerf.
Definition: Well.hpp:210
vector< Perforation > perf
information of perforation belonging to this well.
Definition: Well.hpp:79