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 bool contract_d_diagonal,
302 const WellStateType& well_state) const = 0;
303
304 void addCellRates(std::map<int, RateVector>& cellRates_) const;
305
308 template <class CellFilter>
309 void addConstantCellRates(std::map<int, RateVector>& cellRates,
310 const CellFilter& cellFilter) const
311 {
312 if (!this->operability_status_.solvable) {
313 return;
314 }
315 for (int perfIdx = 0; perfIdx < this->number_of_local_perforations_; ++perfIdx) {
316 const auto cellIdx = this->cells()[perfIdx];
317 if (!cellFilter(cellIdx)) {
318 continue;
319 }
320 auto& rates = cellRates.try_emplace(cellIdx, 0.0).first->second;
321 for (auto i = 0*RateVector::dimension; i < RateVector::dimension; ++i) {
322 rates[i] += getValue(connectionRates_[perfIdx][i]);
323 }
324 }
325 }
326
327 Scalar volumetricSurfaceRateForConnection(int cellIdx, int phaseIdx) const;
328
329 // TODO: theoretically, it should be a const function
330 // Simulator is not const is because that assembleWellEq is non-const Simulator
331 void wellTesting(const Simulator& simulator,
332 const double simulation_time,
333 const GroupStateHelperType& groupStateHelper,
334 WellStateType& well_state,
335 WellTestState& welltest_state,
336 GLiftEclWells& ecl_well_map,
337 std::map<std::string, double>& open_times);
338
339 void checkWellOperability(const Simulator& simulator,
340 const WellStateType& well_state,
341 const GroupStateHelperType& groupStateHelper);
342
344 WellStateType& well_state,
345 const GroupState<Scalar>& group_state,
346 GLiftEclWells& ecl_well_map,
347 DeferredLogger& deferred_logger);
348
349 // check whether the well is operable under the current reservoir condition
350 // mostly related to BHP limit and THP limit
351 void updateWellOperability(const Simulator& simulator,
352 const WellStateType& well_state,
353 const GroupStateHelperType& groupStateHelper);
354
355 bool updateWellOperabilityFromWellEq(const Simulator& simulator,
356 const GroupStateHelperType& groupStateHelper);
357
358 // Sets the representative dissolved/vaporised ratios of the well (Rs, Rv,
359 // Rsw, Rvw in the well state) used to split the total surface rates into
360 // free and dissolved/vaporised parts for output. The ratios are the
361 // rate-weighted averages of the perforation ratios, i.e. what the
362 // perforations actually produce. When they are not well defined (e.g.
363 // crossflow) the ratios inferred from the total rates, bounded by the
364 // saturated values at the well pressure, are used instead.
365 //
366 // Called once per timestep from BlackoilWellModel::timeStepSucceeded().
367 void consolidatePhaseMixingRates(WellStateType& well_state) const;
368
369 // update perforation water throughput based on solved water rate
370 virtual void updateWaterThroughput(const double dt,
371 WellStateType& well_state) const = 0;
372
375 virtual std::vector<Scalar>
377 DeferredLogger& deferred_logger) const = 0;
378
381 virtual void getScaledWellFractions(std::vector<Scalar>& scaled_fractions,
382 DeferredLogger& deferred_logger) const = 0;
383
387 void initializeProducerWellState(const Simulator& simulator,
388 WellStateType& well_state,
389 DeferredLogger& deferred_logger) const;
390
391 void solveWellEquation(const Simulator& simulator,
392 const GroupStateHelperType& groupStateHelper,
393 WellStateType& well_state);
394
395 const std::vector<RateVector>& connectionRates() const
396 {
397 return connectionRates_;
398 }
399
400 void updateConnectionDFactor(const Simulator& simulator,
401 SingleWellStateType& ws) const;
402
404 SingleWellStateType& ws) const;
405
406 virtual bool iterateWellEqWithSwitching(const Simulator& simulator,
407 const double dt,
408 const WellInjectionControls& inj_controls,
409 const WellProductionControls& prod_controls,
410 const GroupStateHelperType& groupStateHelper,
411 WellStateType& well_state,
412 const bool fixed_control,
413 const bool fixed_status,
414 const bool solving_with_zero_rate) = 0;
415
416 virtual Scalar maxPerfPress(const Simulator& simulator) const = 0;
417
418 virtual void updateIPRImplicit(const Simulator& simulator,
419 const GroupStateHelperType& groupStateHelper,
420 WellStateType& well_state) = 0;
421
422 static constexpr int numResDofs = Indices::numEq;
423 static constexpr int numWellDofs = numResDofs + 1; // NB will fail for for thermal for now
424 using BMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numWellDofs, numResDofs>>;
425 using CMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numResDofs, numWellDofs>>;
426 using DMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numWellDofs, numWellDofs>>;
427 using WVector = Dune::BlockVector<Dune::FieldVector<Scalar, numWellDofs>>;
428
429 virtual void addBCDMatrix(std::vector<BMatrix>& b_matrices,
430 std::vector<CMatrix>& c_matrices,
431 std::vector<DMatrix>& d_matrices,
432 Opm::SparseTable<int>& wcells) const = 0;
433
434protected:
435 // simulation parameters
436 std::vector<RateVector> connectionRates_;
437 std::vector<Scalar> B_avg_;
441
442 Scalar wpolymer() const;
443 Scalar wfoam() const;
444 Scalar wsalt() const;
445 Scalar wmicrobes() const;
446 Scalar woxygen() const;
447 Scalar wurea() const;
448
449 virtual Scalar getRefDensity() const = 0;
450
451 std::vector<Scalar>
452 initialWellRateFractions(const Simulator& ebosSimulator,
453 const WellStateType& well_state) const;
454
455 // check whether the well is operable under BHP limit with current reservoir condition
456 virtual void checkOperabilityUnderBHPLimit(const WellStateType& well_state,
457 const Simulator& simulator,
458 DeferredLogger& deferred_logger) = 0;
459
460 // check whether the well is operable under THP limit with current reservoir condition
461 virtual void checkOperabilityUnderTHPLimit(const Simulator& simulator,
462 const WellStateType& well_state,
463 const GroupStateHelperType& groupStateHelper) = 0;
464
465 virtual void updateIPR(const Simulator& simulator,
466 DeferredLogger& deferred_logger) const = 0;
467
468 virtual void assembleWellEqWithoutIteration(const Simulator& simulator,
469 const GroupStateHelperType& groupStateHelper,
470 const double dt,
471 const WellInjectionControls& inj_controls,
472 const WellProductionControls& prod_controls,
473 WellStateType& well_state,
474 const bool solving_with_zero_rate) = 0;
475
476 // iterate well equations with the specified control until converged
477 virtual bool iterateWellEqWithControl(const Simulator& simulator,
478 const double dt,
479 const WellInjectionControls& inj_controls,
480 const WellProductionControls& prod_controls,
481 const GroupStateHelperType& groupStateHelper,
482 WellStateType& well_state) = 0;
483
484 bool iterateWellEquations(const Simulator& simulator,
485 const double dt,
486 const GroupStateHelperType& groupStateHelper,
487 WellStateType& well_state);
488
489 bool solveWellWithOperabilityCheck(const Simulator& simulator,
490 const double dt,
491 const Well::InjectionControls& inj_controls,
492 const Well::ProductionControls& prod_controls,
493 const GroupStateHelperType& groupStateHelper,
494 WellStateType& well_state);
495
496 std::optional<Scalar>
497 estimateOperableBhp(const Simulator& ebos_simulator,
498 const double dt,
499 const GroupStateHelperType& groupStateHelper,
500 const SummaryState& summary_state,
501 WellStateType& well_state);
502
503 bool solveWellWithBhp(const Simulator& simulator,
504 const double dt,
505 const Scalar bhp,
506 const GroupStateHelperType& groupStateHelper,
507 WellStateType& well_state);
508
509 bool solveWellWithZeroRate(const Simulator& simulator,
510 const double dt,
511 const GroupStateHelperType& groupStateHelper,
512 WellStateType& well_state);
513
514 bool solveWellForTesting(const Simulator& simulator,
515 const GroupStateHelperType& groupStateHelper,
516 WellStateType& well_state);
517
518
519 template<class GasLiftSingleWell>
520 std::unique_ptr<GasLiftSingleWell> initializeGliftWellTest_(const Simulator& simulator,
521 WellStateType& well_state,
522 const GroupState<Scalar>& group_state,
523 GLiftEclWells& ecl_well_map,
524 DeferredLogger& deferred_logger);
525
526 Eval getPerfCellPressure(const FluidState& fs) const;
527
528 // get the transmissibility multiplier for specific perforation
529 template<class Value, class Callback>
530 void getTransMult(Value& trans_mult,
531 const Simulator& simulator,
532 const int cell_idx,
533 Callback& extendEval) const;
534
535 // get the well transmissibility for specific perforation
536 template<class Value>
537 void getTw(std::vector<Value>& wi,
538 const int perf,
539 const IntensiveQuantities& intQuants,
540 const Value& trans_mult,
541 const SingleWellStateType& ws) const;
542
543 // get the mobility for specific perforation
544 template<class Value, class Callback>
545 void getMobility(const Simulator& simulator,
546 const int local_perf_index,
547 std::vector<Value>& mob,
548 Callback& extendEval,
549 [[maybe_unused]] DeferredLogger& deferred_logger) const;
550
551 void computeConnLevelProdInd(const FluidState& fs,
552 const std::function<Scalar(const Scalar)>& connPICalc,
553 const std::vector<Scalar>& mobility,
554 Scalar* connPI) const;
555
556 void computeConnLevelInjInd(const FluidState& fs,
557 const Phase preferred_phase,
558 const std::function<Scalar(const Scalar)>& connIICalc,
559 const std::vector<Scalar>& mobility,
560 Scalar* connII,
561 DeferredLogger& deferred_logger) const;
562
563 Scalar computeConnectionDFactor(const int perf,
564 const IntensiveQuantities& intQuants,
565 const SingleWellStateType& ws) const;
566
569 FSInfo getFirstPerfCellConditions(const Simulator& simulator) const;
570};
571
572} // namespace Opm
573
574#include "WellInterface_impl.hpp"
575
576#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:42
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:87
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:136
OperabilityStatus operability_status_
Definition: WellInterfaceGeneric.hpp:476
const std::vector< int > & cells() const
Well cells.
Definition: WellInterfaceGeneric.hpp:91
int number_of_local_perforations_
Definition: WellInterfaceGeneric.hpp:520
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:2003
bool updateWellOperabilityFromWellEq(const Simulator &simulator, const GroupStateHelperType &groupStateHelper)
Definition: WellInterface_impl.hpp:1559
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:1431
void updateWellOperability(const Simulator &simulator, const WellStateType &well_state, const GroupStateHelperType &groupStateHelper)
Definition: WellInterface_impl.hpp:1521
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:855
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:1228
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:2263
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:290
virtual void addWellContributions(SparseMatrixAdapter &) const =0
typename WellInterfaceFluidSystem< FluidSystem >::RateConverterType RateConverterType
Definition: WellInterface.hpp:110
const std::vector< RateVector > & connectionRates() const
Definition: WellInterface.hpp:395
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:382
void getTransMult(Value &trans_mult, const Simulator &simulator, const int cell_idx, Callback &extendEval) const
Definition: WellInterface_impl.hpp:2351
std::vector< RateVector > connectionRates_
Definition: WellInterface.hpp:436
bool solveWellForTesting(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1094
void computeConnLevelProdInd(const FluidState &fs, const std::function< Scalar(const Scalar)> &connPICalc, const std::vector< Scalar > &mobility, Scalar *connPI) const
Definition: WellInterface_impl.hpp:2517
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:1459
Scalar volumetricSurfaceRateForConnection(int cellIdx, int phaseIdx) const
Definition: WellInterface_impl.hpp:1411
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:2482
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:2152
void getMobility(const Simulator &simulator, const int local_perf_index, std::vector< Value > &mob, Callback &extendEval, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:2364
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:425
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:423
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:2014
void solveWellEquation(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1150
static constexpr bool has_watVapor
Definition: WellInterface.hpp:128
void updateConnectionDFactor(const Simulator &simulator, SingleWellStateType &ws) const
Definition: WellInterface_impl.hpp:2243
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:2336
Dune::BlockVector< VectorBlockType > BVector
Definition: WellInterface.hpp:99
void initializeProducerWellState(const Simulator &simulator, WellStateType &well_state, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:2064
std::vector< Scalar > B_avg_
Definition: WellInterface.hpp:437
static constexpr int numResDofs
Definition: WellInterface.hpp:422
static constexpr bool has_bioeffects
Definition: WellInterface.hpp:131
bool changed_to_stopped_this_step_
Definition: WellInterface.hpp:438
virtual void updateWellStateWithTarget(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state) const
Definition: WellInterface_impl.hpp:1589
static constexpr bool has_polymermw
Definition: WellInterface.hpp:125
void addCellRates(std::map< int, RateVector > &cellRates_) const
Definition: WellInterface_impl.hpp:1392
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 void addWellPressureEquations(PressureMatrix &mat, const BVector &x, const int pressureVarIndex, const bool use_well_weights, const bool contract_d_diagonal, const WellStateType &well_state) const =0
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:1971
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:2305
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:2551
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:2585
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:975
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numWellDofs > > DMatrix
Definition: WellInterface.hpp:426
Dune::BlockVector< Dune::FieldVector< Scalar, numWellDofs > > WVector
Definition: WellInterface.hpp:427
int number_of_well_reopenings_
Definition: WellInterface.hpp:440
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:1062
bool wellUnderZeroGroupRateTarget(const GroupStateHelperType &groupStateHelper, const std::optional< bool > group_control=std::nullopt) const
Definition: WellInterface_impl.hpp:1988
bool solveWellWithBhp(const Simulator &simulator, const double dt, const Scalar bhp, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1012
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:1265
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:501
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:2450
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:658
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
void addConstantCellRates(std::map< int, RateVector > &cellRates, const CellFilter &cellFilter) const
Add the connection rates of the cells accepted by cellFilter as constant sources, i....
Definition: WellInterface.hpp:309
Scalar wurea() const
Definition: WellInterface_impl.hpp:180
void updateGroupTargetFallbackFlag(WellStateType &well_state, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:1250
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:2627
virtual void getScaledWellFractions(std::vector< Scalar > &scaled_fractions, DeferredLogger &deferred_logger) const =0
bool thp_update_iterations
Definition: WellInterface.hpp:439
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:1212
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:1581
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:424
void consolidatePhaseMixingRates(WellStateType &well_state) const
Definition: WellInterface_impl.hpp:737
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:183
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