24 #ifndef OPM_WELLINTERFACE_HEADER_INCLUDED
25 #define OPM_WELLINTERFACE_HEADER_INCLUDED
27 #include <opm/common/OpmLog/OpmLog.hpp>
28 #include <opm/common/ErrorMacros.hpp>
29 #include <opm/common/Exceptions.hpp>
31 #include <opm/input/eclipse/Schedule/Well/Well.hpp>
32 #include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
34 #include <opm/core/props/BlackoilPhases.hpp>
36 #include <opm/simulators/wells/WellProdIndexCalculator.hpp>
37 #include <opm/simulators/wells/WellState.hpp>
42 template<
typename TypeTag>
class GasLiftSingleWell;
43 template<
typename TypeTag>
class BlackoilWellModel;
45 #include <opm/simulators/wells/GasLiftGroupInfo.hpp>
46 #include <opm/simulators/wells/GasLiftSingleWell.hpp>
47 #include <opm/simulators/wells/GasLiftSingleWellGeneric.hpp>
48 #include <opm/simulators/wells/BlackoilWellModel.hpp>
49 #include <opm/simulators/flow/BlackoilModelParametersEbos.hpp>
51 #include <opm/simulators/utils/DeferredLogger.hpp>
53 #include<dune/common/fmatrix.hh>
54 #include<dune/istl/bcrsmatrix.hh>
55 #include<dune/istl/matrixmatrix.hh>
57 #include <opm/material/densead/Evaluation.hpp>
59 #include <opm/simulators/wells/WellInterfaceIndices.hpp>
60 #include <opm/simulators/timestepping/ConvergenceReport.hpp>
68 template<
typename TypeTag>
70 GetPropType<TypeTag, Properties::Indices>,
71 GetPropType<TypeTag, Properties::Scalar>>
77 using Grid = GetPropType<TypeTag, Properties::Grid>;
78 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
79 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
80 using Indices = GetPropType<TypeTag, Properties::Indices>;
81 using IntensiveQuantities = GetPropType<TypeTag, Properties::IntensiveQuantities>;
82 using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
83 using SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>;
84 using RateVector = GetPropType<TypeTag, Properties::RateVector>;
86 using GLiftOptWells =
typename BlackoilWellModel<TypeTag>::GLiftOptWells;
87 using GLiftProdWells =
typename BlackoilWellModel<TypeTag>::GLiftProdWells;
88 using GLiftWellStateMap =
89 typename BlackoilWellModel<TypeTag>::GLiftWellStateMap;
90 using GLiftSyncGroups =
typename GasLiftSingleWellGeneric::GLiftSyncGroups;
92 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
94 using VectorBlockType = Dune::FieldVector<Scalar, Indices::numEq>;
95 using MatrixBlockType = Dune::FieldMatrix<Scalar, Indices::numEq, Indices::numEq>;
96 using BVector = Dune::BlockVector<VectorBlockType>;
97 using Eval = DenseAd::Evaluation<Scalar, Indices::numEq>;
99 using RateConverterType =
107 static constexpr
bool has_solvent = getPropValue<TypeTag, Properties::EnableSolvent>();
108 static constexpr
bool has_zFraction = getPropValue<TypeTag, Properties::EnableExtbo>();
109 static constexpr
bool has_polymer = getPropValue<TypeTag, Properties::EnablePolymer>();
110 static constexpr
bool has_energy = getPropValue<TypeTag, Properties::EnableEnergy>();
111 static const bool has_temperature = getPropValue<TypeTag, Properties::EnableTemperature>();
113 static constexpr
bool has_polymermw = getPropValue<TypeTag, Properties::EnablePolymerMW>();
114 static constexpr
bool has_foam = getPropValue<TypeTag, Properties::EnableFoam>();
115 static constexpr
bool has_brine = getPropValue<TypeTag, Properties::EnableBrine>();
116 static constexpr
bool has_watVapor = getPropValue<TypeTag, Properties::EnableEvaporation>();
117 static constexpr
bool has_saltPrecip = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>();
118 static constexpr
bool has_micp = getPropValue<TypeTag, Properties::EnableMICP>();
121 using FluidState = BlackOilFluidState<Eval,
125 Indices::compositionSwitchIdx >= 0,
129 Indices::numPhases >;
135 const RateConverterType& rate_converter,
136 const int pvtRegionIdx,
137 const int num_components,
138 const int num_phases,
139 const int index_of_well,
140 const std::vector<PerforationData>& perf_data);
145 virtual void init(
const PhaseUsage* phase_usage_arg,
146 const std::vector<double>& depth_arg,
147 const double gravity_arg,
149 const std::vector< Scalar >& B_avg);
151 virtual void initPrimaryVariablesEvaluation()
const = 0;
157 void assembleWellEq(
const Simulator& ebosSimulator,
163 virtual void computeWellRatesWithBhp(
164 const Simulator& ebosSimulator,
166 std::vector<double>& well_flux,
170 virtual std::optional<double> computeBhpAtThpLimitProdWithAlq(
171 const Simulator& ebos_simulator,
172 const SummaryState& summary_state,
184 virtual void apply(
const BVector& x, BVector& Ax)
const = 0;
187 virtual void apply(BVector& r)
const = 0;
190 virtual void computeWellPotentials(
const Simulator& ebosSimulator,
192 std::vector<double>& well_potentials,
195 virtual void updateWellStateWithTarget(
const Simulator& ebos_simulator,
200 enum class IndividualOrGroup { Individual, Group, Both };
201 bool updateWellControl(
const Simulator& ebos_simulator,
202 const IndividualOrGroup iog,
209 virtual void calculateExplicitQuantities(
const Simulator& ebosSimulator,
213 virtual void updateProductivityIndex(
const Simulator& ebosSimulator,
225 virtual void addWellContributions(SparseMatrixAdapter&)
const = 0;
227 void addCellRates(RateVector& rates,
int cellIdx)
const;
229 Scalar volumetricSurfaceRateForConnection(
int cellIdx,
int phaseIdx)
const;
231 template <
class EvalWell>
232 Eval restrictEval(
const EvalWell& in)
const
235 out.setValue(in.value());
236 for (
int eqIdx = 0; eqIdx < Indices::numEq; ++eqIdx) {
237 out.setDerivative(eqIdx, in.derivative(eqIdx));
244 void wellTesting(
const Simulator& simulator,
245 const double simulation_time,
246 WellState& well_state,
const GroupState& group_state, WellTestState& welltest_state,
247 DeferredLogger& deferred_logger);
249 void checkWellOperability(
const Simulator& ebos_simulator,
const WellState& well_state, DeferredLogger& deferred_logger);
253 void updateWellOperability(
const Simulator& ebos_simulator,
254 const WellState& well_state,
255 DeferredLogger& deferred_logger);
259 virtual void updateWaterThroughput(
const double dt, WellState& well_state)
const = 0;
273 void solveWellEquation(
const Simulator& ebosSimulator,
283 std::vector<RateVector> connectionRates_;
285 std::vector< Scalar > B_avg_;
287 bool changed_to_stopped_this_step_ =
false;
289 double wpolymer()
const;
291 double wfoam()
const;
293 double wsalt()
const;
295 double wmicrobes()
const;
297 double woxygen()
const;
299 double wurea()
const;
301 virtual double getRefDensity()
const = 0;
304 const std::vector<double>& compFrac()
const;
306 std::vector<double> initialWellRateFractions(
const Simulator& ebosSimulator,
const WellState& well_state)
const;
309 virtual void checkOperabilityUnderBHPLimit(
const WellState& well_state,
const Simulator& ebos_simulator,
DeferredLogger& deferred_logger) =0;
312 virtual void checkOperabilityUnderTHPLimit(
const Simulator& ebos_simulator,
const WellState& well_state,
DeferredLogger& deferred_logger) =0;
314 virtual void updateIPR(
const Simulator& ebos_simulator,
DeferredLogger& deferred_logger)
const=0;
316 virtual void assembleWellEqWithoutIteration(
const Simulator& ebosSimulator,
318 const Well::InjectionControls& inj_controls,
319 const Well::ProductionControls& prod_controls,
325 virtual bool iterateWellEqWithControl(
const Simulator& ebosSimulator,
327 const Well::InjectionControls& inj_controls,
328 const Well::ProductionControls& prod_controls,
333 bool iterateWellEquations(
const Simulator& ebosSimulator,
339 bool solveWellForTesting(
const Simulator& ebosSimulator,
WellState& well_state,
const GroupState& group_state,
342 Eval getPerfCellPressure(
const FluidState& fs)
const;
349 #include "WellInterface_impl.hpp"
Represents the convergence status of the whole simulator, to make it possible to query and store the ...
Definition: ConvergenceReport.hpp:36
Definition: DeferredLogger.hpp:57
Definition: GasLiftSingleWell.hpp:39
Definition: GroupState.hpp:34
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:252
Convert component rates at surface conditions to phase (voidage) rates at reservoir conditions.
Definition: RateConverter.hpp:68
Definition: WellInterfaceFluidSystem.hpp:46
Definition: WellInterfaceIndices.hpp:35
Definition: WellInterface.hpp:72
virtual void apply(const BVector &x, BVector &Ax) const =0
Ax = Ax - C D^-1 B x.
void updateWellStateRates(const Simulator &ebosSimulator, WellState &well_state, DeferredLogger &deferred_logger) const
Modify the well_state's rates if there is only one nonzero rate.
Definition: WellInterface_impl.hpp:1003
virtual std::vector< double > computeCurrentWellRates(const Simulator &ebosSimulator, DeferredLogger &deferred_logger) const =0
Compute well rates based on current reservoir conditions and well variables.
virtual void apply(BVector &r) const =0
r = r - C D^-1 Rw
virtual ~WellInterface()=default
Virtual destructor.
virtual void recoverWellSolutionAndUpdateWellState(const BVector &x, WellState &well_state, DeferredLogger &deferred_logger) const =0
using the solution x to recover the solution xw for wells and applying xw to update Well State
WellInterface(const Well &well, const ParallelWellInfo &pw_info, const int time_step, const ModelParameters ¶m, const RateConverterType &rate_converter, const int pvtRegionIdx, const int num_components, const int num_phases, const int index_of_well, const std::vector< PerforationData > &perf_data)
Constructor.
Definition: WellInterface_impl.hpp:35
virtual bool jacobianContainsWellContributions() const
Wether the Jacobian will also have well contributions in it.
Definition: WellInterface.hpp:219
Collect per-connection static information to enable calculating connection-level or well-level produc...
Definition: WellProdIndexCalculator.hpp:36
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: WellState.hpp:56
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27
Solver parameters for the BlackoilModel.
Definition: BlackoilModelParametersEbos.hpp:327
Definition: BlackoilPhases.hpp:46
Definition: WellInterfaceFluidSystem.hpp:129