OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
Public Member Functions | Protected Attributes | Friends | List of all members
Well Class Reference

#include <Well.hpp>

Public Member Functions

void InputPerfo (const WellParam &well)
 Input the param of perforations.
 
void Setup (const Grid &gd, const Bulk &bk, const vector< SolventINJ > &sols)
 Setup the well after Grid and Bulk finish setup.
 
void InitBHP (const Bulk &myBulk)
 Initialize the Well BHP.
 
void CalWI_Peaceman (const Bulk &myBulk)
 Calculate Well Index with Peaceman model.
 
void CalTrans (const Bulk &myBulk)
 Calculate transmissibility for each phase in perforations.
 
void CalFlux (const Bulk &myBulk, const OCP_BOOL ReCalXi=OCP_FALSE)
 Calculate the flux for each perforations.
 
OCP_DBL CalInjRateMaxBHP (const Bulk &myBulk)
 calculate flow rate of moles of phases for injection well with maxBHP. More...
 
OCP_DBL CalProdRateMinBHP (const Bulk &myBulk)
 calculate flow rate of moles of phases for production well with minBHP. More...
 
void CalInjQj (const Bulk &myBulk, const OCP_DBL &dt)
 
void CalProdQj (const Bulk &myBulk, const OCP_DBL &dt)
 
void CaldG (const Bulk &myBulk)
 Calculate pressure difference between well and perforations. More...
 
void CalInjdG (const Bulk &myBulk)
 Calculate pressure difference between well and perforations for Injection.
 
void CalProddG (const Bulk &myBulk)
 Calculate pressure difference between well and perforations for Production.
 
void CalProddG01 (const Bulk &myBulk)
 Calculate pressure difference between well and perforations for Production.
 
void CalProddG02 (const Bulk &myBulk)
 Calculate pressure difference between well and perforations for Production.
 
void CalProdWeight (const Bulk &myBulk) const
 Calculate the production weight.
 
void CalReInjFluid (const Bulk &myBulk, vector< OCP_DBL > &myZi)
 Calculate the contribution of production well to reinjection defaulted.
 
void CorrectBHP ()
 Correct BHP if opt mode is BHPMode.
 
void CheckOptMode (const Bulk &myBulk)
 Check if well operation mode would be changed. More...
 
OCP_INT CheckP (const Bulk &myBulk)
 Check if abnormal Pressure occurs.
 
OCP_INT CheckCrossFlow (const Bulk &myBulk)
 Check if cross flow happens.
 
void CalPerfP ()
 Update pressure in Perforation after well pressure updates.
 
void ShowPerfStatus (const Bulk &myBulk) const
 Display operation mode of well and state of perforations.
 
USI PerfNum () const
 
void SetBHP (const OCP_DBL &p)
 
OCP_DBL BHP () const
 
OCP_DBL DG (const USI &p) const
 
OCP_DBL ProdWeight (const USI &i) const
 
USI OptMode () const
 
OCP_BOOL IsOpen () const
 Return the state of the well, Open or Close.
 
USI WellType () const
 Return the type of well, Inj or Prod.
 
vector< OCP_DBLInjZi () const
 
OCP_DBL InjZi (const USI &i) const
 
OCP_DBL MaxRate () const
 
OCP_DBL MaxBHP () const
 
OCP_DBL MinBHP () const
 
OCP_DBL InjTemp () const
 
OCP_BOOL PerfState (const USI &p) const
 
USI PerfLocation (const USI &p) const
 
OCP_DBL PerfWI (const USI &p) const
 
OCP_DBL PerfMultiplier (const USI &p) const
 
OCP_DBL PerfTransInj (const USI &p) const
 
OCP_DBL PerfXi (const USI &p) const
 
OCP_DBL PerfTransj (const USI &p, const USI &j) const
 
OCP_DBL PerfQi_lbmol (const USI &p, const USI &i) const
 
OCP_DBL PerfProdQj_ft3 (const USI &p, const USI &j) const
 
OCP_DBL PerfInjQt_ft3 (const USI &p) const
 
OCP_DBL Qi_lbmol (const USI &i) const
 
OCP_BOOL IfUseUnweight () const
 
void AssembleMatReinjection_IMPEC (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt, const vector< Well > &allWell, const vector< USI > &injId) const
 
