34 conn.
Setup(grid, bulk);
35 allWells.
Setup(grid, bulk);
86 allWells.CalMaxBHPChange();
110 flag = allWells.
CheckP(bulk);
131 void Reservoir::GetNTQT(
const OCP_DBL& dt)
134 OCP_DBL QT = allWells.CalWellQT() * dt;
135 cout << setprecision(8) << NT <<
" " << QT << endl;
166 allWells.UpdateLastBHP();
176 allWells.
CalCFL(bulk, dt);
255 allWells.
CaldG(bulk);
278 bulk.ResetphaseNum();
279 bulk.ResetminEigenSkip();
280 bulk.ResetflagSkip();
326 void Reservoir::InitFIM_n()
336 bulk.InitFlashDer_n();
351 void Reservoir::CalFlashDerivFIM_n()
370 allWells.UpdateLastBHP();
406 allWells.AssemblaMatFIM_new_n(myLS, bulk, dt);
417 void Reservoir::GetSolutionFIM_n(
const vector<OCP_DBL>& u,
const OCP_DBL& dPmax,
428 void Reservoir::GetSolution01FIM(
const vector<OCP_DBL>& u)
445 Dscalar(resFIM.res.size(), -1.0, resFIM.res.data());
479 allWells.
CaldG(bulk);
484 void Reservoir::PrintSolFIM(
const string& outfile)
const
486 ofstream outu(outfile);
487 if (!outu.is_open()) cout <<
"Can not open " << outfile << endl;
488 const OCP_USI nb = bulk.numBulk;
489 const OCP_USI nc = bulk.numCom;
491 for (
OCP_USI n = 0; n < nb; n++) {
493 outu << bulk.P[n] <<
"\n";
495 for (
USI i = 0; i < nc; i++) {
496 outu << bulk.Ni[n * nc + i] <<
"\n";
500 for (
USI w = 0; w < allWells.numWell; w++) {
501 outu << allWells.
GetWBHP(w) <<
"\n";
506 void Reservoir::ShowRes(
const vector<OCP_DBL>& res)
const
559 Dscalar(resFIM.res.size(), -1, resFIM.res.data());
598 Dscalar(resFIM.res.size(), -1, resFIM.res.data());
608 void Reservoir::GetSolutionAIMs(
const vector<OCP_DBL>& u,
const OCP_DBL& dPmax,
611 bulk.GetSolAIMs(u, dPmax, dSmax);
615 void Reservoir::ResetValAIM()
624 allWells.
CaldG(bulk);
644 bulk.UpdateLastStepAIM();
646 allWells.UpdateLastBHP();
655 bulk.AllocateAuxAIMc();
664 conn.AssembleMat_AIMc01(myLS, bulk, dt);
679 Dscalar(resFIM.res.size(), -1, resFIM.res.data());
682 void Reservoir::CalFlashAIMc()
687 void Reservoir::CalFlashAIMc01()
692 void Reservoir::CalKrPcAIMc()
711 void Reservoir::GetSolutionAIMc(
const vector<OCP_DBL>& u,
const OCP_DBL& dPmax,
714 bulk.GetSolAIMc01(u, dPmax, dSmax);
718 void Reservoir::InitAIMc()
void Dscalar(const int &n, const double &alpha, double *x)
Scales a vector by a constant.
const USI BLKOIL
Mixture model = black-oil.
const USI EOS_PVTW
Mixture model = equation-of-state.
unsigned int USI
Generic unsigned integer.
double OCP_DBL
Double precision.
unsigned int OCP_USI
Long unsigned integer.
Reservoir class declaration.
#define OCP_FUNCNAME
Print Function Name.
void ShowRes(const vector< OCP_DBL > &res, const Bulk &myBulk) const
Show Res.
void CalResAIMt(ResFIM &resFIM, const Bulk &myBulk, const OCP_DBL &dt) const
Calculate Resiual and relative Resiual for local FIM.
void CalFlux(const Bulk &myBulk)
Calculate volume flow rate and moles flow rate of each perforation.
void CalTrans(const Bulk &myBulk)
Calculate Transmissibility of Wells.
void AllocateMat(LinearSystem &myLS, const USI &bulknum) const
Calculate memory for Matrix.
void AssemblaMatFIM(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for FIM.
void UpdateLastDg()
Reset dG to ldG for each well.
void AssemblaMatAIMt(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for AIMt.
void AssemblaMatIMPEC(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for IMPEC.
void MassConserveIMPEC(Bulk &myBulk, OCP_DBL dt)
Update moles of components in Bulks which connects to well.
OCP_INT CheckP(const Bulk &myBulk)
Check if unreasonable well pressure or perforation pressure occurs.
void CaldG(const Bulk &myBulk)
Calculate dG.
OCP_DBL GetWBHP(const USI &w) const
Return the BHP of wth well.
void ApplyControl(const USI &i)
Apply the operation mode at the ith critical time.
void AssemblaMatFIM_new(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for FIM.
void CalIPRT(const Bulk &myBulk, OCP_DBL dt)
Calculate Injection rate, total Injection, Production rate, total Production.
void GetSolAIMt(const vector< OCP_DBL > &u, const OCP_USI &bId, const USI &len)
Get solution from solver class after linear system is solved for local FIM.
void GetSolFIM(const vector< OCP_DBL > &u, const OCP_USI &bId, const USI &len)
Get solution from solver class after linear system is solved for FIM.
void GetSolIMPEC(const vector< OCP_DBL > &u, const OCP_USI &bId)
Update Well P and Perforation P after linear system is solved for IMPEC.
void InitBHP(const Bulk &myBulk)
Set the initial well pressure.
USI GetWellPerfNum(const USI &i) const
Return the num of perforations of well i.
void SetupWellGroup(const Bulk &myBulk)
Setup information of wellGroup.
void Setup(const Grid &myGrid, const Bulk &myBulk)
Setup well in allWells.
void PrepareWell(const Bulk &myBulk)
Calculate well properties at the beginning of each time step.
void CalResFIM(ResFIM &resFIM, const Bulk &myBulk, const OCP_DBL &dt) const
Calculate Resiual and relative Resiual for FIM.
USI GetWellNum() const
Return the num of wells.
void CalReInjFluid(const Bulk &myBulk)
Calculate Reinjection fluid.
void InputParam(const ParamWell ¶mWell)
Input param from ParamWell.
void CalCFL(const Bulk &myBulk, const OCP_DBL &dt) const
Calculate the CFL number for each perforation and return the maximum one.
void AssemblaMatAIMs(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for AIMt.
void Setup(const Grid &myGrid, const Bulk &myBulk)
Setup active connections and calculate necessary properties using Grid and Bulk.
void UpdateLastStep()
Update physcial values of the previous step.
void AllocateAuxAIMc(const USI &np)
Allocate memory for auxiliary variables used by the AIMc method.
void AssembleMatIMPEC(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assmeble coefficient matrix for IMPEC, terms related to bulks only.
void SetupMatSparsity(LinearSystem &myLS) const
Setup sparsity pattern of the coefficient matrix.
void AssembleMat_FIM(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assmeble coefficient matrix for FIM, terms related to bulks only.
void CalCFL(const Bulk &myBulk, const OCP_DBL &dt) const
Calculate the CFL number for flow between bulks???
void AllocateAuxIMPEC(const USI &np)
Allocate memory for auxiliary variables used by the IMPEC method.
void AllocateAuxAIMt()
Allocate memory for auxiliary variables used by the AIMt method.
void MassConserveIMPEC(Bulk &myBulk, const OCP_DBL &dt) const
Update mole composition of each bulk according to mass conservation for IMPEC.
void CalResFIM(vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt)
Calculate resiual for the Newton iteration in FIM.
void CalResAIMc(vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt)
Calculate resiual for the Newton iteration in FIM.
void CalFluxFIM(const Bulk &myBulk)
Calculate flux for FIM, considering upwinding.
void CalFluxIMPEC(const Bulk &myBulk)
Calculate flux information about flow between bulks for IMPEC.
void AssembleMat_FIM_new(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
void AssembleMat_FIM_new_n(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
OCP_NEW_FIMn.
void AllocateMat(LinearSystem &myLS) const
Allocate memory for the coefficient matrix.
void SetupMatSparsityAIMt(LinearSystem &myLS, const Bulk &myBulk) const
Setup sparsity pattern of the coefficient matrix for AIMt.
void Reset()
Reset physcial values of the current step with the previous step.
void CalResAIMt(vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt)
Calculate resiual for the Newton iteration in local FIM.
void AllocateAuxFIM(const USI &np)
Allocate memory for auxiliary variables used by the FIM method.
void CalResAIMs(vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt)
void AssembleMat_AIMt(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assmeble coefficient matrix for FIM, terms related to bulks only.
void AssembleMat_AIMs(LinearSystem &myLS, vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt) const
void AllocateAuxAIM(const OCP_DBL &ratio)
Allocate memory for auxiliary variables used for AIMt.
void InitSjPcComp(const USI &tabrow, const Grid &myGrid)
Calculate initial equilibrium for compositional model according to EQUIL.
USI GetPhaseNum() const
Return the number of phases.
void AllocateWellBulkId(const USI &n)
Allocate memory for WellbulkId.
void ResetPj()
Reset Pj to the ones of the last time step.
void CalRelResAIMs(ResFIM &resFIM) const
Calculate relative resiual for AIMs, parts related to FIM are considered.
void GetSolIMPEC(const vector< OCP_DBL > &u)
Update P and Pj after linear system is solved.
void InitFlash(const bool &flag=false)
Perform flash calculation with saturations.
void FlashAIMc()
Perform flash calculation with Ni.
bool CheckVe(const OCP_DBL &Vlim) const
Check if relative volume error is out of range, return false if so.
void AllocateAuxIMPEC()
Allocate memory for auxiliary variables used for IMPEC.
void CalMaxChange()
Calculate max change of some variables.
USI GetMixMode() const
Return the mixture mode.
void UpdateLastStepFIM()
Update values of last step for FIM.
void FlashDeriv()
Perform flash calculation with Ni and calculate derivatives.
void ResetNi()
Reset Ni to the ones of the last time step.
void ResetVp()
Reset Vp to the ones of the last time step.
void CalVpore()
Calculate volume of pore with pressure.
void CalRelResFIM(ResFIM &resFIM) const
Calculate relative resiual for FIM.
void ResetFIM()
Reset FIM.
void ResetNt()
Reset Nt to the ones of the last time step.
void CalKrPcDerivAIMc()
Calculate relative permeability and capillary pressure and their derivatives.
void SetCFL2Zero() const
Initialize the CFL number.
void GetSolAIMt(const vector< OCP_DBL > &u, const OCP_DBL &dPmaxlim, const OCP_DBL &dSmaxlim)
Get the solution for local FIM after a Newton iteration.
void Flash()
Perform flash calculation with Ni.
void CalKrPcDeriv()
Calculate relative permeability and capillary pressure and their derivatives.
void GetSol01FIM(const vector< OCP_DBL > &u)
Get the solution for FIM after a Newton iteration???
OCP_DBL CalCFL() const
Calculate the CFL number.
void Setup(const Grid &myGrid)
Allocate memory for bulk data of grid.
void FlashDerivAIM(const bool &IfAIMs)
Perform flash calculation with Ni and calculate derivatives.
void CalKrPcDerivAIM(const bool &IfAIMs)
Calculate relative permeability and capillary pressure and their derivatives.
void ResetFlash()
Reset variables in flash calculations.
void FlashDerivAIMc()
Perform flash calculation with Ni and calculate derivatives.
void InputParam(ParamReservoir &rs_param)
Input param from internal data structure ParamReservoir.
void CalKrPcAIMc()
Calculate relative permeability and capillary pressure with saturation.
void CalKrPc()
Calculate relative permeability and capillary pressure with saturation.
OCP_USI GetBulkNum() const
Return the number of bulks.
void InitSjPcBo(const USI &tabrow)
Calculate initial equilibrium for blkoil model according to EQUIL.
USI GetComNum() const
Return the number of components.
void UpdateLastStepIMPEC()
Update value of last step for IMPEC.
bool CheckNi()
Check if negative Ni occurs, return false if so.
void InitFlashDer()
Perform flash calculation with saturations and calculate derivatives.
void AllocateAuxFIM()
Allocate memory for auxiliary variables used for FIM.
void GetSolFIM_n(const vector< OCP_DBL > &u, const OCP_DBL &dPmaxlim, const OCP_DBL &dSmaxlim)
bool CheckP() const
Check if negative P occurs, return false if so.
void CalRelResAIMt(ResFIM &resFIM) const
Calculate relative resiual for local FIM.
void GetSolFIM(const vector< OCP_DBL > &u, const OCP_DBL &dPmaxlim, const OCP_DBL &dSmaxlim)
Get the solution for FIM after a Newton iteration.
void InputParam(const ParamReservoir &rs_param)
Input parameters from the internal param structure.
void Setup()
Setup the grid information and calculate the properties.
Linear solvers for discrete systems.
void AllocateColMem()
Allocate memory for each matrix row with max possible number of columns.
void AllocateRowMem(const OCP_USI &dimMax, const USI &nb)
Allocate memory for linear system with max possible number of rows.
Pre-processing unit for OpenCAEPoro for reading params from input files.
ParamWell paramWell
Read the well params.
ParamReservoir paramRs
Read the reservoir params.
bool CheckVe(const OCP_DBL &Vlim) const
Check error between Fluids and Pores.
void AllocateMatIMPEC(LinearSystem &myLS) const
Allocate Maxmimum memory for internal Matirx for IMPEC.
void InitFIM()
Initialize the properties of Reservoir for FIM.
void ResetWellIMPEC()
Reset Well for IMPEC.
void AssembleMatAIMs(LinearSystem &myLS, vector< OCP_DBL > &res, const OCP_DBL &dt) const
Assemble Matrix for AIMs.
void AssembleMatFIM(LinearSystem &myLS, const OCP_DBL &dt) const
Assemble Matrix for FIM.
void AllocateAuxAIMt()
Allocate memory for auxiliary variables used for AIMt.
void UpdateLastStepFIM()
Update value of last step for FIM.
void AllocateAuxFIM()
Allocate memory for auxiliary variables used for FIM.
void ResetVal01IMPEC()
Reset Capillary Pressure, Flux for IMPEC.
void CalKrPc()
Calculate Relative Permeability and Capillary for each Bulk.
void Setup()
Setup static information for reservoir with input params.
void UpdateLastStepAIM()
Update value of last step for IMPEC.
void CalFlashIMPEC()
Calculate Flash For IMPEC.
void MassConseveIMPEC(const OCP_DBL &dt)
Calculate Ni according to Flux.
void GetSolutionFIM(const vector< OCP_DBL > &u, const OCP_DBL &dPmax, const OCP_DBL &dSmax)
void CalFlashDerivAIM(const bool &IfAIMs)
Calculate Flash for local FIM, some derivatives are needed.
void GetSolutionIMPEC(const vector< OCP_DBL > &u)
Return the Solution to Reservoir Pressure for IMPEC.
bool CheckNi()
Check if abnormal Pressure occurs.
void InputParam(ParamRead ¶m)
void CalVpore()
Calculate pore of Bulks.
void PrepareWell()
Calculate Well Properties at the beginning of each time step.
void AllocateAuxIMPEC()
Allocate memory for auxiliary variables used for IMPEC.
void InitIMPEC()
Initialize the properties of Reservoir for IMPEC.
void CalKrPcDerivAIM(const bool &IfAIMs)
Calculate Relative Permeability and Capillary and some derivatives for each Bulk.
void GetSolutionAIMt(const vector< OCP_DBL > &u, const OCP_DBL &dPmax, const OCP_DBL &dSmax)
void UpdateLastStepIMPEC()
Update value of last step for IMPEC.
void CalMaxChange()
Calculate Maximum Change of some reference variables for IMPEC.
void AllocateMatFIM(LinearSystem &myLS) const
Allocate Maxmimum memory for internal Matirx for FIM.
OCP_INT CheckP(const bool &bulkCheck=true, const bool &wellCheck=true)
Check if abnormal Pressure occurs.
void AssembleMatAIMc(LinearSystem &myLS, const OCP_DBL &dt) const
Assemble Matrix for AIMc.
void ResetFIM(const bool &flag)
Reset FIM.
void CalFlashDerivAIMc()
Calculate Flash for local FIM, some derivatives are needed.
void CalConnFluxIMPEC()
Calculate flux between bulks.
void ApplyControl(const USI &i)
Apply the control of ith critical time point.
void CalWellTrans()
Calculate Trans of Wells.
void AllocateMatAIMt(LinearSystem &myLS) const
Allocate Maxmimum memory for internal Matirx for local FIM.
void AllocateAuxAIMc()
Allocate memory for auxiliary variables used for FIM.
void AssembleMatIMPEC(LinearSystem &myLS, const OCP_DBL &dt) const
Assemble Matrix for IMPEC.
void AssembleMatAIMt(LinearSystem &myLS, const OCP_DBL &dt) const
Assemble Matrix for AIMt -— local FIM here.
void AllocateAuxAIMs()
Allocate memory for auxiliary variables used for AIMs.
void CalIPRT(const OCP_DBL &dt)
Calculate num of Injection, Production.
OCP_DBL CalCFL(const OCP_DBL &dt)
Calcluate the CFL number, including bulks and wells for IMPEC.
void ResetVal02IMPEC()
Reset Capillary Pressure, Moles of Componnets, Flux for IMPEC.
void CalKrPcDerivAIMc()
Calculate Relative Permeability and Capillary and some derivatives for each Bulk.
void CalKrPcDerivFIM()
Calculate Relative Permeability and Capillary and some derivatives for each Bulk.
void CalFlashDerivFIM()
Calculate Flash for FIM, some derivatives are needed.
void CalFLuxIMPEC()
Calculate flux between bulks, bulks and wells.
void CalResAIMs(ResFIM &resFIM, const OCP_DBL &dt)
Calculate the Resiual for AIMs, it's also RHS of Linear System.
void CalResAIMc(ResFIM &resFIM, const OCP_DBL &dt)
Calculate the Resiual for FIM, it's also RHS of Linear System.
void CalWellFlux()
Calculate Flux between Bulk and Wells.
void CalResFIM(ResFIM &resFIM, const OCP_DBL &dt)
Calculate the Resiual for FIM, it's also RHS of Linear System.
void CalResAIMt(ResFIM &resFIM, const OCP_DBL &dt)
Calculate the Resiual for local FIM, it's also RHS of Linear System.