2017-06-15 04:41:03 -05:00
|
|
|
/*
|
2017-08-03 09:45:59 -05:00
|
|
|
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
2017-06-15 04:41:03 -05:00
|
|
|
Copyright 2017 Statoil ASA.
|
2017-08-03 09:45:59 -05:00
|
|
|
Copyright 2016 - 2017 IRIS AS.
|
2017-06-15 04:41:03 -05:00
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OPM_STANDARDWELL_HEADER_INCLUDED
|
|
|
|
#define OPM_STANDARDWELL_HEADER_INCLUDED
|
|
|
|
|
|
|
|
|
2019-06-20 02:09:19 -05:00
|
|
|
#include <opm/simulators/wells/RateConverter.hpp>
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/wells/WellInterface.hpp>
|
|
|
|
#include <opm/simulators/linalg/ISTLSolverEbos.hpp>
|
2017-06-15 04:41:03 -05:00
|
|
|
|
2019-07-04 02:50:08 -05:00
|
|
|
#include <ewoms/models/blackoil/blackoilpolymermodules.hh>
|
|
|
|
#include <ewoms/models/blackoil/blackoilsolventmodules.hh>
|
|
|
|
#include <ewoms/models/blackoil/blackoilfoammodules.hh>
|
|
|
|
|
2019-03-25 06:52:34 -05:00
|
|
|
#include <opm/material/densead/DynamicEvaluation.hpp>
|
|
|
|
|
|
|
|
#include <dune/common/dynvector.hh>
|
|
|
|
#include <dune/common/dynmatrix.hh>
|
|
|
|
|
2017-06-15 04:41:03 -05:00
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
|
|
|
class StandardWell: public WellInterface<TypeTag>
|
2017-06-15 04:41:03 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2017-08-02 09:19:27 -05:00
|
|
|
typedef WellInterface<TypeTag> Base;
|
2018-08-16 04:51:36 -05:00
|
|
|
|
2017-06-29 06:52:31 -05:00
|
|
|
// TODO: some functions working with AD variables handles only with values (double) without
|
|
|
|
// dealing with derivatives. It can be beneficial to make functions can work with either AD or scalar value.
|
|
|
|
// And also, it can also be beneficial to make these functions hanle different types of AD variables.
|
2017-08-02 09:19:27 -05:00
|
|
|
using typename Base::Simulator;
|
|
|
|
using typename Base::WellState;
|
|
|
|
using typename Base::IntensiveQuantities;
|
|
|
|
using typename Base::FluidSystem;
|
|
|
|
using typename Base::MaterialLaw;
|
|
|
|
using typename Base::ModelParameters;
|
2017-12-04 02:14:08 -06:00
|
|
|
using typename Base::Indices;
|
2017-11-23 01:37:30 -06:00
|
|
|
using typename Base::RateConverterType;
|
2017-06-19 09:46:06 -05:00
|
|
|
|
2017-08-31 00:50:28 -05:00
|
|
|
using Base::numEq;
|
|
|
|
|
2018-03-26 03:50:33 -05:00
|
|
|
using Base::has_solvent;
|
|
|
|
using Base::has_polymer;
|
2019-04-26 03:38:37 -05:00
|
|
|
using Base::has_foam;
|
2018-03-26 03:50:33 -05:00
|
|
|
using Base::has_energy;
|
|
|
|
|
2019-07-04 02:50:08 -05:00
|
|
|
using PolymerModule = Ewoms::BlackOilPolymerModule<TypeTag>;
|
|
|
|
using FoamModule = Ewoms::BlackOilFoamModule<TypeTag>;
|
|
|
|
|
2018-05-09 08:07:43 -05:00
|
|
|
// polymer concentration and temperature are already known by the well, so
|
|
|
|
// polymer and energy conservation do not need to be considered explicitly
|
2018-11-30 05:15:51 -06:00
|
|
|
static const int numPolymerEq = Indices::numPolymers;
|
|
|
|
static const int numEnergyEq = Indices::numEnergy;
|
2019-04-26 03:38:37 -05:00
|
|
|
static const int numFoamEq = Indices::numFoam;
|
2018-11-30 05:15:51 -06:00
|
|
|
|
2018-05-18 03:57:08 -05:00
|
|
|
// number of the conservation equations
|
2019-04-26 03:38:37 -05:00
|
|
|
static const int numWellConservationEq = numEq - numPolymerEq - numEnergyEq - numFoamEq;
|
2018-05-18 03:57:08 -05:00
|
|
|
// number of the well control equations
|
|
|
|
static const int numWellControlEq = 1;
|
2018-12-12 08:58:15 -06:00
|
|
|
// number of the well equations that will always be used
|
|
|
|
// based on the solution strategy, there might be other well equations be introduced
|
|
|
|
static const int numStaticWellEq = numWellConservationEq + numWellControlEq;
|
2018-05-09 08:07:43 -05:00
|
|
|
|
2017-06-15 04:41:03 -05:00
|
|
|
// the positions of the primary variables for StandardWell
|
2018-05-30 08:44:05 -05:00
|
|
|
// the first one is the weighted total rate (WQ_t), the second and the third ones are F_w and F_g,
|
2018-05-11 07:21:53 -05:00
|
|
|
// which represent the fraction of Water and Gas based on the weighted total rate, the last one is BHP.
|
2018-05-08 03:54:57 -05:00
|
|
|
// correspondingly, we have four well equations for blackoil model, the first three are mass
|
|
|
|
// converstation equations, and the last one is the well control equation.
|
2018-05-09 08:07:43 -05:00
|
|
|
// primary variables related to other components, will be before the Bhp and after F_g.
|
2018-05-11 07:21:53 -05:00
|
|
|
// well control equation is always the last well equation.
|
|
|
|
// TODO: in the current implementation, we use the well rate as the first primary variables for injectors,
|
|
|
|
// instead of G_t.
|
2017-12-04 02:14:08 -06:00
|
|
|
static const bool gasoil = numEq == 2 && (Indices::compositionSwitchIdx >= 0);
|
2018-05-30 08:44:05 -05:00
|
|
|
static const int WQTotal = 0;
|
2017-08-31 00:50:28 -05:00
|
|
|
static const int WFrac = gasoil? -1000: 1;
|
|
|
|
static const int GFrac = gasoil? 1: 2;
|
2018-05-09 08:07:43 -05:00
|
|
|
static const int SFrac = !has_solvent ? -1000 : 3;
|
|
|
|
// the index for Bhp in primary variables and also the index of well control equation
|
2018-05-11 07:21:53 -05:00
|
|
|
// they both will be the last one in their respective system.
|
|
|
|
// TODO: we should have indices for the well equations and well primary variables separately
|
2018-12-12 08:58:15 -06:00
|
|
|
static const int Bhp = numStaticWellEq - numWellControlEq;
|
|
|
|
|
2017-08-02 09:19:27 -05:00
|
|
|
using typename Base::Scalar;
|
2017-08-22 07:49:30 -05:00
|
|
|
|
2017-08-04 06:07:16 -05:00
|
|
|
|
2017-08-21 04:26:21 -05:00
|
|
|
using Base::name;
|
2017-11-08 06:57:36 -06:00
|
|
|
using Base::Water;
|
|
|
|
using Base::Oil;
|
|
|
|
using Base::Gas;
|
2017-08-04 06:07:16 -05:00
|
|
|
|
2017-08-02 09:19:27 -05:00
|
|
|
using typename Base::Mat;
|
|
|
|
using typename Base::BVector;
|
|
|
|
using typename Base::Eval;
|
2017-06-15 10:19:49 -05:00
|
|
|
|
2017-08-03 08:14:36 -05:00
|
|
|
// sparsity pattern for the matrices
|
|
|
|
//[A C^T [x = [ res
|
|
|
|
// B D ] x_well] res_well]
|
|
|
|
|
2017-08-04 03:06:37 -05:00
|
|
|
// the vector type for the res_well and x_well
|
2019-03-25 06:52:34 -05:00
|
|
|
typedef Dune::DynamicVector<Scalar> VectorBlockWellType;
|
2017-08-04 03:06:37 -05:00
|
|
|
typedef Dune::BlockVector<VectorBlockWellType> BVectorWell;
|
|
|
|
|
2019-03-25 06:52:34 -05:00
|
|
|
// the matrix type for the diagonal matrix D
|
|
|
|
typedef Dune::DynamicMatrix<Scalar> DiagMatrixBlockWellType;
|
2017-08-03 08:14:36 -05:00
|
|
|
typedef Dune::BCRSMatrix <DiagMatrixBlockWellType> DiagMatWell;
|
|
|
|
|
|
|
|
// the matrix type for the non-diagonal matrix B and C^T
|
2019-03-25 06:52:34 -05:00
|
|
|
typedef Dune::DynamicMatrix<Scalar> OffDiagMatrixBlockWellType;
|
2017-08-03 08:14:36 -05:00
|
|
|
typedef Dune::BCRSMatrix<OffDiagMatrixBlockWellType> OffDiagMatWell;
|
|
|
|
|
2019-03-25 06:52:34 -05:00
|
|
|
typedef DenseAd::DynamicEvaluation<Scalar, numStaticWellEq + numEq + 1> EvalWell;
|
2017-08-03 08:14:36 -05:00
|
|
|
|
2017-11-30 09:31:48 -06:00
|
|
|
using Base::contiSolventEqIdx;
|
|
|
|
using Base::contiPolymerEqIdx;
|
2019-07-04 02:50:08 -05:00
|
|
|
using Base::contiFoamEqIdx;
|
2018-03-26 03:50:33 -05:00
|
|
|
static const int contiEnergyEqIdx = Indices::contiEnergyEqIdx;
|
2017-06-15 10:19:49 -05:00
|
|
|
|
2019-05-02 05:51:25 -05:00
|
|
|
StandardWell(const Well2& well, const int time_step, const Wells* wells,
|
2017-11-22 07:39:42 -06:00
|
|
|
const ModelParameters& param,
|
|
|
|
const RateConverterType& rate_converter,
|
2017-11-30 09:31:48 -06:00
|
|
|
const int pvtRegionIdx,
|
|
|
|
const int num_components);
|
2017-06-15 04:41:03 -05:00
|
|
|
|
2017-08-04 06:07:16 -05:00
|
|
|
virtual void init(const PhaseUsage* phase_usage_arg,
|
|
|
|
const std::vector<double>& depth_arg,
|
|
|
|
const double gravity_arg,
|
2018-08-16 04:51:36 -05:00
|
|
|
const int num_cells) override;
|
2017-06-15 04:41:03 -05:00
|
|
|
|
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void initPrimaryVariablesEvaluation() const override;
|
2017-06-19 08:24:49 -05:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void assembleWellEq(const Simulator& ebosSimulator,
|
2019-02-27 07:47:31 -06:00
|
|
|
const std::vector<Scalar>& B_avg,
|
2017-06-27 05:17:36 -05:00
|
|
|
const double dt,
|
2019-02-03 01:13:11 -06:00
|
|
|
WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) override;
|
2017-06-21 07:07:11 -05:00
|
|
|
|
2018-11-23 06:11:48 -06:00
|
|
|
virtual void updateWellStateWithTarget(const Simulator& ebos_simulator,
|
2019-02-03 01:13:11 -06:00
|
|
|
WellState& well_state,
|
2019-05-24 09:45:27 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) const override;
|
2017-06-23 03:58:46 -05:00
|
|
|
|
2017-08-04 06:07:16 -05:00
|
|
|
/// check whether the well equations get converged for this well
|
2019-02-07 07:43:17 -06:00
|
|
|
virtual ConvergenceReport getWellConvergence(const std::vector<double>& B_avg,
|
2019-06-06 03:40:46 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) const override;
|
2017-06-26 07:35:43 -05:00
|
|
|
|
2017-08-22 10:14:52 -05:00
|
|
|
/// Ax = Ax - C D^-1 B x
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void apply(const BVector& x, BVector& Ax) const override;
|
2017-08-22 10:14:52 -05:00
|
|
|
/// r = r - C D^-1 Rw
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void apply(BVector& r) const override;
|
2017-07-21 07:21:17 -05:00
|
|
|
|
2017-08-04 06:07:16 -05:00
|
|
|
/// using the solution x to recover the solution xw for wells and applying
|
|
|
|
/// xw to update Well State
|
2017-10-16 09:46:28 -05:00
|
|
|
virtual void recoverWellSolutionAndUpdateWellState(const BVector& x,
|
2019-02-07 07:43:17 -06:00
|
|
|
WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const override;
|
2017-07-21 08:30:34 -05:00
|
|
|
|
2017-08-04 06:07:16 -05:00
|
|
|
/// computing the well potentials for group control
|
2017-07-24 08:09:44 -05:00
|
|
|
virtual void computeWellPotentials(const Simulator& ebosSimulator,
|
2019-04-23 06:30:12 -05:00
|
|
|
const std::vector<Scalar>& B_avg,
|
2017-07-24 08:09:44 -05:00
|
|
|
const WellState& well_state,
|
2019-02-03 01:13:11 -06:00
|
|
|
std::vector<double>& well_potentials,
|
|
|
|
Opm::DeferredLogger& deferred_logger) /* const */ override;
|
2017-08-07 10:49:35 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
virtual void updatePrimaryVariables(const WellState& well_state, Opm::DeferredLogger& deferred_logger) const override;
|
2017-08-07 10:49:35 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
virtual void solveEqAndUpdateWellState(WellState& well_state, Opm::DeferredLogger& deferred_logger) override;
|
2017-09-05 04:09:58 -05:00
|
|
|
|
2017-09-05 04:20:43 -05:00
|
|
|
virtual void calculateExplicitQuantities(const Simulator& ebosSimulator,
|
2019-02-07 07:43:17 -06:00
|
|
|
const WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) override; // should be const?
|
2018-02-26 05:23:20 -06:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void addWellContributions(Mat& mat) const override;
|
2018-02-26 05:23:20 -06:00
|
|
|
|
|
|
|
/// \brief Wether the Jacobian will also have well contributions in it.
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual bool jacobianContainsWellContributions() const override
|
2018-02-26 05:23:20 -06:00
|
|
|
{
|
|
|
|
return param_.matrix_add_well_contributions_;
|
|
|
|
}
|
2018-08-16 04:51:36 -05:00
|
|
|
|
2017-08-04 04:20:55 -05:00
|
|
|
protected:
|
|
|
|
|
2017-08-07 07:50:03 -05:00
|
|
|
// protected functions from the Base class
|
2017-08-21 04:26:21 -05:00
|
|
|
using Base::getAllowCrossFlow;
|
2017-08-02 09:19:27 -05:00
|
|
|
using Base::phaseUsage;
|
|
|
|
using Base::flowPhaseToEbosCompIdx;
|
2017-12-04 02:14:08 -06:00
|
|
|
using Base::ebosCompIdxToFlowCompIdx;
|
2017-08-02 09:19:27 -05:00
|
|
|
using Base::wsolvent;
|
|
|
|
using Base::wpolymer;
|
2019-07-04 02:50:08 -05:00
|
|
|
using Base::wfoam;
|
2017-08-04 06:07:16 -05:00
|
|
|
using Base::wellHasTHPConstraints;
|
|
|
|
using Base::mostStrictBhpFromBhpLimits;
|
2017-11-23 01:37:30 -06:00
|
|
|
using Base::scalingFactor;
|
2018-11-02 09:21:58 -05:00
|
|
|
using Base::scaleProductivityIndex;
|
2017-07-21 08:30:34 -05:00
|
|
|
|
2017-08-07 07:50:03 -05:00
|
|
|
// protected member variables from the Base class
|
2018-05-18 03:57:08 -05:00
|
|
|
using Base::current_step_;
|
|
|
|
using Base::well_ecl_;
|
2017-08-02 09:19:27 -05:00
|
|
|
using Base::vfp_properties_;
|
|
|
|
using Base::gravity_;
|
2017-10-16 09:46:28 -05:00
|
|
|
using Base::param_;
|
2017-08-02 09:19:27 -05:00
|
|
|
using Base::well_efficiency_factor_;
|
|
|
|
using Base::first_perf_;
|
|
|
|
using Base::ref_depth_;
|
|
|
|
using Base::perf_depth_;
|
2017-08-04 06:07:16 -05:00
|
|
|
using Base::well_cells_;
|
|
|
|
using Base::number_of_perforations_;
|
|
|
|
using Base::number_of_phases_;
|
|
|
|
using Base::saturation_table_number_;
|
|
|
|
using Base::comp_frac_;
|
|
|
|
using Base::well_index_;
|
|
|
|
using Base::index_of_well_;
|
|
|
|
using Base::well_controls_;
|
|
|
|
using Base::well_type_;
|
2017-11-30 09:31:48 -06:00
|
|
|
using Base::num_components_;
|
2018-11-15 07:37:01 -06:00
|
|
|
using Base::connectionRates_;
|
2017-08-02 09:19:27 -05:00
|
|
|
|
|
|
|
using Base::perf_rep_radius_;
|
|
|
|
using Base::perf_length_;
|
|
|
|
using Base::bore_diameters_;
|
2017-07-31 10:11:44 -05:00
|
|
|
|
2019-03-25 06:52:34 -05:00
|
|
|
// total number of the well equations and primary variables
|
|
|
|
// there might be extra equations be used, numWellEq will be updated during the initialization
|
|
|
|
int numWellEq_ = numStaticWellEq;
|
|
|
|
|
2017-06-15 04:41:03 -05:00
|
|
|
// densities of the fluid in each perforation
|
|
|
|
std::vector<double> perf_densities_;
|
|
|
|
// pressure drop between different perforations
|
|
|
|
std::vector<double> perf_pressure_diffs_;
|
|
|
|
|
2017-08-21 03:23:42 -05:00
|
|
|
// residuals of the well equations
|
|
|
|
BVectorWell resWell_;
|
|
|
|
|
2017-06-15 04:41:03 -05:00
|
|
|
// two off-diagonal matrices
|
2017-08-03 08:14:36 -05:00
|
|
|
OffDiagMatWell duneB_;
|
|
|
|
OffDiagMatWell duneC_;
|
2017-06-15 04:41:03 -05:00
|
|
|
// diagonal matrix for the well
|
2017-08-03 08:14:36 -05:00
|
|
|
DiagMatWell invDuneD_;
|
2017-06-21 07:07:11 -05:00
|
|
|
|
|
|
|
// several vector used in the matrix calculation
|
2017-08-03 08:14:36 -05:00
|
|
|
mutable BVectorWell Bx_;
|
|
|
|
mutable BVectorWell invDrw_;
|
2017-06-15 04:41:03 -05:00
|
|
|
|
2017-08-21 08:41:25 -05:00
|
|
|
// the values for the primary varibles
|
|
|
|
// based on different solutioin strategies, the wells can have different primary variables
|
|
|
|
mutable std::vector<double> primary_variables_;
|
2017-08-07 09:45:16 -05:00
|
|
|
|
2017-08-21 08:41:25 -05:00
|
|
|
// the Evaluation for the well primary variables, which contain derivativles and are used in AD calculation
|
|
|
|
mutable std::vector<EvalWell> primary_variables_evaluation_;
|
|
|
|
|
|
|
|
// the saturations in the well bore under surface conditions at the beginning of the time step
|
2017-06-21 07:07:11 -05:00
|
|
|
std::vector<double> F0_;
|
2017-06-15 04:41:03 -05:00
|
|
|
|
2018-11-14 03:46:09 -06:00
|
|
|
// the vectors used to describe the inflow performance relationship (IPR)
|
|
|
|
// Q = IPR_A - BHP * IPR_B
|
|
|
|
// TODO: it minght need to go to WellInterface, let us implement it in StandardWell first
|
|
|
|
// it is only updated and used for producers for now
|
|
|
|
mutable std::vector<double> ipr_a_;
|
|
|
|
mutable std::vector<double> ipr_b_;
|
|
|
|
|
2018-05-09 08:07:43 -05:00
|
|
|
const EvalWell& getBhp() const;
|
2017-06-15 04:41:03 -05:00
|
|
|
|
2017-07-28 06:49:26 -05:00
|
|
|
EvalWell getQs(const int comp_idx) const;
|
2017-06-23 07:55:56 -05:00
|
|
|
|
2018-05-30 08:44:05 -05:00
|
|
|
const EvalWell& getWQTotal() const;
|
2018-05-09 05:16:33 -05:00
|
|
|
|
2017-08-04 06:07:16 -05:00
|
|
|
EvalWell wellVolumeFractionScaled(const int phase) const;
|
|
|
|
|
2017-12-04 02:14:08 -06:00
|
|
|
EvalWell wellVolumeFraction(const unsigned compIdx) const;
|
2017-08-04 06:07:16 -05:00
|
|
|
|
|
|
|
EvalWell wellSurfaceVolumeFraction(const int phase) const;
|
|
|
|
|
|
|
|
EvalWell extendEval(const Eval& in) const;
|
|
|
|
|
|
|
|
// xw = inv(D)*(rw - C*x)
|
|
|
|
void recoverSolutionWell(const BVector& x, BVectorWell& xw) const;
|
|
|
|
|
2017-08-21 07:16:24 -05:00
|
|
|
// updating the well_state based on well solution dwells
|
|
|
|
void updateWellState(const BVectorWell& dwells,
|
2019-02-07 07:43:17 -06:00
|
|
|
WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2017-08-21 07:16:24 -05:00
|
|
|
|
2017-06-23 07:55:56 -05:00
|
|
|
// calculate the properties for the well connections
|
|
|
|
// to calulate the pressure difference between well connections.
|
|
|
|
void computePropertiesForWellConnectionPressures(const Simulator& ebosSimulator,
|
2017-11-30 10:14:29 -06:00
|
|
|
const WellState& well_state,
|
2017-06-23 07:55:56 -05:00
|
|
|
std::vector<double>& b_perf,
|
|
|
|
std::vector<double>& rsmax_perf,
|
|
|
|
std::vector<double>& rvmax_perf,
|
|
|
|
std::vector<double>& surf_dens_perf) const;
|
2017-06-23 08:54:05 -05:00
|
|
|
|
2017-08-07 07:50:03 -05:00
|
|
|
// TODO: not total sure whether it is a good idea to put this function here
|
2017-06-23 08:54:05 -05:00
|
|
|
// the major reason to put here is to avoid the usage of Wells struct
|
|
|
|
void computeConnectionDensities(const std::vector<double>& perfComponentRates,
|
|
|
|
const std::vector<double>& b_perf,
|
|
|
|
const std::vector<double>& rsmax_perf,
|
|
|
|
const std::vector<double>& rvmax_perf,
|
|
|
|
const std::vector<double>& surf_dens_perf);
|
2017-06-23 09:32:43 -05:00
|
|
|
|
|
|
|
void computeConnectionPressureDelta();
|
2017-06-23 09:45:14 -05:00
|
|
|
|
2017-11-30 10:14:29 -06:00
|
|
|
void computeWellConnectionDensitesPressures(const WellState& well_state,
|
2017-06-23 09:45:14 -05:00
|
|
|
const std::vector<double>& b_perf,
|
|
|
|
const std::vector<double>& rsmax_perf,
|
|
|
|
const std::vector<double>& rvmax_perf,
|
|
|
|
const std::vector<double>& surf_dens_perf);
|
2017-06-26 09:01:45 -05:00
|
|
|
|
2018-05-15 09:34:31 -05:00
|
|
|
// computing the accumulation term for later use in well mass equations
|
2017-09-05 04:20:43 -05:00
|
|
|
void computeAccumWell();
|
|
|
|
|
|
|
|
void computeWellConnectionPressures(const Simulator& ebosSimulator,
|
2017-11-30 10:14:29 -06:00
|
|
|
const WellState& well_state);
|
2017-09-05 04:20:43 -05:00
|
|
|
|
2017-08-21 09:40:10 -05:00
|
|
|
void computePerfRate(const IntensiveQuantities& intQuants,
|
2018-12-12 08:58:15 -06:00
|
|
|
const std::vector<EvalWell>& mob,
|
|
|
|
const EvalWell& bhp,
|
2019-03-12 09:51:41 -05:00
|
|
|
const double Tw,
|
2018-12-12 08:58:15 -06:00
|
|
|
const int perf,
|
2018-12-13 06:29:59 -06:00
|
|
|
const bool allow_cf,
|
|
|
|
std::vector<EvalWell>& cq_s,
|
|
|
|
double& perf_dis_gas_rate,
|
2019-02-07 07:43:17 -06:00
|
|
|
double& perf_vap_oil_rate,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2017-08-21 09:40:10 -05:00
|
|
|
|
2019-05-24 09:45:27 -05:00
|
|
|
void computeWellRatesWithBhp(const Simulator& ebosSimulator,
|
2019-04-23 06:30:12 -05:00
|
|
|
const double& bhp,
|
|
|
|
std::vector<double>& well_flux,
|
2019-05-24 09:45:27 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
void computeWellRatesWithBhpPotential(const Simulator& ebosSimulator,
|
|
|
|
const std::vector<Scalar>& B_avg,
|
|
|
|
const double& bhp,
|
|
|
|
std::vector<double>& well_flux,
|
|
|
|
Opm::DeferredLogger& deferred_logger);
|
2017-07-24 07:48:57 -05:00
|
|
|
|
|
|
|
std::vector<double> computeWellPotentialWithTHP(const Simulator& ebosSimulator,
|
2019-04-23 06:30:12 -05:00
|
|
|
const std::vector<Scalar>& B_avg,
|
2017-07-24 07:48:57 -05:00
|
|
|
const double initial_bhp, // bhp from BHP constraints
|
2019-02-07 07:43:17 -06:00
|
|
|
const std::vector<double>& initial_potential,
|
2019-04-23 06:30:12 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger);
|
2017-08-04 06:07:16 -05:00
|
|
|
|
2017-08-11 04:10:59 -05:00
|
|
|
template <class ValueType>
|
2019-02-07 07:43:17 -06:00
|
|
|
ValueType calculateBhpFromThp(const std::vector<ValueType>& rates, const int control_index, Opm::DeferredLogger& deferred_logger) const;
|
2017-08-11 04:10:59 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
double calculateThpFromBhp(const std::vector<double>& rates, const double bhp, Opm::DeferredLogger& deferred_logger) const;
|
2017-08-11 04:10:59 -05:00
|
|
|
|
2017-08-04 06:07:16 -05:00
|
|
|
// get the mobility for specific perforation
|
|
|
|
void getMobility(const Simulator& ebosSimulator,
|
|
|
|
const int perf,
|
2019-02-07 07:43:17 -06:00
|
|
|
std::vector<EvalWell>& mob,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2017-08-31 00:50:28 -05:00
|
|
|
|
2017-11-23 09:10:37 -06:00
|
|
|
void updateWaterMobilityWithPolymer(const Simulator& ebos_simulator,
|
|
|
|
const int perf,
|
2019-02-07 07:43:17 -06:00
|
|
|
std::vector<EvalWell>& mob_water,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2018-05-04 09:25:33 -05:00
|
|
|
|
|
|
|
void updatePrimaryVariablesNewton(const BVectorWell& dwells,
|
|
|
|
const WellState& well_state) const;
|
|
|
|
|
2019-06-06 04:30:25 -05:00
|
|
|
// update extra primary vriables if there are any
|
|
|
|
void updateExtraPrimaryVariables(const BVectorWell& dwells) const;
|
|
|
|
|
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
void updateWellStateFromPrimaryVariables(WellState& well_state, Opm::DeferredLogger& deferred_logger) const;
|
2018-05-09 05:16:33 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
void updateThp(WellState& well_state, Opm::DeferredLogger& deferred_logger) const;
|
2018-05-16 05:44:38 -05:00
|
|
|
|
2019-02-03 01:13:11 -06:00
|
|
|
void assembleControlEq(Opm::DeferredLogger& deferred_logger);
|
2018-05-11 07:58:44 -05:00
|
|
|
|
|
|
|
// handle the non reasonable fractions due to numerical overshoot
|
|
|
|
void processFractions() const;
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2018-11-14 03:46:09 -06:00
|
|
|
// updating the inflow based on the current reservoir condition
|
2019-02-03 01:13:11 -06:00
|
|
|
void updateIPR(const Simulator& ebos_simulator, Opm::DeferredLogger& deferred_logger) const;
|
2018-11-14 03:46:09 -06:00
|
|
|
|
2018-11-22 08:44:09 -06:00
|
|
|
// update the operability status of the well is operable under the current reservoir condition
|
2018-11-15 07:31:41 -06:00
|
|
|
// mostly related to BHP limit and THP limit
|
2018-11-22 00:02:29 -06:00
|
|
|
virtual void checkWellOperability(const Simulator& ebos_simulator,
|
2019-02-03 01:13:11 -06:00
|
|
|
const WellState& well_state,
|
2019-03-25 06:52:34 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) override;
|
2018-11-15 07:31:41 -06:00
|
|
|
|
2018-11-22 08:44:09 -06:00
|
|
|
// check whether the well is operable under the current reservoir condition
|
|
|
|
// mostly related to BHP limit and THP limit
|
|
|
|
void updateWellOperability(const Simulator& ebos_simulator,
|
2019-02-03 01:13:11 -06:00
|
|
|
const WellState& well_state,
|
2019-03-25 06:52:34 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger);
|
2018-11-22 08:44:09 -06:00
|
|
|
|
2018-11-15 07:31:41 -06:00
|
|
|
// check whether the well is operable under BHP limit with current reservoir condition
|
2019-05-24 09:45:27 -05:00
|
|
|
void checkOperabilityUnderBHPLimitProducer(const Simulator& ebos_simulator, Opm::DeferredLogger& deferred_logger);
|
2018-11-15 07:31:41 -06:00
|
|
|
|
|
|
|
// check whether the well is operable under THP limit with current reservoir condition
|
2019-02-03 01:13:11 -06:00
|
|
|
void checkOperabilityUnderTHPLimitProducer(const Simulator& ebos_simulator, Opm::DeferredLogger& deferred_logger);
|
2018-11-15 07:31:41 -06:00
|
|
|
|
2018-11-15 03:08:03 -06:00
|
|
|
// update WellState based on IPR and associated VFP table
|
|
|
|
void updateWellStateWithTHPTargetIPR(const Simulator& ebos_simulator,
|
2019-02-07 07:43:17 -06:00
|
|
|
WellState& well_state,
|
2019-05-24 09:45:27 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2018-11-15 03:08:03 -06:00
|
|
|
|
|
|
|
void updateWellStateWithTHPTargetIPRProducer(const Simulator& ebos_simulator,
|
2019-02-07 07:43:17 -06:00
|
|
|
WellState& well_state,
|
2019-05-24 09:45:27 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2018-11-15 03:08:03 -06:00
|
|
|
|
2018-11-15 07:31:41 -06:00
|
|
|
// for a well, when all drawdown are in the wrong direction, then this well will not
|
|
|
|
// be able to produce/inject .
|
2018-11-17 16:39:09 -06:00
|
|
|
bool allDrawDownWrongDirection(const Simulator& ebos_simulator) const;
|
|
|
|
|
2018-11-22 00:02:29 -06:00
|
|
|
// whether the well can produce / inject based on the current well state (bhp)
|
|
|
|
bool canProduceInjectWithCurrentBhp(const Simulator& ebos_simulator,
|
2019-02-03 01:13:11 -06:00
|
|
|
const WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger);
|
2018-11-22 00:02:29 -06:00
|
|
|
|
2018-11-17 16:39:09 -06:00
|
|
|
// turn on crossflow to avoid singular well equations
|
|
|
|
// when the well is banned from cross-flow and the BHP is not properly initialized,
|
2018-11-20 06:49:11 -06:00
|
|
|
// we turn on crossflow to avoid singular well equations. It can result in wrong-signed
|
2018-11-17 16:39:09 -06:00
|
|
|
// well rates, it can cause problem for THP calculation
|
|
|
|
// TODO: looking for better alternative to avoid wrong-signed well rates
|
|
|
|
bool openCrossFlowAvoidSingularity(const Simulator& ebos_simulator) const;
|
2018-11-15 07:31:41 -06:00
|
|
|
|
2018-11-15 03:08:03 -06:00
|
|
|
// calculate the BHP from THP target based on IPR
|
|
|
|
// TODO: we need to check the operablility here first, if not operable, then maybe there is
|
|
|
|
// no point to do this
|
2019-02-07 07:43:17 -06:00
|
|
|
double calculateBHPWithTHPTargetIPR(Opm::DeferredLogger& deferred_logger) const;
|
2018-11-15 03:08:03 -06:00
|
|
|
|
2018-10-16 06:17:13 -05:00
|
|
|
// relaxation factor considering only one fraction value
|
|
|
|
static double relaxationFactorFraction(const double old_value,
|
|
|
|
const double dx);
|
|
|
|
|
2018-11-08 06:37:17 -06:00
|
|
|
// calculate a relaxation factor to avoid overshoot of the fractions for producers
|
2018-10-16 06:17:13 -05:00
|
|
|
// which might result in negative rates
|
2018-11-08 06:37:17 -06:00
|
|
|
static double relaxationFactorFractionsProducer(const std::vector<double>& primary_variables,
|
2018-10-16 06:17:13 -05:00
|
|
|
const BVectorWell& dwells);
|
|
|
|
|
2018-11-08 06:37:17 -06:00
|
|
|
// calculate a relaxation factor to avoid overshoot of total rates
|
|
|
|
static double relaxationFactorRate(const std::vector<double>& primary_variables,
|
|
|
|
const BVectorWell& dwells);
|
2018-11-22 08:44:09 -06:00
|
|
|
|
2019-04-23 06:30:12 -05:00
|
|
|
virtual void wellTestingPhysical(const Simulator& simulator, const std::vector<double>& B_avg,
|
2019-01-18 07:04:30 -06:00
|
|
|
const double simulation_time, const int report_step,
|
2019-02-03 01:13:11 -06:00
|
|
|
WellState& well_state, WellTestState& welltest_state,
|
2019-06-06 03:40:46 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) override;
|
2019-03-25 06:52:34 -05:00
|
|
|
|
|
|
|
// calculate the skin pressure based on water velocity, throughput and polymer concentration.
|
|
|
|
// throughput is used to describe the formation damage during water/polymer injection.
|
|
|
|
// calculated skin pressure will be applied to the drawdown during perforation rate calculation
|
|
|
|
// to handle the effect from formation damage.
|
|
|
|
EvalWell pskin(const double throuhgput,
|
|
|
|
const EvalWell& water_velocity,
|
|
|
|
const EvalWell& poly_inj_conc,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
// calculate the skin pressure based on water velocity, throughput during water injection.
|
|
|
|
EvalWell pskinwater(const double throughput,
|
|
|
|
const EvalWell& water_velocity,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
// calculate the injecting polymer molecular weight based on the througput and water velocity
|
|
|
|
EvalWell wpolymermw(const double throughput,
|
|
|
|
const EvalWell& water_velocity,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
// handle the extra equations for polymer injectivity study
|
|
|
|
void handleInjectivityRateAndEquations(const IntensiveQuantities& int_quants,
|
|
|
|
const WellState& well_state,
|
|
|
|
const int perf,
|
|
|
|
std::vector<EvalWell>& cq_s,
|
|
|
|
Opm::DeferredLogger& deferred_logger);
|
2018-11-30 05:15:51 -06:00
|
|
|
|
|
|
|
virtual void updateWaterThroughput(const double dt, WellState& well_state) const override;
|
2019-05-09 06:12:32 -05:00
|
|
|
|
2019-06-06 04:12:22 -05:00
|
|
|
// checking the convergence of the well control equations
|
2019-05-09 06:12:32 -05:00
|
|
|
void checkConvergenceControlEq(ConvergenceReport& report,
|
|
|
|
DeferredLogger& deferred_logger) const;
|
|
|
|
|
2019-06-06 04:12:22 -05:00
|
|
|
// checking convergence of extra equations, if there are any
|
|
|
|
void checkConvergenceExtraEqs(const std::vector<double>& res,
|
2019-06-25 14:53:37 -05:00
|
|
|
ConvergenceReport& report) const;
|
2019-06-06 04:12:22 -05:00
|
|
|
|
2019-06-06 04:47:59 -05:00
|
|
|
// updating the connectionRates_ related polymer molecular weight
|
|
|
|
void updateConnectionRatePolyMW(const EvalWell& cq_s_poly,
|
|
|
|
const IntensiveQuantities& int_quants,
|
|
|
|
const WellState& well_state,
|
|
|
|
const int perf,
|
|
|
|
DeferredLogger& deferred_logger);
|
|
|
|
|
2017-06-15 04:41:03 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
#include "StandardWell_impl.hpp"
|
|
|
|
|
2017-06-15 04:41:03 -05:00
|
|
|
#endif // OPM_STANDARDWELL_HEADER_INCLUDED
|