void AssembleMatReinjection_FIM (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt, const vector< Well > &allWell, const vector< USI > &injId) const
 
void SetPolyhedronWell (const Grid &myGrid, OCPpolyhedron &mypol)
 

Protected Attributes

string name
 well name
 
string group
 group well belongs to, it should be moved to opt if necessary!!!
 
USI I
 I-index of the well header.
 
USI J
 J-index of the well header.
 
OCP_DBL depth
 reference depth of well.
 
WellOpt opt
 well control parameters, contains current control parameters.
 
vector< WellOptoptSet
 
USI numPerf
 num of perforations belonging to this well.
 
vector< Perforationperf
 information of perforation belonging to this well.
 
vector< Mixture * > flashCal
 from bulks's flashCal
 
OCP_DBL numPhase
 num of phases
 
OCP_DBL numCom
 num of components
 
OCP_DBL Psurf {PRESSURE_STD}
 Well surface Pressure, psia.
 
OCP_DBL Tsurf {TEMPERATURE_STD}
 Well surface Temperature, F.
 
USI wOId
 
OCP_DBL bhp
 Well pressure in reference depth.
 
vector< OCP_DBLdG
 difference of pressure between well and perforation: numPerf.
 
OCP_DBL lbhp
 Last BHP.
 
vector< OCP_DBLldG
 Last dG.
 
vector< OCP_DBLqi_lbmol
 flow rate of moles of component inflowing/outflowing
 
vector< OCP_DBLprodRate
 flow rate of volume of phase outflowing
 
vector< OCP_DBLprodWeight
 maybe only a num is needed
 
OCP_DBL WOPR {0}
 well oil production rate.
 
OCP_DBL WOPT {0}
 well total oil production.
 
OCP_DBL WGPR {0}
 well gas production rate.
 
OCP_DBL WGPT {0}
 well total gas production.
 
OCP_DBL WWPR {0}
 well water production rate.
 
OCP_DBL WWPT {0}
 well total water production.
 
OCP_DBL WGIR {0}
 well gas injection rate.
 
OCP_DBL WGIT {0}
 well total gas injection.
 
OCP_DBL WWIR {0}
 well water injection rate.
 
OCP_DBL WWIT {0}
 well total water injection.
 
OCP_BOOL ifUseUnweight {OCP_FALSE}
 

Friends

class AllWells
 
class Out4RPT
 
class MyMetisTest
 

Detailed Description

Well class defines well, and any operations referred to wells are in it. Well connects to the bulks by perforations, which serve as source and sink. Due to practical difficulties in production, a good treatment for well is important, excellent treatment will make the flow rate in well more stable.

Definition at line 44 of file Well.hpp.

Member Function Documentation

◆ AssembleMatReinjection_FIM()

void Well::AssembleMatReinjection_FIM ( const Bulk myBulk,
LinearSystem myLS,
const OCP_DBL dt,
const vector< Well > &  allWell,
const vector< USI > &  injId 
) const

Assemble matrix for Reinjection Well, used in production well when injection well is under RATE control

Definition at line 1145 of file Well.cpp.

