OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
Public Member Functions | 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 &myGrid, const Bulk &myBulk, const vector< SolventINJ > &sols)
 Setup the well after Grid and Bulk finish setupping.
 
void InitBHP (const Bulk &myBulk)
 Initialize the Well BHP.
 
void CalWI_Peaceman_Vertical (const Bulk &myBulk)
 Calculate Well Index with Peaceman model for vertical well.
 
void CalTrans (const Bulk &myBulk)
 Calculate transmissibility for each phase in perforations.
 
void CalFlux (const Bulk &myBulk, const bool flag=false)
 Calculate the flux for each perforations.
 
OCP_DBL CalInjRate (const Bulk &myBulk, const bool &maxBHP)
 calculate flow rate of moles of components for injection well with maxBHP More...
 
OCP_DBL CalProdRate (const Bulk &myBulk, const bool &minBHP)
 calculate flow rate of moles of components for production well with minBHP More...
 
void CalInjQi (const Bulk &myBulk, const OCP_DBL &dt)
 Calculate flow rate of moles of components for injection well.
 
void CalProdQj (const Bulk &myBulk, const OCP_DBL &dt)
 Calculate flow rate of moles of phase for production well.
 
void CalProdQjCOMP (const Bulk &myBulk)
 Calculate flow rate of moles of phase for production well in Compositional Model.
 
void CalProdQiBO (const Bulk &myBulk)
 
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 Prodcution.
 
void CalProdWeight (const Bulk &myBulk) const
 Calculate the Prodweight.
 
void CalReInjFluid (const Bulk &myBulk, vector< OCP_DBL > &myZi)
 Calculate the contribution of production well to reinjection defaulted.
 
void SetBHP ()
 Set BHP if opt mode is BHPMode.
 
void SmoothdG ()
 Try to smooth the dG by average it with dG at last time step. More...
 
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 crossflow happens.
 
void UpdatePerfP ()
 Update pressure in Perforation after well pressure updates.
 
void AllocateMat (LinearSystem &myLS) const
 Allocate memory for matrix.
 
void SetupWellBulk (Bulk &myBulk) const
 Setup bulks which are penetrated by wells.
 
bool WellState () const
 Return the state of the well, Open or Close.
 
USI WellType () const
 Return the type of well, Inj or Prod.
 
OCP_DBL GetPerfPre (const USI &p) const
 Return Pressure of Perf p.
 
void ShowPerfStatus (const Bulk &myBulk) const
 Display operation mode of well and state of perforations.
 
void CalCFL (const Bulk &myBulk, const OCP_DBL &dt) const
 Calculate the CFL number, only parts related to wells are considered.
 
void MassConserveIMPEC (Bulk &myBulk, const OCP_DBL &dt) const
 Update moles of components in those bulks who connects to the well.
 
