2017-06-15 04:34:07 -05:00
|
|
|
/*
|
2017-08-03 09:45:59 -05:00
|
|
|
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
2017-06-15 04:34:07 -05:00
|
|
|
Copyright 2017 Statoil ASA.
|
2017-11-23 01:37:30 -06:00
|
|
|
Copyright 2017 IRIS
|
2019-08-07 07:13:11 -05:00
|
|
|
Copyright 2019 Norce
|
2017-06-15 04:34:07 -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_WELLINTERFACE_HEADER_INCLUDED
|
|
|
|
#define OPM_WELLINTERFACE_HEADER_INCLUDED
|
|
|
|
|
2017-06-20 03:54:33 -05:00
|
|
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
2018-02-14 15:21:13 -06:00
|
|
|
#include <opm/common/ErrorMacros.hpp>
|
|
|
|
#include <opm/common/Exceptions.hpp>
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
|
2019-03-07 08:13:46 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
|
2019-09-30 05:49:36 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp>
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
#include <opm/core/props/BlackoilPhases.hpp>
|
2019-06-20 03:30:16 -05:00
|
|
|
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
2017-06-15 04:34:07 -05:00
|
|
|
|
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/VFPProperties.hpp>
|
|
|
|
#include <opm/simulators/wells/WellHelpers.hpp>
|
2019-08-07 07:13:11 -05:00
|
|
|
#include <opm/simulators/wells/WellGroupHelpers.hpp>
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp>
|
2019-06-20 02:09:19 -05:00
|
|
|
#include <opm/simulators/flow/BlackoilModelParametersEbos.hpp>
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2018-10-25 04:57:47 -05:00
|
|
|
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/utils/DeferredLogger.hpp>
|
2017-06-27 09:04:04 -05:00
|
|
|
|
2017-07-21 07:21:17 -05:00
|
|
|
#include<dune/common/fmatrix.hh>
|
|
|
|
#include<dune/istl/bcrsmatrix.hh>
|
|
|
|
#include<dune/istl/matrixmatrix.hh>
|
|
|
|
|
|
|
|
#include <opm/material/densead/Math.hpp>
|
|
|
|
#include <opm/material/densead/Evaluation.hpp>
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
class WellInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2017-10-06 03:59:42 -05:00
|
|
|
using WellState = WellStateFullyImplicitBlackoil;
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2018-06-21 05:14:17 -05:00
|
|
|
typedef BlackoilModelParametersEbos<TypeTag> ModelParameters;
|
2017-11-08 06:57:36 -06:00
|
|
|
|
|
|
|
static const int Water = BlackoilPhases::Aqua;
|
|
|
|
static const int Oil = BlackoilPhases::Liquid;
|
|
|
|
static const int Gas = BlackoilPhases::Vapour;
|
|
|
|
|
2017-07-31 09:42:26 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
|
2017-06-19 08:05:15 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
|
2017-12-04 02:14:08 -06:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
|
2017-06-19 09:46:06 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, IntensiveQuantities) IntensiveQuantities;
|
2017-06-21 07:07:11 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
|
2018-11-12 05:40:11 -06:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, SparseMatrixAdapter) SparseMatrixAdapter;
|
2018-08-16 04:51:36 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, RateVector) RateVector;
|
2017-06-19 08:05:15 -05:00
|
|
|
|
2017-12-04 02:14:08 -06:00
|
|
|
static const int numEq = Indices::numEq;
|
2017-07-21 07:21:17 -05:00
|
|
|
typedef double Scalar;
|
|
|
|
|
|
|
|
typedef Dune::FieldVector<Scalar, numEq > VectorBlockType;
|
|
|
|
typedef Dune::FieldMatrix<Scalar, numEq, numEq > MatrixBlockType;
|
|
|
|
typedef Dune::BlockVector<VectorBlockType> BVector;
|
|
|
|
typedef DenseAd::Evaluation<double, /*size=*/numEq> Eval;
|
|
|
|
|
2017-06-19 09:46:06 -05:00
|
|
|
static const bool has_solvent = GET_PROP_VALUE(TypeTag, EnableSolvent);
|
2017-07-25 05:10:13 -05:00
|
|
|
static const bool has_polymer = GET_PROP_VALUE(TypeTag, EnablePolymer);
|
2018-03-26 03:50:33 -05:00
|
|
|
static const bool has_energy = GET_PROP_VALUE(TypeTag, EnableEnergy);
|
2019-10-09 08:24:23 -05:00
|
|
|
static const bool has_temperature = GET_PROP_VALUE(TypeTag, EnableTemperature);
|
2018-11-28 07:24:29 -06:00
|
|
|
// flag for polymer molecular weight related
|
|
|
|
static const bool has_polymermw = GET_PROP_VALUE(TypeTag, EnablePolymerMW);
|
2019-07-04 02:50:08 -05:00
|
|
|
static const bool has_foam = GET_PROP_VALUE(TypeTag, EnableFoam);
|
2019-12-03 10:48:17 -06:00
|
|
|
static const bool has_brine = GET_PROP_VALUE(TypeTag, EnableBrine);
|
2017-12-04 02:14:08 -06:00
|
|
|
static const int contiSolventEqIdx = Indices::contiSolventEqIdx;
|
|
|
|
static const int contiPolymerEqIdx = Indices::contiPolymerEqIdx;
|
2018-11-28 07:24:29 -06:00
|
|
|
// index for the polymer molecular weight continuity equation
|
|
|
|
static const int contiPolymerMWEqIdx = Indices::contiPolymerMWEqIdx;
|
2019-07-04 02:50:08 -05:00
|
|
|
static const int contiFoamEqIdx = Indices::contiFoamEqIdx;
|
2019-12-03 10:48:17 -06:00
|
|
|
static const int contiBrineEqIdx = Indices::contiBrineEqIdx;
|
2017-11-23 01:37:30 -06:00
|
|
|
|
2019-07-04 02:50:08 -05:00
|
|
|
// For the conversion between the surface volume rate and reservoir voidage rate
|
2017-11-23 01:37:30 -06:00
|
|
|
using RateConverterType = RateConverter::
|
|
|
|
SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
|
2019-10-09 08:24:23 -05:00
|
|
|
static const bool compositionSwitchEnabled = Indices::gasEnabled;
|
|
|
|
using FluidState = Opm::BlackOilFluidState<Eval,
|
2019-10-11 08:57:51 -05:00
|
|
|
FluidSystem,
|
|
|
|
has_temperature,
|
|
|
|
has_energy,
|
|
|
|
compositionSwitchEnabled,
|
2019-12-03 10:48:17 -06:00
|
|
|
has_brine,
|
2019-10-11 08:57:51 -05:00
|
|
|
Indices::numPhases >;
|
2017-06-15 04:34:07 -05:00
|
|
|
/// Constructor
|
2019-10-23 02:09:45 -05:00
|
|
|
WellInterface(const Well& well, const int time_step,
|
2017-11-23 01:37:30 -06:00
|
|
|
const ModelParameters& param,
|
|
|
|
const RateConverterType& rate_converter,
|
2017-11-30 09:31:48 -06:00
|
|
|
const int pvtRegionIdx,
|
2019-10-23 02:09:45 -05:00
|
|
|
const int num_components,
|
|
|
|
const int num_phases,
|
|
|
|
const int index_of_well,
|
|
|
|
const int first_perf_index,
|
|
|
|
const std::vector<PerforationData>& perf_data);
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2017-08-22 02:43:26 -05:00
|
|
|
/// Virutal destructor
|
|
|
|
virtual ~WellInterface() {}
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
/// Well name.
|
|
|
|
const std::string& name() const;
|
|
|
|
|
2019-10-23 02:09:45 -05:00
|
|
|
/// True if the well is an injector.
|
|
|
|
bool isInjector() const;
|
|
|
|
|
|
|
|
/// True if the well is a producer.
|
|
|
|
bool isProducer() const;
|
|
|
|
|
2018-06-06 08:17:59 -05:00
|
|
|
/// Index of well in the wells struct and wellState
|
2019-04-24 10:21:07 -05:00
|
|
|
int indexOfWell() const;
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2017-10-02 07:18:33 -05:00
|
|
|
/// Well cells.
|
2018-08-16 04:51:36 -05:00
|
|
|
const std::vector<int>& cells() const {return well_cells_; }
|
2017-10-02 07:18:33 -05:00
|
|
|
|
2018-11-13 03:45:02 -06:00
|
|
|
void setVFPProperties(const VFPProperties<VFPInjProperties,VFPProdProperties>* vfp_properties_arg);
|
2017-08-07 07:50:03 -05:00
|
|
|
|
2019-09-30 05:49:36 -05:00
|
|
|
void setGuideRate(const GuideRate* guide_rate_arg);
|
|
|
|
|
2017-06-28 08:20:25 -05:00
|
|
|
virtual void init(const PhaseUsage* phase_usage_arg,
|
2017-08-01 09:11:55 -05:00
|
|
|
const std::vector<double>& depth_arg,
|
2017-06-28 08:20:25 -05:00
|
|
|
const double gravity_arg,
|
|
|
|
const int num_cells);
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2017-08-21 08:41:25 -05:00
|
|
|
virtual void initPrimaryVariablesEvaluation() const = 0;
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
virtual ConvergenceReport getWellConvergence(const WellState& well_state, const std::vector<double>& B_avg, Opm::DeferredLogger& deferred_logger) const = 0;
|
2017-06-26 07:35:43 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
virtual void solveEqAndUpdateWellState(WellState& well_state, Opm::DeferredLogger& deferred_logger) = 0;
|
2017-06-26 09:01:45 -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
|
|
|
|
) = 0;
|
2017-06-27 05:17:36 -05:00
|
|
|
|
2018-06-28 06:47:10 -05:00
|
|
|
void updateWellTestState(const WellState& well_state,
|
|
|
|
const double& simulationTime,
|
2018-10-29 08:01:41 -05:00
|
|
|
const bool& writeMessageToOPMLog,
|
2019-02-03 01:13:11 -06:00
|
|
|
WellTestState& wellTestState,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2017-06-28 04:15:04 -05:00
|
|
|
|
2017-08-03 10:30:47 -05:00
|
|
|
void setWellEfficiencyFactor(const double efficiency_factor);
|
2017-06-28 04:15:04 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
void computeRepRadiusPerfLength(const Grid& grid, const std::vector<int>& cartesian_to_compressed, Opm::DeferredLogger& deferred_logger);
|
2017-06-29 06:52:31 -05:00
|
|
|
|
2017-08-22 07:49:30 -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 = 0;
|
2017-06-29 06:52:31 -05:00
|
|
|
|
2017-08-22 07:49:30 -05:00
|
|
|
/// Ax = Ax - C D^-1 B x
|
2017-07-21 07:21:17 -05:00
|
|
|
virtual void apply(const BVector& x, BVector& Ax) const = 0;
|
|
|
|
|
2017-08-22 07:49:30 -05:00
|
|
|
/// r = r - C D^-1 Rw
|
2017-07-21 07:21:17 -05:00
|
|
|
virtual void apply(BVector& r) const = 0;
|
|
|
|
|
2017-09-05 04:09:58 -05:00
|
|
|
// TODO: before we decide to put more information under mutable, this function is not const
|
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) = 0;
|
2017-07-24 07:48:57 -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 = 0;
|
2017-07-31 09:42:26 -05:00
|
|
|
|
2019-05-10 07:56:20 -05:00
|
|
|
void updateWellControl(const Simulator& ebos_simulator,
|
2018-11-15 03:08:03 -06:00
|
|
|
WellState& well_state,
|
2019-01-21 01:26:28 -06:00
|
|
|
Opm::DeferredLogger& deferred_logger) /* const */;
|
2017-07-31 09:42:26 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
virtual void updatePrimaryVariables(const WellState& well_state, Opm::DeferredLogger& deferred_logger) const = 0;
|
2017-08-07 10:49:35 -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) = 0; // should be const?
|
2017-09-05 04:09:58 -05:00
|
|
|
|
2018-02-26 05:23:20 -06:00
|
|
|
/// \brief Wether the Jacobian will also have well contributions in it.
|
|
|
|
virtual bool jacobianContainsWellContributions() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-05-15 07:46:43 -05:00
|
|
|
|
2018-02-14 06:34:35 -06:00
|
|
|
// updating the voidage rates in well_state when requested
|
|
|
|
void calculateReservoirRates(WellState& well_state) const;
|
|
|
|
|
2018-03-05 09:39:25 -06:00
|
|
|
// Add well contributions to matrix
|
2019-10-02 05:48:29 -05:00
|
|
|
virtual void addWellContributions(SparseMatrixAdapter&) const = 0;
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2018-11-15 07:37:01 -06:00
|
|
|
void addCellRates(RateVector& rates, int cellIdx) const;
|
2018-08-16 04:51:36 -05:00
|
|
|
|
2018-11-14 06:18:48 -06:00
|
|
|
Scalar volumetricSurfaceRateForConnection(int cellIdx, int phaseIdx) const;
|
|
|
|
|
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
template <class EvalWell>
|
|
|
|
Eval restrictEval(const EvalWell& in) const
|
|
|
|
{
|
|
|
|
Eval out = 0.0;
|
|
|
|
out.setValue(in.value());
|
|
|
|
for(int eqIdx = 0; eqIdx < numEq;++eqIdx) {
|
|
|
|
out.setDerivative(eqIdx, in.derivative(eqIdx));
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2018-07-03 08:13:30 -05:00
|
|
|
void closeCompletions(WellTestState& wellTestState);
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
const Well& wellEcl() const;
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2018-10-31 08:56:56 -05:00
|
|
|
// TODO: theoretically, it should be a const function
|
|
|
|
// Simulator is not const is because that assembleWellEq is non-const Simulator
|
2019-04-23 06:30:12 -05:00
|
|
|
void wellTesting(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,
|
2018-11-22 08:44:09 -06:00
|
|
|
const WellTestConfig::Reason testing_reason,
|
2018-11-23 16:46:56 -06:00
|
|
|
/* const */ WellState& well_state, WellTestState& welltest_state,
|
2019-01-21 01:26:28 -06:00
|
|
|
Opm::DeferredLogger& deferred_logger);
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2018-11-15 07:37:01 -06:00
|
|
|
void updatePerforatedCell(std::vector<bool>& is_cell_perforated);
|
|
|
|
|
2019-05-24 09:45:27 -05:00
|
|
|
virtual void checkWellOperability(const Simulator& ebos_simulator, const WellState& well_state, Opm::DeferredLogger& deferred_logger) = 0;
|
2018-11-15 07:37:01 -06:00
|
|
|
|
2018-11-17 16:14:51 -06:00
|
|
|
// whether the well is operable
|
|
|
|
bool isOperable() const;
|
|
|
|
|
2018-11-22 04:01:58 -06:00
|
|
|
/// Returns true if the well has one or more THP limits/constraints.
|
2019-08-07 07:13:11 -05:00
|
|
|
bool wellHasTHPConstraints(const SummaryState& summaryState) const;
|
2018-11-22 04:01:58 -06:00
|
|
|
|
2018-11-23 05:51:13 -06:00
|
|
|
/// Returns true if the well is currently in prediction mode (i.e. not history mode).
|
2019-06-25 14:53:37 -05:00
|
|
|
bool underPredictionMode() const;
|
2018-11-23 05:51:13 -06:00
|
|
|
|
2018-11-30 05:15:51 -06:00
|
|
|
// update perforation water throughput based on solved water rate
|
|
|
|
virtual void updateWaterThroughput(const double dt, WellState& well_state) const = 0;
|
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
void stopWell() {
|
|
|
|
wellIsStopped_ = true;
|
|
|
|
}
|
|
|
|
void openWell() {
|
|
|
|
wellIsStopped_ = false;
|
|
|
|
}
|
|
|
|
|
2019-10-03 09:44:44 -05:00
|
|
|
bool wellIsStopped() const {
|
2019-08-07 07:13:11 -05:00
|
|
|
return wellIsStopped_;
|
|
|
|
}
|
|
|
|
|
2019-09-23 08:15:55 -05:00
|
|
|
void setWsolvent(const double wsolvent);
|
|
|
|
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
protected:
|
2017-07-25 05:10:13 -05:00
|
|
|
|
2018-06-28 06:47:10 -05:00
|
|
|
// to indicate a invalid completion
|
2018-07-02 04:06:51 -05:00
|
|
|
static const int INVALIDCOMPLETION = INT_MAX;
|
2017-07-25 09:41:25 -05:00
|
|
|
|
2019-11-18 09:33:10 -06:00
|
|
|
Well well_ecl_;
|
2017-07-25 05:10:13 -05:00
|
|
|
|
|
|
|
const int current_step_;
|
|
|
|
|
2017-10-16 09:46:28 -05:00
|
|
|
// simulation parameters
|
|
|
|
const ModelParameters& param_;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
// number of the perforations for this well
|
|
|
|
int number_of_perforations_;
|
|
|
|
|
|
|
|
// well index for each perforation
|
|
|
|
std::vector<double> well_index_;
|
|
|
|
|
|
|
|
// depth for each perforation
|
|
|
|
std::vector<double> perf_depth_;
|
|
|
|
|
2017-06-23 09:32:43 -05:00
|
|
|
// reference depth for the BHP
|
2017-07-19 04:51:19 -05:00
|
|
|
double ref_depth_;
|
2017-06-23 09:32:43 -05:00
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
double well_efficiency_factor_;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
// cell index for each well perforation
|
2017-08-04 06:07:16 -05:00
|
|
|
std::vector<int> well_cells_;
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
// saturation table nubmer for each well perforation
|
|
|
|
std::vector<int> saturation_table_number_;
|
|
|
|
|
2017-07-31 09:42:26 -05:00
|
|
|
// representative radius of the perforations, used in shear calculation
|
|
|
|
std::vector<double> perf_rep_radius_;
|
|
|
|
|
|
|
|
// length of the perforations, use in shear calculation
|
|
|
|
std::vector<double> perf_length_;
|
|
|
|
|
|
|
|
// well bore diameter
|
|
|
|
std::vector<double> bore_diameters_;
|
|
|
|
|
2019-06-20 02:07:20 -05:00
|
|
|
/*
|
|
|
|
* completions_ contains the mapping from completion id to connection indices
|
|
|
|
* {
|
2019-06-21 04:19:09 -05:00
|
|
|
* 2 : [ConnectionIndex, ConnectionIndex],
|
|
|
|
* 1 : [ConnectionIndex, ConnectionIndex, ConnectionIndex],
|
2019-06-20 02:07:20 -05:00
|
|
|
* 5 : [ConnectionIndex],
|
|
|
|
* 7 : [ConnectionIndex]
|
|
|
|
* ...
|
|
|
|
* }
|
2019-06-21 04:19:09 -05:00
|
|
|
* The integer IDs correspond to the COMPLETION id given by the COMPLUMP keyword.
|
2019-06-20 02:07:20 -05:00
|
|
|
* When there is no COMPLUMP keyword used, a default completion number will be assigned
|
2019-06-24 14:02:47 -05:00
|
|
|
* based on the order of the declaration of the connections.
|
|
|
|
* Since the connections not OPEN is not included in the Wells, so they will not be considered
|
|
|
|
* in this mapping relation.
|
2019-06-20 02:07:20 -05:00
|
|
|
*/
|
|
|
|
std::map<int, std::vector<int>> completions_;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
const PhaseUsage* phase_usage_;
|
|
|
|
|
2017-08-21 04:26:21 -05:00
|
|
|
bool getAllowCrossFlow() const;
|
|
|
|
|
2018-11-13 03:45:02 -06:00
|
|
|
const VFPProperties<VFPInjProperties,VFPProdProperties>* vfp_properties_;
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2019-09-30 05:49:36 -05:00
|
|
|
const GuideRate* guide_rate_;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
double gravity_;
|
2017-07-24 07:48:57 -05:00
|
|
|
|
2017-11-23 01:37:30 -06:00
|
|
|
// For the conversion between the surface volume rate and resrevoir voidage rate
|
|
|
|
const RateConverterType& rateConverter_;
|
|
|
|
|
|
|
|
// The pvt region of the well. We assume
|
|
|
|
// We assume a well to not penetrate more than one pvt region.
|
2017-11-23 04:15:50 -06:00
|
|
|
const int pvtRegionIdx_;
|
2017-11-23 01:37:30 -06:00
|
|
|
|
2017-11-30 09:31:48 -06:00
|
|
|
const int num_components_;
|
|
|
|
|
2019-10-23 02:09:45 -05:00
|
|
|
// number of phases
|
|
|
|
int number_of_phases_;
|
|
|
|
|
|
|
|
// the index of well in Wells struct
|
|
|
|
int index_of_well_;
|
|
|
|
|
|
|
|
// record the index of the first perforation
|
|
|
|
// of states of individual well.
|
|
|
|
int first_perf_;
|
|
|
|
|
|
|
|
std::vector<int> originalConnectionIndex_;
|
|
|
|
|
2018-11-15 07:37:01 -06:00
|
|
|
std::vector<RateVector> connectionRates_;
|
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
bool wellIsStopped_;
|
|
|
|
|
2019-09-23 08:15:55 -05:00
|
|
|
double wsolvent_;
|
|
|
|
|
2017-08-21 04:26:21 -05:00
|
|
|
const PhaseUsage& phaseUsage() const;
|
|
|
|
|
|
|
|
int flowPhaseToEbosCompIdx( const int phaseIdx ) const;
|
|
|
|
|
2017-12-04 02:14:08 -06:00
|
|
|
int ebosCompIdxToFlowCompIdx( const unsigned compIdx ) const;
|
2017-08-21 04:26:21 -05:00
|
|
|
|
|
|
|
double wsolvent() const;
|
|
|
|
|
|
|
|
double wpolymer() const;
|
|
|
|
|
2019-07-04 02:50:08 -05:00
|
|
|
double wfoam() const;
|
|
|
|
|
2019-11-07 02:39:42 -06:00
|
|
|
double wsalt() const;
|
|
|
|
|
2017-08-21 04:26:21 -05:00
|
|
|
bool checkRateEconLimits(const WellEconProductionLimits& econ_production_limits,
|
2019-02-03 01:13:11 -06:00
|
|
|
const WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2017-08-21 04:26:21 -05:00
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
double getTHPConstraint(const SummaryState& summaryState) const;
|
2018-11-15 01:57:47 -06:00
|
|
|
|
2017-08-03 10:30:47 -05:00
|
|
|
// Component fractions for each phase for the well
|
|
|
|
const std::vector<double>& compFrac() const;
|
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
double mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const;
|
2017-07-26 08:31:44 -05:00
|
|
|
|
2019-07-02 03:51:28 -05:00
|
|
|
struct RatioLimitCheckReport;
|
2017-07-26 08:31:44 -05:00
|
|
|
|
2019-07-02 03:51:28 -05:00
|
|
|
void checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
|
|
|
|
const WellState& well_state,
|
|
|
|
RatioLimitCheckReport& report) const;
|
2017-07-26 08:31:44 -05:00
|
|
|
|
2019-06-27 16:25:25 -05:00
|
|
|
void checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits,
|
|
|
|
const WellState& well_state,
|
|
|
|
RatioLimitCheckReport& report) const;
|
|
|
|
|
2019-07-03 07:13:57 -05:00
|
|
|
void checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits,
|
|
|
|
const WellState& well_state,
|
|
|
|
RatioLimitCheckReport& report) const;
|
|
|
|
|
2019-07-02 03:51:28 -05:00
|
|
|
void checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
|
|
|
|
const WellState& well_state,
|
|
|
|
RatioLimitCheckReport& report,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2017-07-26 08:31:44 -05:00
|
|
|
|
2019-06-27 16:25:25 -05:00
|
|
|
|
2019-06-24 07:02:08 -05:00
|
|
|
template <typename RatioFunc>
|
2019-06-21 04:19:09 -05:00
|
|
|
bool checkMaxRatioLimitWell(const WellState& well_state,
|
2019-06-21 03:46:05 -05:00
|
|
|
const double max_ratio_limit,
|
2019-06-24 07:02:08 -05:00
|
|
|
const RatioFunc& ratioFunc) const;
|
2019-06-21 03:46:05 -05:00
|
|
|
|
2019-06-24 07:02:08 -05:00
|
|
|
template <typename RatioFunc>
|
2019-06-21 04:19:09 -05:00
|
|
|
void checkMaxRatioLimitCompletions(const WellState& well_state,
|
|
|
|
const double max_ratio_limit,
|
2019-06-24 07:02:08 -05:00
|
|
|
const RatioFunc& ratioFunc,
|
2019-07-02 03:51:28 -05:00
|
|
|
RatioLimitCheckReport& report) const;
|
2019-06-21 04:19:09 -05:00
|
|
|
|
2017-11-23 01:37:30 -06:00
|
|
|
double scalingFactor(const int comp_idx) const;
|
|
|
|
|
2018-11-13 04:19:53 -06:00
|
|
|
// whether a well is specified with a non-zero and valid VFP table number
|
2019-02-07 07:43:17 -06:00
|
|
|
bool isVFPActive(Opm::DeferredLogger& deferred_logger) const;
|
2018-11-13 04:19:53 -06:00
|
|
|
|
2018-11-15 05:55:30 -06:00
|
|
|
struct OperabilityStatus;
|
|
|
|
|
|
|
|
OperabilityStatus operability_status_;
|
|
|
|
|
2019-04-23 06:30:12 -05:00
|
|
|
void wellTestingEconomic(const Simulator& simulator, const std::vector<double>& B_avg,
|
2019-06-25 14:53:37 -05:00
|
|
|
const double simulation_time, const WellState& well_state,
|
|
|
|
WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger);
|
2018-10-31 09:32:50 -05: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-01-21 01:26:28 -06:00
|
|
|
WellState& well_state, WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger) = 0;
|
2018-11-22 08:44:09 -06:00
|
|
|
|
2018-10-31 09:32:50 -05:00
|
|
|
void updateWellTestStateEconomic(const WellState& well_state,
|
|
|
|
const double simulation_time,
|
|
|
|
const bool write_message_to_opmlog,
|
2019-02-03 01:13:11 -06:00
|
|
|
WellTestState& well_test_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2018-10-31 09:32:50 -05:00
|
|
|
|
2018-11-17 16:30:27 -06:00
|
|
|
void updateWellTestStatePhysical(const WellState& well_state,
|
|
|
|
const double simulation_time,
|
|
|
|
const bool write_message_to_opmlog,
|
2019-02-03 01:13:11 -06:00
|
|
|
WellTestState& well_test_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2018-11-17 16:30:27 -06:00
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
void solveWellForTesting(const Simulator& ebosSimulator, WellState& well_state,
|
|
|
|
const std::vector<double>& B_avg,
|
|
|
|
Opm::DeferredLogger& deferred_logger);
|
2018-11-22 08:44:09 -06:00
|
|
|
|
2019-04-23 06:30:12 -05:00
|
|
|
bool solveWellEqUntilConverged(const Simulator& ebosSimulator,
|
2018-11-23 16:46:56 -06:00
|
|
|
const std::vector<double>& B_avg,
|
|
|
|
WellState& well_state,
|
2019-01-21 01:26:28 -06:00
|
|
|
Opm::DeferredLogger& deferred_logger);
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2019-03-21 05:45:50 -05:00
|
|
|
void scaleProductivityIndex(const int perfIdx, double& productivity_index, const bool new_well, Opm::DeferredLogger& deferred_logger);
|
2018-11-30 06:37:04 -06:00
|
|
|
|
2019-06-20 02:07:20 -05:00
|
|
|
void initCompletions();
|
|
|
|
|
2018-11-30 06:37:04 -06:00
|
|
|
// count the number of times an output log message is created in the productivity
|
|
|
|
// index calculations
|
|
|
|
int well_productivity_index_logger_counter_;
|
2018-11-02 09:21:58 -05:00
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
bool checkConstraints(WellState& well_state, const SummaryState& summaryState);
|
2018-11-15 07:37:01 -06:00
|
|
|
|
2019-09-23 08:15:55 -05:00
|
|
|
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
};
|
|
|
|
|
2018-11-15 05:55:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
|
2018-11-15 05:55:30 -06:00
|
|
|
// definition of the struct OperabilityStatus
|
|
|
|
template<typename TypeTag>
|
|
|
|
struct
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
OperabilityStatus {
|
|
|
|
bool isOperable() const {
|
|
|
|
if (!operable_under_only_bhp_limit) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2018-11-24 15:22:50 -06:00
|
|
|
return ( (isOperableUnderBHPLimit() || isOperableUnderTHPLimit()) );
|
2018-11-15 05:55:30 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isOperableUnderBHPLimit() const {
|
2018-11-18 08:08:17 -06:00
|
|
|
return operable_under_only_bhp_limit && obey_thp_limit_under_bhp_limit;
|
2018-11-15 05:55:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isOperableUnderTHPLimit() const {
|
2018-11-20 06:49:11 -06:00
|
|
|
return can_obtain_bhp_with_thp_limit && obey_bhp_limit_with_thp_limit;
|
2018-11-15 05:55:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void reset() {
|
|
|
|
operable_under_only_bhp_limit = true;
|
2018-11-18 08:08:17 -06:00
|
|
|
obey_thp_limit_under_bhp_limit = true;
|
2018-11-20 06:49:11 -06:00
|
|
|
can_obtain_bhp_with_thp_limit = true;
|
2018-11-18 08:08:17 -06:00
|
|
|
obey_bhp_limit_with_thp_limit = true;
|
2018-11-15 05:55:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// whether the well can be operated under bhp limit
|
|
|
|
// without considering other limits.
|
|
|
|
// if it is false, then the well is not operable for sure.
|
|
|
|
bool operable_under_only_bhp_limit = true;
|
2018-11-18 08:08:17 -06:00
|
|
|
// if the well can be operated under bhp limit, will it obey(not violate)
|
2018-11-15 05:55:30 -06:00
|
|
|
// the thp limit when operated under bhp limit
|
2018-11-18 08:08:17 -06:00
|
|
|
bool obey_thp_limit_under_bhp_limit = true;
|
2018-11-15 05:55:30 -06:00
|
|
|
// whether the well operate under the thp limit only
|
2018-11-20 06:49:11 -06:00
|
|
|
bool can_obtain_bhp_with_thp_limit = true;
|
2018-11-18 08:08:17 -06:00
|
|
|
// whether the well obey bhp limit when operated under thp limit
|
|
|
|
bool obey_bhp_limit_with_thp_limit = true;
|
2018-11-30 06:37:04 -06:00
|
|
|
|
2018-11-15 05:55:30 -06:00
|
|
|
};
|
2019-07-02 03:51:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
struct
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
RatioLimitCheckReport{
|
|
|
|
bool ratio_limit_violated = false;
|
|
|
|
int worst_offending_completion = INVALIDCOMPLETION;
|
|
|
|
double violation_extent = 0.0;
|
|
|
|
};
|
|
|
|
|
2019-01-18 07:04:30 -06:00
|
|
|
const std::string modestring[4] = { "BHP", "THP", "RESERVOIR_RATE", "SURFACE_RATE" };
|
2018-11-15 05:55:30 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
#include "WellInterface_impl.hpp"
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
#endif // OPM_WELLINTERFACE_HEADER_INCLUDED
|