1150 {
1151  // find Open injection well under Rate control
1152  vector<OCP_USI> tarId;
1153  for (auto& w : injId) {
1154  if (allWell[w].IsOpen() && allWell[w].opt.optMode != BHP_MODE)
1155  tarId.push_back(allWell[w].wOId + myBulk.numBulk);
1156  }
1157 
1158  USI tlen = tarId.size();
1159  if (tlen > 0) {
1160  // All inj well has the same factor
1161  const OCP_DBL factor = allWell[injId[0]].opt.reInjFactor;
1162  const OCP_USI prodId = wOId + myBulk.numBulk;
1163 
1164  const USI ncol = numCom + 1;
1165  const USI ncol2 = numPhase * numCom + numPhase;
1166  const USI bsize = ncol * ncol;
1167  const USI bsize2 = ncol * ncol2;
1168 
1169  OCP_DBL xij, xi, mu, muP, xiP, dP, transIJ, tmp;
1170  OCP_USI n_np_j;
1171 
1172  vector<OCP_DBL> bmat(bsize, 0);
1173  vector<OCP_DBL> bmat2(bsize, 0);
1174  vector<OCP_DBL> tmpMat(bsize, 0);
1175  vector<OCP_DBL> dQdXpB(bsize, 0);
1176  vector<OCP_DBL> dQdXpW(bsize, 0);
1177  vector<OCP_DBL> dQdXsB(bsize2, 0);
1178 
1179  for (USI p = 0; p < numPerf; p++) {
1180  const OCP_USI n = perf[p].location;
1181  fill(dQdXpB.begin(), dQdXpB.end(), 0.0);
1182  fill(dQdXpW.begin(), dQdXpW.end(), 0.0);
1183  fill(dQdXsB.begin(), dQdXsB.end(), 0.0);
1184 
1185  for (USI j = 0; j < numPhase; j++) {
1186  n_np_j = n * numPhase + j;
1187  if (!myBulk.phaseExist[n_np_j]) continue;
1188 
1189  dP = myBulk.Pj[n_np_j] - bhp - dG[p];
1190  xi = myBulk.xi[n_np_j];
1191  mu = myBulk.mu[n_np_j];
1192  muP = myBulk.muP[n_np_j];
1193  xiP = myBulk.xiP[n_np_j];
1194 
1195  for (USI i = 0; i < numCom; i++) {
1196  xij = myBulk.xij[n_np_j * numCom + i];
1197  // dQ / dP
1198  transIJ = perf[p].transj[j] * xi * xij;
1199  dQdXpB[(i + 1) * ncol] += transIJ * (1 - dP * muP / mu) +
1200  dP * perf[p].transj[j] * xij * xiP;
1201  dQdXpW[(i + 1) * ncol] += -transIJ;
1202 
1203  // dQ / dS
1204  for (USI k = 0; k < numPhase; k++) {
1205  tmp = CONV1 * perf[p].WI * perf[p].multiplier * dP / mu * xi *
1206  xij * myBulk.dKr_dS[n_np_j * numPhase + k];
1207  // capillary pressure
1208  tmp += transIJ * myBulk.dPcj_dS[n_np_j * numPhase + k];
1209  dQdXsB[(i + 1) * ncol2 + k] += tmp;
1210  }
1211  // dQ / dCij
1212  for (USI k = 0; k < numCom; k++) {
1213  tmp = dP * perf[p].transj[j] * xij *
1214  (myBulk.xix[n_np_j * numCom + k] -
1215  xi / mu * myBulk.mux[n_np_j * numCom + k]);
1216  if (k == i) {
1217  tmp += perf[p].transj[j] * xi * dP;
1218  }
1219  dQdXsB[(i + 1) * ncol2 + numPhase + j * numCom + k] += tmp;
1220  }
1221  }
1222  }
1223 
1224  // for Prod Well
1225  for (USI i = 0; i < numCom; i++) {
1226  tmpMat[0] += dQdXpW[(i + 1) * ncol] * factor;
1227  }
1228 
1229  // for Perf(bulk) of Prod Well
1230  bmat = dQdXpB;
1231  DaABpbC(ncol, ncol, ncol2, 1, dQdXsB.data(), &myBulk.dSec_dPri[n * bsize2],
1232  1, bmat.data());
1233  fill(bmat2.begin(), bmat2.end(), 0.0);
1234  for (USI i = 0; i < numCom; i++) {
1235  // becareful '-' before factor
1236  Daxpy(ncol, -factor, bmat.data() + (i + 1) * ncol, bmat2.data());
1237  }
1238 
1239  // Insert bulk val into equations in ascending order
1240  for (USI t = 0; t < tlen; t++) {
1241  myLS.NewOffDiag(tarId[t], n, bmat2);
1242  }
1243  }
1244  // prod well
1245  for (USI t = 0; t < tlen; t++) {
1246  myLS.NewOffDiag(tarId[t], prodId, tmpMat);
1247  }
1248  }
1249 }
void DaABpbC(const int &m, const int &n, const int &k, const double &alpha, const double *A, const double *B, const double &beta, double *C)
Computes C' = alpha B'A' + beta C', all matrices are column-major.
Definition: DenseMat.cpp:75
void Daxpy(const int &n, const double &alpha, const double *x, double *y)
Constant times a vector plus a vector.
Definition: DenseMat.cpp:68
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:27
const OCP_DBL CONV1
1 bbl = CONV1 ft3
Definition: OCPConst.hpp:63
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:25
const USI BHP_MODE
Well option = fixed bottom-hole-pressure.
Definition: OCPConst.hpp:135
vector< OCP_DBL > mu
Viscosity of phase: numPhase*numBulk.
Definition: Bulk.hpp:320
vector< OCP_DBL > dSec_dPri
d Secondary variable / d Primary variable.
Definition: Bulk.hpp:486
vector< OCP_DBL > xij
Nij / Nj: numPhase*numCom*numBulk.
Definition: Bulk.hpp:317
vector< OCP_DBL > Pj
Pressure of phase: numPhase*numBulk.
Definition: Bulk.hpp:311
vector< OCP_DBL > mux
d Muj / d xij: numPhase*numCom*numBulk.
Definition: Bulk.hpp:360
vector< OCP_DBL > muP
d Mu / d P: numPhase*numBulk.
Definition: Bulk.hpp:358
vector< OCP_DBL > dKr_dS
d Krj / d Sk: numPhase * numPhase * bulk.
Definition: Bulk.hpp:362
vector< OCP_BOOL > phaseExist
Existence of phase: numPhase*numBulk.
Definition: Bulk.hpp:313
vector< OCP_DBL > xiP
d xi / d P: numPhase*numBulk.
Definition: Bulk.hpp:355
vector< OCP_DBL > xi
Moles density of phase: numPhase*numBulk.
Definition: Bulk.hpp:319
OCP_USI numBulk
Number of bulks (active grids).
Definition: Bulk.hpp:153
vector< OCP_DBL > xix
d Xi_j / d xij: numPhase*numCom*numBulk.
Definition: Bulk.hpp:357
vector< OCP_DBL > dPcj_dS
d Pcj / d Sk: numPhase * numPhase * bulk.
Definition: Bulk.hpp:361
void NewOffDiag(const OCP_USI &bId, const OCP_USI &eId, const OCP_DBL &v)
Push back a off-diagonal value.
USI numPerf
num of perforations belonging to this well.
Definition: Well.hpp:78
OCP_DBL numPhase
num of phases
Definition: Well.hpp:83
USI wOId
Definition: Well.hpp:89
WellOpt opt
well control parameters, contains current control parameters.
Definition: Well.hpp:75
OCP_DBL numCom
num of components
Definition: Well.hpp:84
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 > 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

