OpenCAEPoro  0.2.0 Sep/22/2022
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 "WellPerf.hpp"
27 
28 using namespace std;
29 
32 {
33 public:
34  SolventINJ() = default;
35  SolventINJ& operator=(const Solvent& other)
36  {
37  name = other.name;
38  data = other.comRatio;
39  return *this;
40  };
41  string name;
42  vector<OCP_DBL> data;
43 };
44 
48 class WellOpt
49 {
50  friend class Well;
51  friend class AllWells;
52  friend class DetailInfo;
53 
54 public:
56  WellOpt() = default;
57 
59  WellOpt(const WellOptParam& Optparam);
60 
62  bool operator !=(const WellOpt& Opt) const;
63 
64 private:
65  USI type{0};
68  string fluidType;
69  bool state{false};
70  USI optMode;
72  USI initOptMode;
76  OCP_DBL maxRate;
81  OCP_DBL maxBHP;
86  OCP_DBL minBHP;
91  vector<OCP_DBL> zi;
92  OCP_DBL xiINJ;
93  // for Reinjection
94  bool reInj{false};
95  USI injPhase;
96  OCP_DBL factor;
97  vector<USI> connWell;
98 };
99 
104 class Well
105 {
106  friend class AllWells;
107  friend class DetailInfo;
108 
109 public:
110  Well() = default;
111 
113  // General
115 
116 public:
118  void InputPerfo(const WellParam& well);
120  void Setup(const Grid& myGrid, const Bulk& myBulk, const vector<SolventINJ>& sols);
122  void InitBHP(const Bulk& myBulk);
124  void CalWI_Peaceman_Vertical(const Bulk& myBulk);
126  void CalTrans(const Bulk& myBulk);
128  void CalFlux(const Bulk& myBulk, const bool flag = false);
130  OCP_DBL CalInjRate(const Bulk& myBulk, const bool& maxBHP);
132  OCP_DBL CalProdRate(const Bulk& myBulk, const bool& minBHP);
134  void CalInjQi(const Bulk& myBulk, const OCP_DBL& dt);
136  void CalProdQj(const Bulk& myBulk, const OCP_DBL& dt);
138  void CalProdQjCOMP(const Bulk& myBulk);
141  void CalProdQiBO(const Bulk& myBulk);
143  void CaldG(const Bulk& myBulk);
145  void CalInjdG(const Bulk& myBulk);
147  void CalProddG(const Bulk& myBulk);
149  void CalProdWeight(const Bulk& myBulk) const;
151  void CalReInjFluid(const Bulk& myBulk, vector<OCP_DBL>& myZi);
153  void SetBHP();
155  void SmoothdG();
157  void CheckOptMode(const Bulk& myBulk);
159  OCP_INT CheckP(const Bulk& myBulk);
161  OCP_INT CheckCrossFlow(const Bulk& myBulk);
163  void UpdatePerfP()
164  {
165  for (USI p = 0; p < numPerf; p++) perf[p].P = BHP + dG[p];
166  }
168  void AllocateMat(LinearSystem& myLS) const;
170  void SetupWellBulk(Bulk& myBulk) const;
172  bool WellState() const { return opt.state; }
174  USI WellType() const { return opt.type; }
176  OCP_DBL GetPerfPre(const USI& p) const { return perf[p].P; }
178  void ShowPerfStatus(const Bulk& myBulk) const;
179 
180 
181 private:
182  string name;
183  string group;
184  USI wEId;
185  USI I;
186  USI J;
187  WellOpt opt;
188  vector<WellOpt> optSet;
190  OCP_DBL lBHP;
191  mutable OCP_DBL BHP;
192  OCP_DBL depth;
193  USI numPerf;
194  vector<Perforation> perf;
195  vector<OCP_DBL>
196  dG;
197  vector<OCP_DBL> ldG;
199 
200  // production rate and injection rate
201  vector<OCP_DBL> qi_lbmol;
203 
204  USI Mtype;
205  mutable vector<OCP_DBL> factor;
206  mutable vector<OCP_DBL> prodWeight;
207 
208  OCP_DBL WOPR{0};
209  OCP_DBL WOPT{0};
210  OCP_DBL WGPR{0};
211  OCP_DBL WGPT{0};
212  OCP_DBL WWPR{0};
213  OCP_DBL WWPT{0};
214  OCP_DBL WGIR{0};
215  OCP_DBL WGIT{0};
216  OCP_DBL WWIR{0};
217  OCP_DBL WWIT{0};
218 
220  // IMPEC
222 
223 public:
225  void CalCFL(const Bulk& myBulk, const OCP_DBL& dt) const;
227  void MassConserveIMPEC(Bulk& myBulk, const OCP_DBL& dt) const;
229  void AssembleMatINJ_IMPEC(const Bulk& myBulk, LinearSystem& myLS,
230  const OCP_DBL& dt) const;
232  void AssembleMatPROD_IMPEC(const Bulk& myBulk, LinearSystem& myLS,
233  const OCP_DBL& dt) const;
236  void AssembleMatReinjection_IMPEC(const Bulk& myBulk, LinearSystem& myLS,
237  const OCP_DBL& dt, const vector<Well>& allWell, const vector<USI>& injId) const;
238 
239 
241  // FIM
243 
244 public:
246  void AssembleMatINJ_FIM(const Bulk& myBulk, LinearSystem& myLS,
247  const OCP_DBL& dt) const;
249  void AssembleMatPROD_FIM(const Bulk& myBulk, LinearSystem& myLS,
250  const OCP_DBL& dt) const;
253  void AssembleMatReinjection_FIM(const Bulk& myBulk, LinearSystem& myLS,
254  const OCP_DBL& dt, const vector<Well>& allWell, const vector<USI>& injId) const;
256  void CalResFIM(ResFIM& resFIM, const Bulk& myBulk, const OCP_DBL& dt,
257  const OCP_USI& wId, const vector<Well>& allWell) const;
258  void ShowRes(const OCP_USI& wId, const vector<OCP_DBL>& res, const Bulk& myBulk) const;
259 
261  // FIM(new)
263 
265  void AssembleMatINJ_FIM_new(const Bulk& myBulk, LinearSystem& myLS,
266  const OCP_DBL& dt) const;
268  void AssembleMatPROD_FIM_new(const Bulk& myBulk, LinearSystem& myLS,
269  const OCP_DBL& dt) const;
270  void AssembleMatINJ_FIM_new_n(const Bulk& myBulk, LinearSystem& myLS,
271  const OCP_DBL& dt) const;
272  void AssembleMatPROD_FIM_new_n(const Bulk& myBulk, LinearSystem& myLS,
273  const OCP_DBL& dt) const;
274 
275 
277  // AIMt, AIMs
279 
280 public:
282  void AssembleMatINJ_AIMt(const Bulk& myBulk, LinearSystem& myLS,
283  const OCP_DBL& dt) const;
285  void AssembleMatPROD_AIMt(const Bulk& myBulk, LinearSystem& myLS,
286  const OCP_DBL& dt) const;
288  void CalResAIMt(ResFIM& resFIM, const Bulk& myBulk, const OCP_DBL& dt,
289  const OCP_USI& wId, const vector<Well>& allWell) const;
290 
292  void AssembleMatINJ_AIMs(const Bulk& myBulk, LinearSystem& myLS,
293  const OCP_DBL& dt) const;
295  void AssembleMatPROD_AIMs(const Bulk& myBulk, LinearSystem& myLS,
296  const OCP_DBL& dt) const;
297 };
298 
299 #endif /* end if __WELL_HEADER__ */
300 
301 /*----------------------------------------------------------------------------*/
302 /* Brief Change History of This File */
303 /*----------------------------------------------------------------------------*/
304 /* Author Date Actions */
305 /*----------------------------------------------------------------------------*/
306 /* Shizhe Li Oct/01/2021 Create file */
307 /* Chensong Zhang Oct/15/2021 Format file */
308 /*----------------------------------------------------------------------------*/
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:22
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:26
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:24
int OCP_INT
Long integer.
Definition: OCPConst.hpp:25
Some Structure in OpenCAEPoro.
ParamWell class declaration.
WellPerf class declaration.
Physical information of each active reservoir bulk.
Definition: Bulk.hpp:58
Collect more detailed information of each time step.
Definition: OCPOutput.hpp:165
Basic information of computational grid, including the rock properties.
Definition: Grid.hpp:76
Linear solvers for discrete systems.
Describe the molar fraction of components of fluid injected to reservoir from INJ.
Definition: Well.hpp:32
string name
name of solvens
Definition: Well.hpp:40
vector< OCP_DBL > data
molar fraction of components
Definition: Well.hpp:42
Describe the molar fraction of components of fluid injected to reservoir from INJ.
Definition: ParamWell.hpp:88
Definition: Well.hpp:49
WellOpt()=default
Default constructor.
TODO: Add Doxygen.
Definition: ParamWell.hpp:61
Definition: Well.hpp:105
void UpdatePerfP()
Update pressure in Perforation after well pressure updates.
Definition: Well.hpp:163
OCP_DBL GetPerfPre(const USI &p) const
Return Pressure of Perf p.
Definition: Well.hpp:176
bool WellState() const
Return the state of the well, Open or Close.
Definition: Well.hpp:172
USI WellType() const
Return the type of well, Inj or Prod.
Definition: Well.hpp:174