22 for (
auto& s : paramWell.
solSet) {
32 vector<USI> wellOptTime;
42 wells[w].ifUseUnweight = paramWell.
well[w].ifUseUnweight;
44 wells[w].optSet.resize(t);
47 vector<WellOptPair> tmpOptParam;
48 const USI n0 = paramWell.
well[w].optParam.size();
49 for (
USI i = 0; i < n0 - 1; i++) {
50 if (paramWell.
well[w].optParam[i].d !=
51 paramWell.
well[w].optParam[i + 1].d) {
52 tmpOptParam.push_back(paramWell.
well[w].optParam[i]);
55 tmpOptParam.push_back(paramWell.
well[w].optParam.back());
57 const USI n = tmpOptParam.size();
59 wellOptTime.resize(n + 1);
60 for (
USI i = 0; i < n; i++) {
61 wellOptTime[i] = tmpOptParam[i].d;
63 wellOptTime.back() = t;
64 for (
USI i = 0; i < n; i++) {
65 for (
USI d = wellOptTime[i]; d < wellOptTime[i + 1]; d++) {
79 SetPolyhedronWell(myGrid);
110 for (g = 1; g < glen; g++) {
121 if (g == glen &&
wells[w].group !=
"Field") {
158 for (
auto& w :
wells) {
160 for (
auto& p : w.perf) {
171 for (
auto& w :
wells) {
172 for (
auto& p : w.perf)
well2bulk[wId].push_back(p.Location());
184 if (
wells[w].IsOpen()) {
197 wells[w].InitBHP(myBulk);
206 if (
wells[w].IsOpen()) {
208 wells[w].CalTrans(myBulk);
209 wells[w].CaldG(myBulk);
210 wells[w].CheckOptMode(myBulk);
211 wells[w].CalFlux(myBulk, OCP_TRUE);
221 if (
wells[w].IsOpen()) {
222 wells[w].CalTrans(myBulk);
232 if (
wells[w].IsOpen()) {
233 wells[w].CalFlux(myBulk, OCP_FALSE);
243 if (
wells[w].IsOpen()) {
244 wells[w].CaldG(myBulk);
265 if (
wells[w].IsOpen()) {
267 wells[w].CalProdQj(myBulk, dt);
269 wells[w].CalInjQj(myBulk, dt);
291 fill(wG.reInjZi.begin(), wG.reInjZi.end(), 0.0);
292 for (
auto& prod :
wellGroup[wG.prodGroup].wIdPROD) {
293 Daxpy(nc, 1.0, &
wells[prod].qi_lbmol[0], &wG.reInjZi[0]);
296 if (fabs(qt) < 1E-8) {
298 fill(wG.reInjZi.begin(), wG.reInjZi.end(), 0.0);
299 for (
auto& prod :
wellGroup[wG.prodGroup].wIdPROD) {
300 wells[prod].CalReInjFluid(myBulk, wG.reInjZi);
302 qt =
Dnorm1(nc, &wG.reInjZi[0]);
305 Dcopy(nc, &wG.reInjZi[0], &
flashCal[0]->xij[wG.reInjPhase * nc]);
306 wG.reInjXi =
flashCal[0]->xi[wG.reInjPhase];
307 wG.reInjFactor = wG.reInjXi *
flashCal[0]->vj[wG.reInjPhase] / qt;
309 for (
auto& w : wG.wIdINJ) {
310 if (
wells[w].IsOpen()) {
311 wells[w].opt.reInj = OCP_TRUE;
312 wells[w].opt.connWell = wG.wIdPROD;
313 wells[w].opt.reInjPhase = wG.reInjPhase;
314 wells[w].opt.injZi = wG.reInjZi;
315 wells[w].opt.factorINJ =
317 wells[w].opt.reInjFactor = wG.reInjFactor;
318 wells[w].opt.maxRate =
319 -wG.saleRate *
wells[w].opt.factorINJ;
326 void AllWells::ResetBHP()
328 for (
auto& w :
wells) {
344 if (
wells[w].IsOpen()) {
349 case WELL_NEGATIVE_PRESSURE:
350 return WELL_NEGATIVE_PRESSURE;
352 case WELL_SWITCH_TO_BHPMODE:
353 flagSwitch = OCP_TRUE;
357 flagCrossf = OCP_TRUE;
367 if (flagSwitch || flagCrossf)
return WELL_SWITCH_TO_BHPMODE;
378 if (
wells[w].name == name) {
389 numPerf +=
wells[w].numPerf;
400 m = max(m,
wells[w].numPerf);
405 void AllWells::CalMaxBHPChange()
409 if (
wells[w].IsOpen()) {
415 void AllWells::SetPolyhedronWell(
const Grid& myGrid)
420 polyhedronWell.resize(
numWell);
422 wells[w].SetPolyhedronWell(myGrid, polyhedronWell[w]);
426 void AllWells::SetWellVal()
const
431 if (
wells[w].opt.state) {
434 wellVal[w] =
wells[w].opt.maxBHP;
436 wellVal[w] =
wells[w].opt.maxRate;
439 wellVal[w] =
wells[w].opt.minBHP;
441 wellVal[w] =
wells[w].opt.maxRate;
AllWells class declaration.
void Daxpy(const int &n, const double &alpha, const double *x, double *y)
Constant times a vector plus a vector.
double Dnorm1(const int &N, double *x)
Computes the L1-norm of a vector.
void Dcopy(const int &N, double *dst, const double *src)
Calculate the minimal eigenvalue for symmetric matrix with mkl lapack.
unsigned int USI
Generic unsigned integer.
const USI GAS
Fluid type = gas.
double OCP_DBL
Double precision.
const USI PROD
Well type = producer.
const USI INJ
Well type = injector.
const USI BHP_MODE
Well option = fixed bottom-hole-pressure.
unsigned int OCP_BOOL
OCP_BOOL in OCP.
#define OCP_FUNCNAME
Print Function Name.
#define OCP_ABORT(msg)
Abort if critical error happens.
void InputParam(const ParamWell ¶mWell, const ParamOutput &output_param)
Input param from ParamWell.
void CalFlux(const Bulk &myBulk)
Calculate volume flow rate and moles flow rate of each perforation.
vector< vector< OCP_USI > > well2bulk
connections between wells and bulks
OCP_DBL Psurf
well reference pressure
vector< Well > wells
well set.
void CalTrans(const Bulk &myBulk)
Calculate Transmissibility of Wells.
vector< SolventINJ > solvents
Sets of Solvent.
USI GetMaxWellPerNum() const
Calculate maximum num of perforations of all Wells.
OCP_DBL dPmax
Maximum BHP change.
void SetupWell(const Grid &myGrid, const Bulk &myBulk)
complete the information of well according to Grid and Bulk.
OCP_INT CheckP(const Bulk &myBulk)
Check if unreasonable well pressure or perforation pressure occurs.
OCP_DBL FWIR
water injection rate in field.
void SetupConnWell2Bulk(const Bulk &myBulk)
Setup the static connection between well and bulks.
OCP_DBL FGIT
gas total injection in field.
OCP_DBL FOPR
oil production rate in field.
OCP_DBL FGPt
gas total production in field.
void CaldG(const Bulk &myBulk)
Calculate dG.
OCP_DBL FWPR
water production rate in field.
vector< WellGroup > wellGroup
wellGroup set
OCP_BOOL wellChange
if wells change, then OCP_TRUE
void ApplyControl(const USI &i)
Apply the operation mode at the ith critical time.
OCP_DBL FGIR
gas injection rate in field.
void SetupMixture(const Bulk &myBulk)
get the mixture from bulk -— useless now
OCP_DBL Tsurf
well reference temperature
OCP_DBL FGPR
gas production rate in field.
USI GetWellPerfNum() const
Return the num of perforations of all wells.
void CalIPRT(const Bulk &myBulk, OCP_DBL dt)
Calculate Injection rate, total Injection, Production rate, total Production.
void SetupWellBulk(Bulk &myBulk) const
Setup bulks which are penetrated by wells at current stage.
OCP_DBL FWIT
water total injection in field.
void InitBHP(const Bulk &myBulk)
Set the initial well pressure.
OCP_DBL FOPT
oil total production in field.
void SetupWellGroup(const Bulk &myBulk)
Setup information of wellGroup.
USI numGroup
num of groups
USI GetIndex(const string &name) const
Return the index of specified well.
void Setup(const Grid &myGrid, const Bulk &myBulk)
Setup wells.
void PrepareWell(const Bulk &myBulk)
Calculate well properties at the beginning of each time step.
OCP_DBL FWPT
water total production in field.
vector< Mixture * > flashCal
Useless now.
void CalReInjFluid(const Bulk &myBulk)
Calculate Reinjection fluid.
Physical information of each active reservoir bulk.
const vector< Mixture * > & GetMixture() const
Return flash.
USI GetComNum() const
Return the number of components.
void AddWellBulkId(const OCP_USI &n)
push back an element for wellBulkId
OutputVTKParam outVTKParam
See OutputVTKParam.
OCP_DBL Psurf
Pressure in surface condition.
vector< Solvent > solSet
Sets of Solvent.
vector< OCP_DBL > criticalTime
Records the critical time given by users.
OCP_DBL Tsurf
Temperature in surface condition.
vector< WellParam > well
Contains all the information of wells.