References bhp, BHP_MODE, CONV1, DaABpbC(), Daxpy(), dG, Bulk::dKr_dS, Bulk::dPcj_dS, Bulk::dSec_dPri, IsOpen(), Bulk::mu, Bulk::muP, Bulk::mux, LinearSystem::NewOffDiag(), Bulk::numBulk, numCom, numPerf, numPhase, opt, perf, Bulk::phaseExist, Bulk::Pj, wOId, Bulk::xi, Bulk::xij, Bulk::xiP, and Bulk::xix.

◆ AssembleMatReinjection_IMPEC()

void Well::AssembleMatReinjection_IMPEC ( const Bulk myBulk,
LinearSystem myLS,
const OCP_DBL dt,
const vector< Well > &  allWell,
const vector< USI > &  injId 
) const

Assemble matrix for Reinjection Well, used in production well when injection well is under RATE control

Definition at line 1096 of file Well.cpp.

1101 {
1102  // find Open injection well under Rate control
1103  vector<OCP_USI> tarId;
1104  for (auto& w : injId) {
1105  if (allWell[w].IsOpen() && allWell[w].opt.optMode != BHP_MODE)
1106  tarId.push_back(allWell[w].wOId + myBulk.numBulk);
1107  }
1108 
1109  USI tlen = tarId.size();
1110  if (tlen > 0) {
1111  // All inj well has the same factor
1112  const OCP_DBL factor = allWell[injId[0]].opt.reInjFactor * dt;
1113  const OCP_USI prodId = wOId + myBulk.numBulk;
1114  OCP_USI n, bId;
1115  OCP_DBL tmp, valb;
1116  OCP_DBL valw = 0;
1117  OCP_DBL rhsw = 0;
1118  for (USI p = 0; p < numPerf; p++) {
1119  n = perf[p].location;
1120  valb = 0;
1121 
1122  for (USI j = 0; j < numPhase; j++) {
1123  bId = n * numPhase + j;
1124  if (myBulk.phaseExist[bId]) {
1125  tmp = perf[p].transj[j] * myBulk.xi[bId];
1126  valb += tmp;
1127  rhsw += tmp * (myBulk.Pc[bId] - dG[p]);
1128  }
1129  }
1130  valb *= factor;
1131  for (USI t = 0; t < tlen; t++) {
1132  myLS.NewOffDiag(tarId[t], n, -valb);
1133  }
1134  valw += valb;
1135  }
1136  rhsw *= factor;
1137  // rhs and prod well
1138  for (USI t = 0; t < tlen; t++) {
1139  myLS.AddRhs(tarId[t], rhsw);
1140  myLS.NewOffDiag(tarId[t], prodId, valw);
1141  }
1142  }
1143 }
vector< OCP_DBL > Pc
Capillary pressure of phase: numPhase*numBulk.
Definition: Bulk.hpp:312
void AddRhs(const OCP_USI &n, const OCP_DBL &v)
Add a value at b[n].