void AssembleMatINJ_IMPEC (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for IMPEC, parts related to injection well are included.
 
void AssembleMatPROD_IMPEC (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for IMPEC, parts related to production well are included.
 
void AssembleMatReinjection_IMPEC (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt, const vector< Well > &allWell, const vector< USI > &injId) const
 
void AssembleMatINJ_FIM (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for FIM, parts related to Injection well are included.
 
void AssembleMatPROD_FIM (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for FIM, parts related to Production well are included.
 
void AssembleMatReinjection_FIM (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt, const vector< Well > &allWell, const vector< USI > &injId) const
 
void CalResFIM (ResFIM &resFIM, const Bulk &myBulk, const OCP_DBL &dt, const OCP_USI &wId, const vector< Well > &allWell) const
 Calculate Resiual and relative Resiual for FIM.
 
void ShowRes (const OCP_USI &wId, const vector< OCP_DBL > &res, const Bulk &myBulk) const
 
void AssembleMatINJ_FIM_new (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for FIM, parts related to Injection well are included.
 
void AssembleMatPROD_FIM_new (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for FIM, parts related to Production well are included.
 
void AssembleMatINJ_FIM_new_n (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 
void AssembleMatPROD_FIM_new_n (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 
void AssembleMatINJ_AIMt (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for AIMt, parts related to Injection well are included.
 
void AssembleMatPROD_AIMt (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for AIMt, parts related to Production well are included.
 
void CalResAIMt (ResFIM &resFIM, const Bulk &myBulk, const OCP_DBL &dt, const OCP_USI &wId, const vector< Well > &allWell) const
 Calculate Resiual and relative Resiual for local FIM.
 
void AssembleMatINJ_AIMs (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for AIMs, parts related to Injection well are included.
 
void AssembleMatPROD_AIMs (const Bulk &myBulk, LinearSystem &myLS, const OCP_DBL &dt) const
 Assemble matrix for AIMs, parts related to Production well are included.
 

Friends

class AllWells
 
class DetailInfo
 

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 104 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 1842 of file Well.cpp.

1845 {
1846  // find Open injection well under Rate control
1847  vector<OCP_USI> tarId;
1848  for (USI w = 0; w < injId.size(); w++) {
1849  if (allWell[w].WellState() && allWell[w].opt.optMode != BHP_MODE)
1850  tarId.push_back(allWell[w].wEId + myBulk.numBulk);
1851  }
1852 
1853  USI tlen = tarId.size();
1854  if (tlen > 0) {
1855  OCP_USI tar;
1856  USI tarsize;
1857  const OCP_DBL factor = allWell[injId[0]].opt.factor;
1858  const OCP_USI prodId = wEId + myBulk.numBulk;
1859 
1860  // cout << "Factor(assemble): " << factor << endl;
1861 
1862  const USI np = myBulk.numPhase;
1863  const USI nc = myBulk.numCom;
1864  const USI ncol = nc + 1;
1865  const USI ncol2 = np * nc + np;
1866  const USI bsize = ncol * ncol;
1867  const USI bsize2 = ncol * ncol2;
1868 
1869  OCP_DBL xij, xi, mu, muP, xiP, dP, transIJ, tmp;
1870  OCP_USI n_np_j;
1871 
1872  vector<OCP_DBL> bmat(bsize, 0);
1873  vector<OCP_DBL> bmat2(bsize, 0);
1874  vector<OCP_DBL> tmpMat(bsize, 0);
1875  vector<OCP_DBL> dQdXpB(bsize, 0);
1876  vector<OCP_DBL> dQdXpW(bsize, 0);
1877  vector<OCP_DBL> dQdXsB(bsize2, 0);
1878 
1879  for (USI p = 0; p < numPerf; p++) {
1880  OCP_USI n = perf[p].location;
1881  fill(dQdXpB.begin(), dQdXpB.end(), 0.0);
1882  fill(dQdXpW.begin(), dQdXpW.end(), 0.0);
1883  fill(dQdXsB.begin(), dQdXsB.end(), 0.0);
1884 
1885  for (USI j = 0; j < np; j++) {
1886  n_np_j = n * np + j;
1887  if (!myBulk.phaseExist[n_np_j]) continue;
1888 
1889  dP = myBulk.Pj[n_np_j] - BHP - dG[p];
1890  xi = myBulk.xi[n_np_j];
1891  mu = myBulk.mu[n_np_j];
1892  muP = myBulk.muP[n_np_j];
1893  xiP = myBulk.xiP[n_np_j];
1894 
1895  for (USI i = 0; i < nc; i++) {
1896  xij = myBulk.xij[n_np_j * nc + i];
1897  // dQ / dP
1898  transIJ = perf[p].transj[j] * xi * xij;
1899  dQdXpB[(i + 1) * ncol] += transIJ * (1 - dP * muP / mu) +
1900  dP * perf[p].transj[j] * xij * xiP;
1901  dQdXpW[(i + 1) * ncol] += -transIJ;
1902 
1903  // dQ / dS
1904  for (USI k = 0; k < np; k++) {
1905  tmp = CONV1 * perf[p].WI * perf[p].multiplier * dP / mu * xi *
1906  xij * myBulk.dKr_dS[n * np * np + j * np + k];
1907  // capillary pressure
1908  tmp += transIJ * myBulk.dPcj_dS[n * np * np + j * np + k];
1909  dQdXsB[(i + 1) * ncol2 + k] += tmp;
1910  }
1911  // dQ / dCij
1912  for (USI k = 0; k < nc; k++) {
1913  tmp = dP * perf[p].transj[j] * xij *
1914  (myBulk.xix[n_np_j * nc + k] -
1915  xi / mu * myBulk.mux[n_np_j * nc + k]);
1916  if (k == i) {
1917  tmp += perf[p].transj[j] * xi * dP;
1918  }
1919  dQdXsB[(i + 1) * ncol2 + np + j * nc + k] += tmp;
1920  }
1921  }
1922  }
1923 
1924  // for Prod Well, be careful!
1925  for (USI i = 0; i < nc; i++) {
1926  // tmpMat[0] -= dQdXpW[(i + 1) * ncol] * factor;
1927  tmpMat[0] += dQdXpW[(i + 1) * ncol] * factor;
1928  }
1929 
1930  // for perf(bulk) of Prod Well
1931  bmat = dQdXpB;
1932  DaABpbC(ncol, ncol, ncol2, 1, dQdXsB.data(), &myBulk.dSec_dPri[n * bsize2],
1933  1, bmat.data());
1934  fill(bmat2.begin(), bmat2.end(), 0.0);
1935  for (USI i = 0; i < nc; i++) {
1936  // becareful '-' before factor
1937  // Daxpy(ncol, -factor, bmat.data() + (i + 1) * ncol, bmat2.data());
1938  Daxpy(ncol, factor, bmat.data() + (i + 1) * ncol, bmat2.data());
1939  }
1940 
1941  // Insert bulk val into equations in ascending order
1942  for (USI t = 0; t < tlen; t++) {
1943  tar = tarId[t];
1944  tarsize = myLS.colId[tar].size();
1945  USI i;
1946  for (i = 0; i < tarsize; i++) {
1947  if (n < myLS.colId[tar][i]) {
1948  // insert
1949  // attention that bulk id is less than well id
1950  myLS.colId[tar].insert(myLS.colId[tar].begin() + i, n);
1951  myLS.val[tar].insert(myLS.val[tar].begin() + i * bsize,
1952  bmat.begin(), bmat.end());
1953  myLS.diagPtr[tar]++;
1954  break;
1955  }
1956  }
1957  }
1958  }
1959  // insert prod well var into equations in ascending order
1960  for (USI t = 0; t < tlen; t++) {
1961  tar = tarId[t];
1962  tarsize = myLS.colId[tar].size();
1963  USI i;
1964  for (i = 0; i < tarsize; i++) {
1965  if (prodId < myLS.colId[tar][i]) {
1966  // insert
1967  myLS.colId[tar].insert(myLS.colId[tar].begin() + i, prodId);
1968  myLS.val[tar].insert(myLS.val[tar].begin() + i * bsize,
1969  tmpMat.begin(), tmpMat.end());
1970  if (i <= myLS.diagPtr[tar]) myLS.diagPtr[tar]++;
1971  break;
1972  }
1973  }
1974  if (i == tarsize) {
1975  // insert into end
1976  myLS.colId[tar].push_back(prodId);
1977  myLS.val[tar].insert(myLS.val[tar].end(), tmpMat.begin(), tmpMat.end());
1978  }
1979  }
1980  }
1981 }
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:76
void Daxpy(const int &n, const double &alpha, const double *x, double *y)
Constant times a vector plus a vector.
Definition: DenseMat.cpp:69
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:22
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:26
const OCP_DBL CONV1
1 bbl = CONV1 ft3
Definition: OCPConst.hpp:59
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:24
const USI BHP_MODE
Well option = fixed bottom-hole-pressure.
Definition: OCPConst.hpp:120
bool WellState() const
Return the state of the well, Open or Close.
Definition: Well.hpp:172

References BHP_MODE, CONV1, DaABpbC(), Daxpy(), and WellState().

◆ 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 1445 of file Well.cpp.

1448 {
1449  // find Open injection well under Rate control
1450  vector<OCP_USI> tarId;
1451  for (USI w = 0; w < injId.size(); w++) {
1452  if (allWell[w].WellState() && allWell[w].opt.optMode != BHP_MODE)
1453  tarId.push_back(allWell[w].wEId + myBulk.numBulk);
1454  }
1455 
1456  USI tlen = tarId.size();
1457  if (tlen > 0) {
1458  const OCP_DBL factor = allWell[injId[0]].opt.factor * dt;
1459  // cout << "Factor(assemble): " << allWell[injId[0]].opt.factor << endl;
1460  const OCP_USI prodId = wEId + myBulk.numBulk;
1461  USI np = myBulk.numPhase;
1462  OCP_USI n, bId;
1463  OCP_DBL tmp, valb;
1464  OCP_DBL valw = 0;
1465  OCP_DBL rhsw = 0;
1466  OCP_USI tar;
1467  USI tarsize;
1468  for (USI p = 0; p < numPerf; p++) {
1469  n = perf[p].location;
1470  valb = 0;
1471 
1472  for (USI j = 0; j < np; j++) {
1473  bId = n * np + j;
1474  if (myBulk.phaseExist[bId]) {
1475  tmp = perf[p].transj[j] * myBulk.xi[bId];
1476  valb += tmp;
1477  rhsw += tmp * (myBulk.Pc[bId] - dG[p]);
1478  }
1479  }
1480  valb *= factor;
1481  // Insert bulk val into equations in ascending order
1482  for (USI t = 0; t < tlen; t++) {
1483  tar = tarId[t];
1484  tarsize = myLS.colId[tar].size();
1485  USI i;
1486  for (i = 0; i < tarsize; i++) {
1487  if (n < myLS.colId[tar][i]) {
1488  // insert
1489  // attention that bulk id is less than well id
1490  myLS.colId[tar].insert(myLS.colId[tar].begin() + i, n);
1491  myLS.val[tar].insert(myLS.val[tar].begin() + i, -valb);
1492  myLS.diagPtr[tar]++;
1493  break;
1494  }
1495  }
1496  }
1497  valw += valb;
1498  }
1499  rhsw *= factor;
1500  // insert prod well var and rhs into equations in ascending order
1501  for (USI t = 0; t < tlen; t++) {
1502  tar = tarId[t];
1503  tarsize = myLS.colId[tar].size();
1504  myLS.b[tar] += rhsw; // rhsw
1505  USI i;
1506  for (i = 0; i < tarsize; i++) {
1507  if (prodId < myLS.colId[tar][i]) {
1508  // insert
1509  myLS.colId[tar].insert(myLS.colId[tar].begin() + i, prodId);
1510  myLS.val[tar].insert(myLS.val[tar].begin() + i, valw);
1511  if (i <= myLS.diagPtr[tar]) myLS.diagPtr[tar]++;
1512  break;
1513  }
1514  }
1515  if (i == tarsize) {
1516  // pushback
1517  myLS.colId[tar].push_back(prodId);
1518  myLS.val[tar].push_back(valw);
1519  }
1520  }
1521  }
1522 }

References BHP_MODE, and WellState().

◆ 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 577 of file Well.cpp.

578 {
579  OCP_FUNCNAME;
580 
581  if (opt.type == INJ)
582  CalInjdG(myBulk);
583  else
584  CalProddG(myBulk);
585 
586  // if (name == "PROD17") {
587  // for (USI p = 0; p < numPerf; p++) {
588  // cout << perf[p].state << " ";
589  // cout << setprecision(2);
590  // cout << dG[p] << " ";
591  // OCP_USI n = perf[p].location * myBulk.numPhase;
592  // cout << setprecision(6);
593  // cout << myBulk.kr[n + 0] << " ";
594  // cout << myBulk.kr[n + 1] << " ";
595  // cout << myBulk.kr[n + 2] << " ";
596  // cout << myBulk.S[n + 0] << " ";
597  // cout << myBulk.S[n + 1] << " ";
598  // cout << myBulk.S[n + 2] << " ";
599  // cout << setprecision(2);
600  // for (USI i = 0; i < myBulk.numCom; i++) {
601  // cout << perf[p].qi_lbmol[i] << " ";
602  // }
603  // cout << endl;
604  // }
605  //}
606 }
const USI INJ
Well type = injector.
Definition: OCPConst.hpp:107
#define OCP_FUNCNAME
Print Function Name.
Definition: UtilError.hpp:73
void CalInjdG(const Bulk &myBulk)
Calculate pressure difference between well and perforations for Injection.
Definition: Well.cpp:608
void CalProddG(const Bulk &myBulk)
Calculate pressure difference between well and perforations for Prodcution.
Definition: Well.cpp:678

References CalInjdG(), CalProddG(), INJ, and OCP_FUNCNAME.

◆ CalInjRate()

OCP_DBL Well::CalInjRate ( const Bulk myBulk,
const bool &  maxBHP 
)

calculate flow rate of moles of components 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 460 of file Well.cpp.

461 {
462  OCP_FUNCNAME;
463 
464  OCP_DBL qj = 0;
465  OCP_DBL Pwell = maxBHP ? opt.maxBHP : BHP;
466 
467  for (USI p = 0; p < numPerf; p++) {
468 
469  OCP_DBL Pperf = Pwell + dG[p];
470  OCP_USI k = perf[p].location;
471 
472  OCP_DBL dP = Pperf - myBulk.P[k];
473  qj += perf[p].transINJ * perf[p].xi * dP;
474  }
475  return qj;
476 }

References OCP_FUNCNAME.

◆ CalProdQiBO()

void Well::CalProdQiBO ( const Bulk myBulk)

Calculate flow rate of moles of components for Production well in black oil model.

Definition at line 557 of file Well.cpp.

558 {
559  OCP_FUNCNAME;
560 
561  const USI nc = myBulk.numCom;
562 
563  for (USI i = 0; i < nc; i++) {
564  if (myBulk.index2Phase[i] == OIL) {
565  WOPR = qi_lbmol[i];
566  } else if (myBulk.index2Phase[i] == GAS) {
567  WGPR = qi_lbmol[i];
568  } else if (myBulk.index2Phase[i] == WATER) {
569  WWPR = qi_lbmol[i];
570  }
571  }
572 }
const USI GAS
Fluid type = gas.
Definition: OCPConst.hpp:83
const USI WATER
Fluid type = water.
Definition: OCPConst.hpp:84
const USI OIL
Fluid type = oil.
Definition: OCPConst.hpp:82

References GAS, OCP_FUNCNAME, OIL, and WATER.

◆ CalProdRate()

OCP_DBL Well::CalProdRate ( const Bulk myBulk,
const bool &  minBHP 
)

calculate flow rate of moles of components 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 481 of file Well.cpp.

482 {
483  OCP_FUNCNAME;
484 
485  const USI np = myBulk.numPhase;
486  const USI nc = myBulk.numCom;
487  OCP_DBL qj = 0;
488  OCP_DBL Pwell = minBHP ? opt.minBHP : BHP;
489 
490  for (USI p = 0; p < numPerf; p++) {
491 
492  OCP_DBL Pperf = Pwell + dG[p];
493  OCP_USI k = perf[p].location;
494 
495  for (USI j = 0; j < np; j++) {
496  OCP_USI id = k * np + j;
497  if (myBulk.phaseExist[id]) {
498  OCP_DBL temp = 0;
499  for (USI i = 0; i < nc; i++) {
500  temp += prodWeight[i] * myBulk.xij[id * nc + i];
501  }
502  OCP_DBL xi = myBulk.xi[id];
503  OCP_DBL dP = myBulk.Pj[id] - Pperf;
504  qj += perf[p].transj[j] * xi * dP * temp;
505  }
506  }
507  }
508  return qj;
509 }

References OCP_FUNCNAME.

◆ 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 971 of file Well.cpp.

972 {
973  OCP_FUNCNAME;
974  if (opt.initOptMode == BHP_MODE) {
975  if (opt.type == INJ) {
976  OCP_DBL q = CalInjRate(myBulk, true);
977  // for INJ well, maxRate has been switch to lbmols
978  OCP_DBL tarRate = opt.maxRate;
979  if (opt.reInj) {
980  if (opt.injPhase == GAS)
981  tarRate = WGIR;
982  else if (opt.injPhase == WATER)
983  tarRate = WWIR;
984  }
985  if (q > tarRate) {
986  opt.optMode = RATE_MODE;
987  }
988  else {
989  opt.optMode = BHP_MODE;
990  BHP = opt.maxBHP;
991  }
992  }
993  else {
994  opt.optMode = BHP_MODE;
995  if (opt.type == INJ)
996  BHP = opt.maxBHP;
997  else
998  BHP = opt.minBHP;
999  }
1000  //else {
1001  // OCP_DBL q = CalProdRate(myBulk, false);
1002  // // cout << q << endl;
1003  // if (q > opt.maxRate) {
1004  // opt.optMode = opt.initOptMode;
1005  // }
1006  // else {
1007  // opt.optMode = BHP_MODE;
1008  // BHP = opt.minBHP;
1009  // }
1010  //}
1011  } else {
1012  if (opt.type == INJ) {
1013  OCP_DBL q = CalInjRate(myBulk, true);
1014  // for INJ well, maxRate has been switch to lbmols
1015  OCP_DBL tarRate = opt.maxRate;
1016  if (opt.reInj) {
1017  if (opt.injPhase == GAS)
1018  tarRate = WGIR;
1019  else if (opt.injPhase == WATER)
1020  tarRate = WWIR;
1021  }
1022 
1023  if (q > tarRate) {
1024  opt.optMode = opt.initOptMode;
1025  }
1026  else {
1027  opt.optMode = BHP_MODE;
1028  BHP = opt.maxBHP;
1029  }
1030  }
1031  else {
1032  OCP_DBL q = CalProdRate(myBulk, true);
1033  // cout << q << endl;
1034  if (q > opt.maxRate) {
1035  opt.optMode = opt.initOptMode;
1036  }
1037  else {
1038  opt.optMode = BHP_MODE;
1039  BHP = opt.minBHP;
1040  }
1041  }
1042  }
1043 }
const USI RATE_MODE
Well option = fixed total rate???
Definition: OCPConst.hpp:115
OCP_DBL CalProdRate(const Bulk &myBulk, const bool &minBHP)
calculate flow rate of moles of components for production well with minBHP
Definition: Well.cpp:481
OCP_DBL CalInjRate(const Bulk &myBulk, const bool &maxBHP)
calculate flow rate of moles of components for injection well with maxBHP
Definition: Well.cpp:460

References BHP_MODE, CalInjRate(), CalProdRate(), GAS, INJ, OCP_FUNCNAME, RATE_MODE, and WATER.

◆ SmoothdG()

void Well::SmoothdG ( )

Try to smooth the dG by average it with dG at last time step.

It's just a test now to make dG more stable.

Definition at line 959 of file Well.cpp.

960 {
961  OCP_FUNCNAME;
962 
963  for (USI p = 0; p < numPerf; p++) {
964  dG[p] = (ldG[p] + dG[p]) / 2; // seems better
965  // dG[p] = ldG[p] + 0.618 * (dG[p] - ldG[p]);
966  }
967 }

References OCP_FUNCNAME.


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