WellInterface.hpp
Go to the documentation of this file.
1/*
2 Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2017 Statoil ASA.
4 Copyright 2017 IRIS
5 Copyright 2019 Norce
6
7 This file is part of the Open Porous Media project (OPM).
8
9 OPM is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OPM is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OPM. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#ifndef OPM_WELLINTERFACE_HEADER_INCLUDED
24#define OPM_WELLINTERFACE_HEADER_INCLUDED
25
26// NOTE: GasLiftSingleWell.hpp includes StandardWell.hpp which includes ourself
27// (WellInterface.hpp), so we need to forward declare GasLiftSingleWell
28// for it to be defined in this file. Similar for BlackoilWellModel
29namespace Opm {
30 template<typename TypeTag> class GasLiftSingleWell;
31 template<typename TypeTag> class BlackoilWellModel;
32}
33
34#include <opm/common/OpmLog/OpmLog.hpp>
35#include <opm/common/ErrorMacros.hpp>
36#include <opm/common/Exceptions.hpp>
37
38#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
39
40#include <opm/material/fluidstates/BlackOilFluidState.hpp>
41
43
45
55
57
59
60#include <dune/common/fmatrix.hh>
61#include <dune/istl/bcrsmatrix.hh>
62#include <dune/istl/matrixmatrix.hh>
63
64#include <opm/material/densead/Evaluation.hpp>
65
66#include <limits>
67#include <vector>
68
69namespace Opm
70{
71
72class WellInjectionProperties;
73class WellProductionProperties;
74template<typename Scalar, typename IndexTraits> class GroupStateHelper;
75
76template<typename TypeTag>
77class WellInterface : public WellInterfaceIndices<GetPropType<TypeTag, Properties::FluidSystem>,
78 GetPropType<TypeTag, Properties::Indices>>
79{
82public:
87 using IndexTraits = typename FluidSystem::IndexTraitsType;
95
96 using VectorBlockType = Dune::FieldVector<Scalar, Indices::numEq>;
97 using MatrixBlockType = Dune::FieldMatrix<Scalar, Indices::numEq, Indices::numEq>;
98 using Eval = typename Base::Eval;
99 using BVector = Dune::BlockVector<VectorBlockType>;
100 using PressureMatrix = Dune::BCRSMatrix<Opm::MatrixBlock<Scalar, 1, 1>>;
101
105
108
111
115
117
118 static constexpr bool has_solvent = getPropValue<TypeTag, Properties::EnableSolvent>();
119 static constexpr bool has_zFraction = getPropValue<TypeTag, Properties::EnableExtbo>();
120 static constexpr bool has_polymer = getPropValue<TypeTag, Properties::EnablePolymer>();
121 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
122 static constexpr bool has_energy = energyModuleType == EnergyModules::FullyImplicitThermal;
123
124 // flag for polymer molecular weight related
125 static constexpr bool has_polymermw = getPropValue<TypeTag, Properties::EnablePolymerMW>();
126 static constexpr bool has_foam = getPropValue<TypeTag, Properties::EnableFoam>();
127 static constexpr bool has_brine = getPropValue<TypeTag, Properties::EnableBrine>();
128 static constexpr bool has_watVapor = getPropValue<TypeTag, Properties::EnableVapwat>();
129 static constexpr bool has_disgas_in_water = getPropValue<TypeTag, Properties::EnableDisgasInWater>();
130 static constexpr bool has_saltPrecip = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>();
131 static constexpr bool has_bioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
132 static constexpr bool has_micp = Indices::enableMICP;
133
134 template<class ValueType>
135 using BlackOilFluidStateType = BlackOilFluidState<ValueType,
137 energyModuleType != EnergyModules::NoTemperature,
138 energyModuleType == EnergyModules::FullyImplicitThermal,
139 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max(),
141 has_brine,
145 Indices::numPhases>;
146
147 // fluid state for the reservoir fluid
149
151 WellInterface(const Well& well,
152 const ParallelWellInfo<Scalar>& pw_info,
153 const int time_step,
154 const ModelParameters& param,
155 const RateConverterType& rate_converter,
156 const int pvtRegionIdx,
157 const int num_conservation_quantities,
158 const int num_phases,
159 const int index_of_well,
160 const std::vector<PerforationData<Scalar>>& perf_data);
161
163 virtual ~WellInterface() = default;
164
165 virtual void init(const std::vector<Scalar>& depth_arg,
166 const Scalar gravity_arg,
167 const std::vector<Scalar>& B_avg,
168 const bool changed_to_open_this_step);
169
171 const std::vector<Scalar>& B_avg,
172 const bool relax_tolerance) const = 0;
173
174 virtual void solveEqAndUpdateWellState(const Simulator& simulator,
175 const GroupStateHelperType& groupStateHelper,
176 WellStateType& well_state) = 0;
177
178 void assembleWellEq(const Simulator& simulator,
179 const double dt,
180 const GroupStateHelperType& groupStateHelper,
181 WellStateType& well_state);
182
183 void assembleWellEqWithoutIteration(const Simulator& simulator,
184 const GroupStateHelperType& groupStateHelper,
185 const double dt,
186 WellStateType& well_state,
187 const bool solving_with_zero_rate);
188
189 // Convenience overload that gets scaled fractions internally
191 DeferredLogger& deferred_logger) const;
192
193 // TODO: better name or further refactoring the function to make it more clear
194 void prepareWellBeforeAssembling(const Simulator& simulator,
195 const double dt,
196 const GroupStateHelperType& groupStateHelper,
197 WellStateType& well_state);
198
199 virtual void computeWellRatesWithBhp(const Simulator& ebosSimulator,
200 const Scalar& bhp,
201 std::vector<Scalar>& well_flux,
202 DeferredLogger& deferred_logger) const = 0;
203
204 virtual std::optional<Scalar>
206 const GroupStateHelperType& groupStateHelper,
207 const SummaryState& summary_state,
208 const Scalar alq_value,
209 bool iterate_if_no_solution) const = 0;
210
211 std::optional<Scalar>
213 const WellStateType& well_state,
214 Scalar bhp,
215 const SummaryState& summary_state,
216 const Scalar alq_value);
220 const BVector& x,
221 const GroupStateHelperType& groupStateHelper,
222 WellStateType& well_state) = 0;
223
225 virtual void apply(const BVector& x, BVector& Ax) const = 0;
226
228 virtual void apply(BVector& r) const = 0;
229
230 // TODO: before we decide to put more information under mutable, this function is not const
231 virtual void computeWellPotentials(const Simulator& simulator,
232 const WellStateType& well_state,
233 const GroupStateHelperType& groupStateHelper,
234 std::vector<Scalar>& well_potentials) = 0;
235
236 virtual void updateWellStateWithTarget(const Simulator& simulator,
237 const GroupStateHelperType& groupStateHelper,
238 WellStateType& well_state) const;
239
240 virtual void scaleSegmentRatesAndPressure(WellStateType& well_state) const;
241
242 virtual void computeWellRatesWithBhpIterations(const Simulator& simulator,
243 const Scalar& bhp,
244 const GroupStateHelperType& groupStateHelper,
245 std::vector<Scalar>& well_flux) const = 0;
246
247 bool wellUnderZeroRateTarget(const GroupStateHelperType& groupStateHelper) const;
248
249 bool stoppedOrZeroRateTarget(const GroupStateHelperType& groupStateHelper) const;
250
251 bool updateWellStateWithTHPTargetProd(const Simulator& simulator,
252 WellStateType& well_state,
253 const GroupStateHelperType& groupStateHelper) const;
254
255 bool wellUnderZeroGroupRateTarget(const GroupStateHelperType& groupStateHelper,
256 const std::optional<bool> group_control = std::nullopt) const;
257
258 enum class IndividualOrGroup { Individual, Group, Both };
259 bool updateWellControl(const Simulator& simulator,
260 const IndividualOrGroup iog,
261 const GroupStateHelperType& groupStateHelper,
262 WellStateType& well_state) /* const */;
263
270 void updateWeldrawMaxRate(const Simulator& simulator,
271 WellStateType& well_state,
272 DeferredLogger& deferred_logger) const;
273
275 const GroupStateHelperType& groupStateHelper,
276 const Well::InjectionControls& inj_controls,
277 const Well::ProductionControls& prod_controls,
278 const Scalar WQTotal,
279 WellStateType& well_state,
280 const bool fixed_control,
281 const bool fixed_status,
282 const bool solving_with_zero_rate);
283
284 virtual void updatePrimaryVariables(const GroupStateHelperType& groupStateHelper) = 0;
285
286 virtual void calculateExplicitQuantities(const Simulator& simulator,
287 const GroupStateHelperType& groupStateHelper) = 0; // should be const?
288
289 virtual void updateProductivityIndex(const Simulator& simulator,
290 const WellProdIndexCalculator<Scalar>& wellPICalc,
291 WellStateType& well_state,
292 DeferredLogger& deferred_logger) const = 0;
293
294 // Add well contributions to matrix
296
298 const BVector& x,
299 const int pressureVarIndex,
300 const bool use_well_weights,
301 const WellStateType& well_state) const = 0;
302
303 void addCellRates(std::map<int, RateVector>& cellRates_) const;
304
305 Scalar volumetricSurfaceRateForConnection(int cellIdx, int phaseIdx) const;
306
307 // TODO: theoretically, it should be a const function
308 // Simulator is not const is because that assembleWellEq is non-const Simulator
309 void wellTesting(const Simulator& simulator,
310 const double simulation_time,
311 const GroupStateHelperType& groupStateHelper,
312 WellStateType& well_state,
313 WellTestState& welltest_state,
314 GLiftEclWells& ecl_well_map,
315 std::map<std::string, double>& open_times);
316
317 void checkWellOperability(const Simulator& simulator,
318 const WellStateType& well_state,
319 const GroupStateHelperType& groupStateHelper);
320
322 WellStateType& well_state,
323 const GroupState<Scalar>& group_state,
324 GLiftEclWells& ecl_well_map,
325 DeferredLogger& deferred_logger);
326
327 // check whether the well is operable under the current reservoir condition
328 // mostly related to BHP limit and THP limit
329 void updateWellOperability(const Simulator& simulator,
330 const WellStateType& well_state,
331 const GroupStateHelperType& groupStateHelper);
332
333 bool updateWellOperabilityFromWellEq(const Simulator& simulator,
334 const GroupStateHelperType& groupStateHelper);
335
336 // update perforation water throughput based on solved water rate
337 virtual void updateWaterThroughput(const double dt,
338 WellStateType& well_state) const = 0;
339
342 virtual std::vector<Scalar>
344 DeferredLogger& deferred_logger) const = 0;
345
348 virtual void getScaledWellFractions(std::vector<Scalar>& scaled_fractions,
349 DeferredLogger& deferred_logger) const = 0;
350
354 void initializeProducerWellState(const Simulator& simulator,
355 WellStateType& well_state,
356 DeferredLogger& deferred_logger) const;
357
358 void solveWellEquation(const Simulator& simulator,
359 const GroupStateHelperType& groupStateHelper,
360 WellStateType& well_state);
361
362 const std::vector<RateVector>& connectionRates() const
363 {
364 return connectionRates_;
365 }
366
367 void updateConnectionDFactor(const Simulator& simulator,
368 SingleWellStateType& ws) const;
369
371 SingleWellStateType& ws) const;
372
373 virtual bool iterateWellEqWithSwitching(const Simulator& simulator,
374 const double dt,
375 const WellInjectionControls& inj_controls,
376 const WellProductionControls& prod_controls,
377 const GroupStateHelperType& groupStateHelper,
378 WellStateType& well_state,
379 const bool fixed_control,
380 const bool fixed_status,
381 const bool solving_with_zero_rate) = 0;
382
383 virtual Scalar maxPerfPress(const Simulator& simulator) const = 0;
384
385 virtual void updateIPRImplicit(const Simulator& simulator,
386 const GroupStateHelperType& groupStateHelper,
387 WellStateType& well_state) = 0;
388
389 static constexpr int numResDofs = Indices::numEq;
390 static constexpr int numWellDofs = numResDofs + 1; // NB will fail for for thermal for now
391 using BMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numWellDofs, numResDofs>>;
392 using CMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numResDofs, numWellDofs>>;
393 using DMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numWellDofs, numWellDofs>>;
394 using WVector = Dune::BlockVector<Dune::FieldVector<Scalar, numWellDofs>>;
395
396 virtual void addBCDMatrix(std::vector<BMatrix>& b_matrices,
397 std::vector<CMatrix>& c_matrices,
398 std::vector<DMatrix>& d_matrices,
399 Opm::SparseTable<int>& wcells) const = 0;
400
401protected:
402 // simulation parameters
403 std::vector<RateVector> connectionRates_;
404 std::vector<Scalar> B_avg_;
408
409 Scalar wpolymer() const;
410 Scalar wfoam() const;
411 Scalar wsalt() const;
412 Scalar wmicrobes() const;
413 Scalar woxygen() const;
414 Scalar wurea() const;
415
416 virtual Scalar getRefDensity() const = 0;
417
418 std::vector<Scalar>
419 initialWellRateFractions(const Simulator& ebosSimulator,
420 const WellStateType& well_state) const;
421
422 // check whether the well is operable under BHP limit with current reservoir condition
423 virtual void checkOperabilityUnderBHPLimit(const WellStateType& well_state,
424 const Simulator& simulator,
425 DeferredLogger& deferred_logger) = 0;
426
427 // check whether the well is operable under THP limit with current reservoir condition
428 virtual void checkOperabilityUnderTHPLimit(const Simulator& simulator,
429 const WellStateType& well_state,
430 const GroupStateHelperType& groupStateHelper) = 0;
431
432 virtual void updateIPR(const Simulator& simulator,
433 DeferredLogger& deferred_logger) const = 0;
434
435 virtual void assembleWellEqWithoutIteration(const Simulator& simulator,
436 const GroupStateHelperType& groupStateHelper,
437 const double dt,
438 const WellInjectionControls& inj_controls,
439 const WellProductionControls& prod_controls,
440 WellStateType& well_state,
441 const bool solving_with_zero_rate) = 0;
442
443 // iterate well equations with the specified control until converged
444 virtual bool iterateWellEqWithControl(const Simulator& simulator,
445 const double dt,
446 const WellInjectionControls& inj_controls,
447 const WellProductionControls& prod_controls,
448 const GroupStateHelperType& groupStateHelper,
449 WellStateType& well_state) = 0;
450
451 bool iterateWellEquations(const Simulator& simulator,
452 const double dt,
453 const GroupStateHelperType& groupStateHelper,
454 WellStateType& well_state);
455
456 bool solveWellWithOperabilityCheck(const Simulator& simulator,
457 const double dt,
458 const Well::InjectionControls& inj_controls,
459 const Well::ProductionControls& prod_controls,
460 const GroupStateHelperType& groupStateHelper,
461 WellStateType& well_state);
462
463 std::optional<Scalar>
464 estimateOperableBhp(const Simulator& ebos_simulator,
465 const double dt,
466 const GroupStateHelperType& groupStateHelper,
467 const SummaryState& summary_state,
468 WellStateType& well_state);
469
470 bool solveWellWithBhp(const Simulator& simulator,
471 const double dt,
472 const Scalar bhp,
473 const GroupStateHelperType& groupStateHelper,
474 WellStateType& well_state);
475
476 bool solveWellWithZeroRate(const Simulator& simulator,
477 const double dt,
478 const GroupStateHelperType& groupStateHelper,
479 WellStateType& well_state);
480
481 bool solveWellForTesting(const Simulator& simulator,
482 const GroupStateHelperType& groupStateHelper,
483 WellStateType& well_state);
484
485
486 template<class GasLiftSingleWell>
487 std::unique_ptr<GasLiftSingleWell> initializeGliftWellTest_(const Simulator& simulator,
488 WellStateType& well_state,
489 const GroupState<Scalar>& group_state,
490 GLiftEclWells& ecl_well_map,
491 DeferredLogger& deferred_logger);
492
493 Eval getPerfCellPressure(const FluidState& fs) const;
494
495 // get the transmissibility multiplier for specific perforation
496 template<class Value, class Callback>
497 void getTransMult(Value& trans_mult,
498 const Simulator& simulator,
499 const int cell_idx,
500 Callback& extendEval) const;
501
502 // get the well transmissibility for specific perforation
503 template<class Value>
504 void getTw(std::vector<Value>& wi,
505 const int perf,
506 const IntensiveQuantities& intQuants,
507 const Value& trans_mult,
508 const SingleWellStateType& ws) const;
509
510 // get the mobility for specific perforation
511 template<class Value, class Callback>
512 void getMobility(const Simulator& simulator,
513 const int local_perf_index,
514 std::vector<Value>& mob,
515 Callback& extendEval,
516 [[maybe_unused]] DeferredLogger& deferred_logger) const;
517
518 void computeConnLevelProdInd(const FluidState& fs,
519 const std::function<Scalar(const Scalar)>& connPICalc,
520 const std::vector<Scalar>& mobility,
521 Scalar* connPI) const;
522
523 void computeConnLevelInjInd(const FluidState& fs,
524 const Phase preferred_phase,
525 const std::function<Scalar(const Scalar)>& connIICalc,
526 const std::vector<Scalar>& mobility,
527 Scalar* connII,
528 DeferredLogger& deferred_logger) const;
529
530 Scalar computeConnectionDFactor(const int perf,
531 const IntensiveQuantities& intQuants,
532 const SingleWellStateType& ws) const;
533
536 FSInfo getFirstPerfCellConditions(const Simulator& simulator) const;
537};
538
539} // namespace Opm
540
541#include "WellInterface_impl.hpp"
542
543#endif // OPM_WELLINTERFACE_HEADER_INCLUDED
Declares the properties required by the black oil model.
Definition: ConvergenceReport.hpp:38
Definition: DeferredLogger.hpp:57
std::map< std::string, std::pair< const Well *, int > > GLiftEclWells
Definition: GasLiftGroupInfo.hpp:65
Definition: GasLiftSingleWell.hpp:39
Definition: GroupStateHelper.hpp:56
Definition: GroupState.hpp:41
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:217
Definition: RateConverter.hpp:70
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:84
Definition: SingleWellState.hpp:44
Definition: WellInterfaceFluidSystem.hpp:50
static constexpr int Oil
Definition: WellInterfaceFluidSystem.hpp:65
static constexpr int Water
Definition: WellInterfaceFluidSystem.hpp:64
static constexpr int Gas
Definition: WellInterfaceFluidSystem.hpp:66
int pvtRegionIdx() const
Definition: WellInterfaceGeneric.hpp:132
Definition: WellInterfaceIndices.hpp:34
DenseAd::Evaluation< Scalar, Indices::numDerivatives > Eval
Definition: WellInterfaceIndices.hpp:40
typename WellInterfaceFluidSystem< GetPropType< TypeTag, Properties::FluidSystem > >::ModelParameters ModelParameters
Definition: WellInterfaceIndices.hpp:41
Definition: WellInterface.hpp:79
bool stoppedOrZeroRateTarget(const GroupStateHelperType &groupStateHelper) const
Definition: WellInterface_impl.hpp:1888
bool updateWellOperabilityFromWellEq(const Simulator &simulator, const GroupStateHelperType &groupStateHelper)
Definition: WellInterface_impl.hpp:1439
virtual void checkOperabilityUnderTHPLimit(const Simulator &simulator, const WellStateType &well_state, const GroupStateHelperType &groupStateHelper)=0
virtual std::vector< Scalar > computeCurrentWellRates(const Simulator &simulator, DeferredLogger &deferred_logger) const =0
void checkWellOperability(const Simulator &simulator, const WellStateType &well_state, const GroupStateHelperType &groupStateHelper)
Definition: WellInterface_impl.hpp:1311
void updateWellOperability(const Simulator &simulator, const WellStateType &well_state, const GroupStateHelperType &groupStateHelper)
Definition: WellInterface_impl.hpp:1401
bool solveWellWithOperabilityCheck(const Simulator &simulator, const double dt, const Well::InjectionControls &inj_controls, const Well::ProductionControls &prod_controls, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:735
Scalar woxygen() const
Definition: WellInterface_impl.hpp:168
virtual Scalar maxPerfPress(const Simulator &simulator) const =0
static constexpr bool has_brine
Definition: WellInterface.hpp:127
IndividualOrGroup
Definition: WellInterface.hpp:258
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: WellInterface.hpp:84
void assembleWellEqWithoutIteration(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, const double dt, WellStateType &well_state, const bool solving_with_zero_rate)
Definition: WellInterface_impl.hpp:1108
virtual void recoverWellSolutionAndUpdateWellState(const Simulator &simulator, const BVector &x, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)=0
Scalar computeConnectionDFactor(const int perf, const IntensiveQuantities &intQuants, const SingleWellStateType &ws) const
Definition: WellInterface_impl.hpp:2135
virtual std::optional< Scalar > computeBhpAtThpLimitProdWithAlq(const Simulator &ebos_simulator, const GroupStateHelperType &groupStateHelper, const SummaryState &summary_state, const Scalar alq_value, bool iterate_if_no_solution) const =0
virtual void computeWellRatesWithBhp(const Simulator &ebosSimulator, const Scalar &bhp, std::vector< Scalar > &well_flux, DeferredLogger &deferred_logger) const =0
void updateWeldrawMaxRate(const Simulator &simulator, WellStateType &well_state, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:289
virtual void addWellContributions(SparseMatrixAdapter &) const =0
typename WellInterfaceFluidSystem< FluidSystem >::RateConverterType RateConverterType
Definition: WellInterface.hpp:110
const std::vector< RateVector > & connectionRates() const
Definition: WellInterface.hpp:362
Scalar wfoam() const
Definition: WellInterface_impl.hpp:130
virtual void updateIPR(const Simulator &simulator, DeferredLogger &deferred_logger) const =0
bool updateWellControlAndStatusLocalIteration(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, const Well::InjectionControls &inj_controls, const Well::ProductionControls &prod_controls, const Scalar WQTotal, WellStateType &well_state, const bool fixed_control, const bool fixed_status, const bool solving_with_zero_rate)
Definition: WellInterface_impl.hpp:381
void getTransMult(Value &trans_mult, const Simulator &simulator, const int cell_idx, Callback &extendEval) const
Definition: WellInterface_impl.hpp:2223
std::vector< RateVector > connectionRates_
Definition: WellInterface.hpp:403
bool solveWellForTesting(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:974
void computeConnLevelProdInd(const FluidState &fs, const std::function< Scalar(const Scalar)> &connPICalc, const std::vector< Scalar > &mobility, Scalar *connPI) const
Definition: WellInterface_impl.hpp:2389
Dune::BCRSMatrix< Opm::MatrixBlock< Scalar, 1, 1 > > PressureMatrix
Definition: WellInterface.hpp:100
void gliftBeginTimeStepWellTestUpdateALQ(const Simulator &simulator, WellStateType &well_state, const GroupState< Scalar > &group_state, GLiftEclWells &ecl_well_map, DeferredLogger &deferred_logger)
Definition: WellInterface_impl.hpp:1339
Scalar volumetricSurfaceRateForConnection(int cellIdx, int phaseIdx) const
Definition: WellInterface_impl.hpp:1291
virtual void init(const std::vector< Scalar > &depth_arg, const Scalar gravity_arg, const std::vector< Scalar > &B_avg, const bool changed_to_open_this_step)
Definition: WellInterface_impl.hpp:98
BlackOilFluidState< ValueType, FluidSystem, energyModuleType !=EnergyModules::NoTemperature, energyModuleType==EnergyModules::FullyImplicitThermal, Indices::compositionSwitchIdx !=std::numeric_limits< unsigned >::max(), has_watVapor, has_brine, has_saltPrecip, has_disgas_in_water, has_solvent, Indices::numPhases > BlackOilFluidStateType
Definition: WellInterface.hpp:145
std::optional< Scalar > computeBhpAtThpLimitProdWithAlqUsingIPR(const Simulator &simulator, const WellStateType &well_state, Scalar bhp, const SummaryState &summary_state, const Scalar alq_value)
Definition: WellInterface_impl.hpp:2354
virtual void updatePrimaryVariables(const GroupStateHelperType &groupStateHelper)=0
void getTw(std::vector< Value > &wi, const int perf, const IntensiveQuantities &intQuants, const Value &trans_mult, const SingleWellStateType &ws) const
Definition: WellInterface_impl.hpp:2037
void getMobility(const Simulator &simulator, const int local_perf_index, std::vector< Value > &mob, Callback &extendEval, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:2236
virtual void apply(const BVector &x, BVector &Ax) const =0
Ax = Ax - C D^-1 B x.
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numResDofs, numWellDofs > > CMatrix
Definition: WellInterface.hpp:392
GetPropType< TypeTag, Properties::IntensiveQuantities > IntensiveQuantities
Definition: WellInterface.hpp:89
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: WellInterface.hpp:85
static constexpr int numWellDofs
Definition: WellInterface.hpp:390
virtual void updateIPRImplicit(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)=0
std::vector< Scalar > initialWellRateFractions(const Simulator &ebosSimulator, const WellStateType &well_state) const
Definition: WellInterface_impl.hpp:1899
void solveWellEquation(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1030
static constexpr bool has_watVapor
Definition: WellInterface.hpp:128
void updateConnectionDFactor(const Simulator &simulator, SingleWellStateType &ws) const
Definition: WellInterface_impl.hpp:2115
virtual void updateWaterThroughput(const double dt, WellStateType &well_state) const =0
GetPropType< TypeTag, Properties::MaterialLaw > MaterialLaw
Definition: WellInterface.hpp:90
virtual Scalar getRefDensity() const =0
typename FluidSystem::IndexTraitsType IndexTraits
Definition: WellInterface.hpp:87
Eval getPerfCellPressure(const FluidState &fs) const
Definition: WellInterface_impl.hpp:2208
Dune::BlockVector< VectorBlockType > BVector
Definition: WellInterface.hpp:99
void initializeProducerWellState(const Simulator &simulator, WellStateType &well_state, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:1949
std::vector< Scalar > B_avg_
Definition: WellInterface.hpp:404
static constexpr int numResDofs
Definition: WellInterface.hpp:389
static constexpr bool has_bioeffects
Definition: WellInterface.hpp:131
bool changed_to_stopped_this_step_
Definition: WellInterface.hpp:405
virtual void updateWellStateWithTarget(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state) const
Definition: WellInterface_impl.hpp:1469
static constexpr bool has_polymermw
Definition: WellInterface.hpp:125
void addCellRates(std::map< int, RateVector > &cellRates_) const
Definition: WellInterface_impl.hpp:1272
static constexpr bool has_polymer
Definition: WellInterface.hpp:120
virtual void apply(BVector &r) const =0
r = r - C D^-1 Rw
GetPropType< TypeTag, Properties::Grid > Grid
Definition: WellInterface.hpp:83
virtual ~WellInterface()=default
Virtual destructor.
typename Base::ModelParameters ModelParameters
Definition: WellInterface.hpp:116
virtual void solveEqAndUpdateWellState(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)=0
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: WellInterface.hpp:86
static constexpr bool has_solvent
Definition: WellInterface.hpp:118
static constexpr bool has_disgas_in_water
Definition: WellInterface.hpp:129
virtual bool iterateWellEqWithSwitching(const Simulator &simulator, const double dt, const WellInjectionControls &inj_controls, const WellProductionControls &prod_controls, const GroupStateHelperType &groupStateHelper, WellStateType &well_state, const bool fixed_control, const bool fixed_status, const bool solving_with_zero_rate)=0
static constexpr bool has_saltPrecip
Definition: WellInterface.hpp:130
bool wellUnderZeroRateTarget(const GroupStateHelperType &groupStateHelper) const
Definition: WellInterface_impl.hpp:1856
virtual void assembleWellEqWithoutIteration(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, const double dt, const WellInjectionControls &inj_controls, const WellProductionControls &prod_controls, WellStateType &well_state, const bool solving_with_zero_rate)=0
virtual void checkOperabilityUnderBHPLimit(const WellStateType &well_state, const Simulator &simulator, DeferredLogger &deferred_logger)=0
virtual void addBCDMatrix(std::vector< BMatrix > &b_matrices, std::vector< CMatrix > &c_matrices, std::vector< DMatrix > &d_matrices, Opm::SparseTable< int > &wcells) const =0
static constexpr bool has_foam
Definition: WellInterface.hpp:126
GetPropType< TypeTag, Properties::RateVector > RateVector
Definition: WellInterface.hpp:92
void updateConnectionTransmissibilityFactor(const Simulator &simulator, SingleWellStateType &ws) const
Definition: WellInterface_impl.hpp:2177
void computeConnLevelInjInd(const FluidState &fs, const Phase preferred_phase, const std::function< Scalar(const Scalar)> &connIICalc, const std::vector< Scalar > &mobility, Scalar *connII, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:2423
typename GasLiftGroupInfo< Scalar, IndexTraits >::GLiftEclWells GLiftEclWells
Definition: WellInterface.hpp:94
std::unique_ptr< GasLiftSingleWell > initializeGliftWellTest_(const Simulator &simulator, WellStateType &well_state, const GroupState< Scalar > &group_state, GLiftEclWells &ecl_well_map, DeferredLogger &deferred_logger)
Definition: WellInterface_impl.hpp:2457
virtual void addWellPressureEquations(PressureMatrix &mat, const BVector &x, const int pressureVarIndex, const bool use_well_weights, const WellStateType &well_state) const =0
BlackOilFluidStateType< Eval > FluidState
Definition: WellInterface.hpp:148
std::optional< Scalar > estimateOperableBhp(const Simulator &ebos_simulator, const double dt, const GroupStateHelperType &groupStateHelper, const SummaryState &summary_state, WellStateType &well_state)
Definition: WellInterface_impl.hpp:855
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numWellDofs > > DMatrix
Definition: WellInterface.hpp:393
Dune::BlockVector< Dune::FieldVector< Scalar, numWellDofs > > WVector
Definition: WellInterface.hpp:394
int number_of_well_reopenings_
Definition: WellInterface.hpp:407
Scalar wsalt() const
Definition: WellInterface_impl.hpp:144
static constexpr bool has_micp
Definition: WellInterface.hpp:132
bool solveWellWithZeroRate(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:942
bool wellUnderZeroGroupRateTarget(const GroupStateHelperType &groupStateHelper, const std::optional< bool > group_control=std::nullopt) const
Definition: WellInterface_impl.hpp:1873
bool solveWellWithBhp(const Simulator &simulator, const double dt, const Scalar bhp, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:892
Dune::FieldMatrix< Scalar, Indices::numEq, Indices::numEq > MatrixBlockType
Definition: WellInterface.hpp:97
void prepareWellBeforeAssembling(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1145
void wellTesting(const Simulator &simulator, const double simulation_time, const GroupStateHelperType &groupStateHelper, WellStateType &well_state, WellTestState &welltest_state, GLiftEclWells &ecl_well_map, std::map< std::string, double > &open_times)
Definition: WellInterface_impl.hpp:500
virtual ConvergenceReport getWellConvergence(const GroupStateHelperType &groupStateHelper, const std::vector< Scalar > &B_avg, const bool relax_tolerance) const =0
typename Base::Eval Eval
Definition: WellInterface.hpp:98
WellInterface(const Well &well, const ParallelWellInfo< Scalar > &pw_info, const int time_step, const ModelParameters &param, const RateConverterType &rate_converter, const int pvtRegionIdx, const int num_conservation_quantities, const int num_phases, const int index_of_well, const std::vector< PerforationData< Scalar > > &perf_data)
Constructor.
Definition: WellInterface_impl.hpp:61
WellState< Scalar, IndexTraits > WellStateType
Definition: WellInterface.hpp:102
bool updateWellStateWithTHPTargetProd(const Simulator &simulator, WellStateType &well_state, const GroupStateHelperType &groupStateHelper) const
Definition: WellInterface_impl.hpp:2322
virtual void computeWellPotentials(const Simulator &simulator, const WellStateType &well_state, const GroupStateHelperType &groupStateHelper, std::vector< Scalar > &well_potentials)=0
bool iterateWellEquations(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:657
static constexpr bool has_energy
Definition: WellInterface.hpp:122
Scalar wpolymer() const
Definition: WellInterface_impl.hpp:114
SingleWellState< Scalar, IndexTraits > SingleWellStateType
Definition: WellInterface.hpp:103
virtual bool iterateWellEqWithControl(const Simulator &simulator, const double dt, const WellInjectionControls &inj_controls, const WellProductionControls &prod_controls, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)=0
virtual void updateProductivityIndex(const Simulator &simulator, const WellProdIndexCalculator< Scalar > &wellPICalc, WellStateType &well_state, DeferredLogger &deferred_logger) const =0
virtual void calculateExplicitQuantities(const Simulator &simulator, const GroupStateHelperType &groupStateHelper)=0
GetPropType< TypeTag, Properties::Indices > Indices
Definition: WellInterface.hpp:88
bool updateWellControl(const Simulator &simulator, const IndividualOrGroup iog, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:192
Scalar wurea() const
Definition: WellInterface_impl.hpp:180
void updateGroupTargetFallbackFlag(WellStateType &well_state, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:1130
FSInfo getFirstPerfCellConditions(const Simulator &simulator) const
Temperature and salt concentration of the first perforated cell, broadcast so that all processes of a...
Definition: WellInterface_impl.hpp:2499
virtual void getScaledWellFractions(std::vector< Scalar > &scaled_fractions, DeferredLogger &deferred_logger) const =0
bool thp_update_iterations
Definition: WellInterface.hpp:406
Dune::FieldVector< Scalar, Indices::numEq > VectorBlockType
Definition: WellInterface.hpp:96
void assembleWellEq(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1092
Scalar wmicrobes() const
Definition: WellInterface_impl.hpp:156
GetPropType< TypeTag, Properties::SparseMatrixAdapter > SparseMatrixAdapter
Definition: WellInterface.hpp:91
virtual void scaleSegmentRatesAndPressure(WellStateType &well_state) const
Definition: WellInterface_impl.hpp:1461
GroupStateHelper< Scalar, IndexTraits > GroupStateHelperType
Definition: WellInterface.hpp:104
virtual void computeWellRatesWithBhpIterations(const Simulator &simulator, const Scalar &bhp, const GroupStateHelperType &groupStateHelper, std::vector< Scalar > &well_flux) const =0
static constexpr bool has_zFraction
Definition: WellInterface.hpp:119
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numResDofs > > BMatrix
Definition: WellInterface.hpp:391
static constexpr EnergyModules energyModuleType
Definition: WellInterface.hpp:121
Definition: WellProdIndexCalculator.hpp:37
Definition: WellState.hpp:68
Declares the properties required by the black oil model.
Phase
Phase indices for reservoir coupling, we currently only support black-oil phases (oil,...
Definition: ReservoirCoupling.hpp:165
Definition: blackoilbioeffectsmodules.hh:45
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
Reservoir temperature and salt concentration of the first perforated cell.
Definition: ParallelWellInfo.hpp:44
Static data associated with a well perforation.
Definition: PerforationData.hpp:30