References LinearSystem::AddRhs(), BHP_MODE, dG, IsOpen(), LinearSystem::NewOffDiag(), Bulk::numBulk, numPerf, numPhase, opt, Bulk::Pc, perf, Bulk::phaseExist, wOId, and Bulk::xi.

◆ CaldG()

void Well::CaldG ( const Bulk myBulk)

Calculate pressure difference between well and perforations.

It calculates pressure difference between perforations iteratively. This function can be used in both black oil model and compositional model. stability of this method shoule be tested.

Definition at line 357 of file Well.cpp.

358 {
359  OCP_FUNCNAME;
360 
361  if (opt.type == INJ)
362  CalInjdG(myBulk);
363  else
364  CalProddG01(myBulk);
365 }
const USI INJ
Well type = injector.
Definition: OCPConst.hpp:122
#define OCP_FUNCNAME
Print Function Name.
Definition: UtilError.hpp:73
void CalProddG01(const Bulk &myBulk)
Calculate pressure difference between well and perforations for Production.
Definition: Well.cpp:438
void CalInjdG(const Bulk &myBulk)
Calculate pressure difference between well and perforations for Injection.
Definition: Well.cpp:367

References CalInjdG(), CalProddG01(), INJ, OCP_FUNCNAME, and opt.

◆ CalInjQj()

void Well::CalInjQj ( const Bulk myBulk,
const OCP_DBL dt 
)

Calculate flow rate of moles of phases for injection well with calculated qi_lbmol.

Definition at line 322 of file Well.cpp.

323 {
324  OCP_FUNCNAME;
325 
326  OCP_DBL qj = 0;
327 
328  for (USI i = 0; i < numCom; i++) {
329  qj += qi_lbmol[i];
330  }
331  if (opt.fluidType == "WAT") {
332  WWIR = -qj / opt.factorINJ;
333  WWIT += WWIR * dt;
334  } else {
335  WGIR = -qj / opt.factorINJ; // Mscf or lbmol -> Mscf
336  WGIT += WGIR * dt;
337  }
338 }
OCP_DBL WWIT
well total water injection.
Definition: Well.hpp:230
OCP_DBL WGIR
well gas injection rate.
Definition: Well.hpp:227
OCP_DBL WWIR
well water injection rate.
Definition: Well.hpp:229
OCP_DBL WGIT
well total gas injection.
Definition: Well.hpp:228
vector< OCP_DBL > qi_lbmol
flow rate of moles of component inflowing/outflowing
Definition: Well.hpp:217

References numCom, OCP_FUNCNAME, opt, qi_lbmol, WGIR, WGIT, WWIR, and WWIT.

◆ CalInjRateMaxBHP()

OCP_DBL Well::CalInjRateMaxBHP ( const Bulk myBulk)

calculate flow rate of moles of phases for injection well with maxBHP.

Pressure in injection well equals maximum ones in injection well, which is input by users. this function is used to check if operation mode of well shoubld be swtched.

Definition at line 263 of file Well.cpp.

264 {
265  OCP_FUNCNAME;
266 
267  OCP_DBL qj = 0;
268  OCP_DBL Pwell = opt.maxBHP;
269 
270  for (USI p = 0; p < numPerf; p++) {
271 
272  OCP_DBL Pperf = Pwell + dG[p];
273  OCP_USI k = perf[p].location;
274 
275  USI pvtnum = myBulk.PVTNUM[k];
276  OCP_DBL xi = myBulk.flashCal[pvtnum]->XiPhase(Pperf, opt.injTemp, &opt.injZi[0],
277  opt.injProdPhase);
278 
279  OCP_DBL dP = Pperf - myBulk.P[k];
280  qj += perf[p].transINJ * xi * dP;
281  }
282  return qj;
283 }
vector< USI > PVTNUM
Identify PVT region in black-oil model: numBulk.
Definition: Bulk.hpp:191
vector< Mixture * > flashCal
Flash calculation class.
Definition: Bulk.hpp:192
vector< OCP_DBL > P
Pressure: numBulk.
Definition: Bulk.hpp:309

References dG, Bulk::flashCal, numPerf, OCP_FUNCNAME, opt, Bulk::P, perf, and Bulk::PVTNUM.

◆ CalProdQj()

void Well::CalProdQj ( const Bulk myBulk,
const OCP_DBL dt 
)

Calculate flow rate of moles of phases for production well with calculated qi_lbmol.

Definition at line 340 of file Well.cpp.

341 {
342 
343  flashCal[0]->CalProdRate(Psurf, Tsurf, &qi_lbmol[0], prodRate);
344  USI iter = 0;
345  if (myBulk.oil) WOPR = prodRate[iter++];
346  if (myBulk.gas) WGPR = prodRate[iter++];
347  if (myBulk.water) WWPR = prodRate[iter++];
348 
349  WOPT += WOPR * dt;
350  WGPT += WGPR * dt;
351  WWPT += WWPR * dt;
352 }
OCP_BOOL oil
If OCP_TRUE, oil phase could exist.
Definition: Bulk.hpp:222
OCP_BOOL gas
If OCP_TRUE, gas phase could exist.
Definition: Bulk.hpp:223
OCP_BOOL water
If OCP_TRUE, water phase could exist.
Definition: Bulk.hpp:224
OCP_DBL WOPT
well total oil production.
Definition: Well.hpp:222
vector< OCP_DBL > prodRate
flow rate of volume of phase outflowing
Definition: Well.hpp:218
OCP_DBL WGPR
well gas production rate.
Definition: Well.hpp:223
OCP_DBL WWPT
well total water production.
Definition: Well.hpp:226
OCP_DBL Tsurf
Well surface Temperature, F.
Definition: Well.hpp:87
OCP_DBL WOPR
well oil production rate.
Definition: Well.hpp:221
OCP_DBL WGPT
well total gas production.
Definition: Well.hpp:224
vector< Mixture * > flashCal
from bulks's flashCal
Definition: Well.hpp:81
OCP_DBL Psurf
Well surface Pressure, psia.
Definition: Well.hpp:86
OCP_DBL WWPR
well water production rate.
Definition: Well.hpp:225

References flashCal, Bulk::gas, Bulk::oil, prodRate, Psurf, qi_lbmol, Tsurf, Bulk::water, WGPR, WGPT, WOPR, WOPT, WWPR, and WWPT.

◆ CalProdRateMinBHP()

OCP_DBL Well::CalProdRateMinBHP ( const Bulk myBulk)

calculate flow rate of moles of phases for production well with minBHP.

Pressure in production well equals minial ones in production well, which is input by users. this function is used to check if operation mode of well shoubld be swtched.

Definition at line 288 of file Well.cpp.

289 {
290  OCP_FUNCNAME;
291 
292  OCP_DBL qj = 0;
293  OCP_DBL Pwell = opt.minBHP;
294 
295  vector<OCP_DBL> tmpQi_lbmol(numCom, 0);
296  vector<OCP_DBL> tmpQj(numPhase, 0);
297 
298  for (USI p = 0; p < numPerf; p++) {
299 
300  OCP_DBL Pperf = Pwell + dG[p];
301  OCP_USI k = perf[p].location;
302 
303  for (USI j = 0; j < numPhase; j++) {
304  OCP_USI id = k * numPhase + j;
305  if (myBulk.phaseExist[id]) {
306  OCP_DBL dP = myBulk.Pj[id] - Pperf;
307  OCP_DBL temp = perf[p].transj[j] * myBulk.xi[id] * dP;
308  for (USI i = 0; i < numCom; i++) {
309  tmpQi_lbmol[i] += myBulk.xij[id * numCom + i] * temp;
310  }
311  }
312  }
313  }
314  flashCal[0]->CalProdRate(Psurf, Tsurf, &tmpQi_lbmol[0], tmpQj);
315  for (USI j = 0; j < numPhase; j++) {
316  qj += tmpQj[j] * opt.prodPhaseWeight[j];
317  }
318 
319  return qj;
320 }

References dG, flashCal, numCom, numPerf, numPhase, OCP_FUNCNAME, opt, perf, Bulk::phaseExist, Bulk::Pj, Psurf, Tsurf, Bulk::xi, and Bulk::xij.

◆ CheckOptMode()

void Well::CheckOptMode ( const Bulk myBulk)

Check if well operation mode would be changed.

Constant well pressure would be applied if flow rate is too large. Constant flow rate would be applied if well pressure is outranged.

Definition at line 893 of file Well.cpp.

894 {
895  OCP_FUNCNAME;
896  if (opt.initOptMode == BHP_MODE) {
897  if (opt.type == INJ) {
898  OCP_DBL q = CalInjRateMaxBHP(myBulk);
899  // for INJ well, maxRate has been switch to lbmols
900  OCP_DBL tarRate = opt.maxRate;
901  if (opt.reInj) {
902  if (opt.reInjPhase == GAS)
903  tarRate = WGIR;
904  else if (opt.reInjPhase == WATER)
905  tarRate = WWIR;
906  }
907  if (q > tarRate) {
908  opt.optMode = RATE_MODE;
909  } else {
910  opt.optMode = BHP_MODE;
911  bhp = opt.maxBHP;
912  }
913  } else {
914  opt.optMode = BHP_MODE;
915  bhp = opt.minBHP;
916  }
917  } else {
918  if (opt.type == INJ) {
919  OCP_DBL q = CalInjRateMaxBHP(myBulk);
920  // for INJ well, maxRate has been switch to lbmols
921  OCP_DBL tarRate = opt.maxRate;
922  if (opt.reInj) {
923  if (opt.reInjPhase == GAS)
924  tarRate = WGIR;
925  else if (opt.reInjPhase == WATER)
926  tarRate = WWIR;
927  }
928 
929  if (q > tarRate) {
930  opt.optMode = opt.initOptMode;
931  } else {
932  opt.optMode = BHP_MODE;
933  bhp = opt.maxBHP;
934  }
935  } else {
936  OCP_DBL q = CalProdRateMinBHP(myBulk);
937  // cout << q << endl;
938  if (q > opt.maxRate) {
939  opt.optMode = opt.initOptMode;
940  } else {
941  opt.optMode = BHP_MODE;
942  bhp = opt.minBHP;
943  }
944  }
945  }
946 }
const USI GAS
Fluid type = gas.
Definition: OCPConst.hpp:92
const USI WATER
Fluid type = water.
Definition: OCPConst.hpp:93
const USI RATE_MODE
Well option = fixed total rate???
Definition: OCPConst.hpp:130
OCP_DBL CalInjRateMaxBHP(const Bulk &myBulk)
calculate flow rate of moles of phases for injection well with maxBHP.
Definition: Well.cpp:263
OCP_DBL CalProdRateMinBHP(const Bulk &myBulk)
calculate flow rate of moles of phases for production well with minBHP.
Definition: Well.cpp:288

References bhp, BHP_MODE, CalInjRateMaxBHP(), CalProdRateMinBHP(), GAS, INJ, OCP_FUNCNAME, opt, RATE_MODE, WATER, WGIR, and WWIR.

Member Data Documentation

◆ optSet

vector<WellOpt> Well::optSet
protected

well control parameters set, contains control parameters in all critical time.

Definition at line 76 of file Well.hpp.

◆ wOId

USI Well::wOId
protected

well index in allWells, closed well is excluded, it's the well index in equations

Definition at line 89 of file Well.hpp.


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