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
47
57
59
61
62#include <dune/common/fmatrix.hh>
63#include <dune/istl/matrixmatrix.hh>
64
65#include <opm/material/densead/Evaluation.hpp>
66
67#include <limits>
68#include <vector>
69
70namespace Opm
71{
72
73class WellInjectionProperties;
74class WellProductionProperties;
75template<typename Scalar, typename IndexTraits> class GroupStateHelper;
76
77template<typename TypeTag>
78class WellInterface : public WellInterfaceIndices<GetPropType<TypeTag, Properties::FluidSystem>,
79 GetPropType<TypeTag, Properties::Indices>>
80{
83public:
88 using IndexTraits = typename FluidSystem::IndexTraitsType;
96
97 using VectorBlockType = Dune::FieldVector<Scalar, Indices::numEq>;
98 using MatrixBlockType = Dune::FieldMatrix<Scalar, Indices::numEq, Indices::numEq>;
99 using Eval = typename Base::Eval;
102
106
109
112
116
118
119 static constexpr bool has_solvent = getPropValue<TypeTag, Properties::EnableSolvent>();
120 static constexpr bool has_zFraction = getPropValue<TypeTag, Properties::EnableExtbo>();
121 static constexpr bool has_polymer = getPropValue<TypeTag, Properties::EnablePolymer>();
122 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
123 static constexpr bool has_energy = energyModuleType == EnergyModules::FullyImplicitThermal;
124
125 // flag for polymer molecular weight related
126 static constexpr bool has_polymermw = getPropValue<TypeTag, Properties::EnablePolymerMW>();
127 static constexpr bool has_foam = getPropValue<TypeTag, Properties::EnableFoam>();
128 static constexpr bool has_brine = getPropValue<TypeTag, Properties::EnableBrine>();
129 static constexpr bool has_watVapor = getPropValue<TypeTag, Properties::EnableVapwat>();
130 static constexpr bool has_disgas_in_water = getPropValue<TypeTag, Properties::EnableDisgasInWater>();
131 static constexpr bool has_saltPrecip = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>();
132 static constexpr bool has_bioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
133 static constexpr bool has_micp = Indices::enableMICP;
134
135 template<class ValueType>
136 using BlackOilFluidStateType = BlackOilFluidState<ValueType,
138 energyModuleType != EnergyModules::NoTemperature,
139 energyModuleType == EnergyModules::FullyImplicitThermal,
140 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max(),
142 has_brine,
146 Indices::numPhases>;
147
148 // fluid state for the reservoir fluid
150
152 WellInterface(const Well& well,
153 const ParallelWellInfo<Scalar>& pw_info,
154 const int time_step,
155 const ModelParameters& param,
156 const RateConverterType& rate_converter,
157 const int pvtRegionIdx,
158 const int num_conservation_quantities,
159 const int num_phases,
160 const int index_of_well,
161 const std::vector<PerforationData<Scalar>>& perf_data);
162
164 virtual ~WellInterface() = default;
165
166 virtual void init(const std::vector<Scalar>& depth_arg,
167 const Scalar gravity_arg,
168 const std::vector<Scalar>& B_avg,
169 const bool changed_to_open_this_step);
170
172 const std::vector<Scalar>& B_avg,
173 const bool relax_tolerance) const = 0;
174
175 virtual void solveEqAndUpdateWellState(const Simulator& simulator,
176 const GroupStateHelperType& groupStateHelper,
177 WellStateType& well_state) = 0;
178
179 void assembleWellEq(const Simulator& simulator,
180 const double dt,
181 const GroupStateHelperType& groupStateHelper,
182 WellStateType& well_state);
183
184 void assembleWellEqWithoutIteration(const Simulator& simulator,
185 const GroupStateHelperType& groupStateHelper,
186 const double dt,
187 WellStateType& well_state,
188 const bool solving_with_zero_rate);
189
190 // Convenience overload that gets scaled fractions internally
192 DeferredLogger& deferred_logger) const;
193
194 // TODO: better name or further refactoring the function to make it more clear
195 void prepareWellBeforeAssembling(const Simulator& simulator,
196 const double dt,
197 const GroupStateHelperType& groupStateHelper,
198 WellStateType& well_state);
199
200 virtual void computeWellRatesWithBhp(const Simulator& ebosSimulator,
201 const Scalar& bhp,
202 std::vector<Scalar>& well_flux,
203 DeferredLogger& deferred_logger) const = 0;
204
205 virtual std::optional<Scalar>
207 const GroupStateHelperType& groupStateHelper,
208 const SummaryState& summary_state,
209 const Scalar alq_value,
210 bool iterate_if_no_solution) const = 0;
211
212 std::optional<Scalar>
214 const WellStateType& well_state,
215 Scalar bhp,
216 const SummaryState& summary_state,
217 const Scalar alq_value);
221 const BVector& x,
222 const GroupStateHelperType& groupStateHelper,
223 WellStateType& well_state) = 0;
224
226 virtual void apply(const BVector& x, BVector& Ax) const = 0;
227
229 virtual void apply(BVector& r) const = 0;
230
231 // TODO: before we decide to put more information under mutable, this function is not const
232 virtual void computeWellPotentials(const Simulator& simulator,
233 const WellStateType& well_state,
234 const GroupStateHelperType& groupStateHelper,
235 std::vector<Scalar>& well_potentials) = 0;
236
237 virtual void updateWellStateWithTarget(const Simulator& simulator,
238 const GroupStateHelperType& groupStateHelper,
239 WellStateType& well_state) const;
240
241 virtual void scaleSegmentRatesAndPressure(WellStateType& well_state) const;
242
243 virtual void computeWellRatesWithBhpIterations(const Simulator& simulator,
244 const Scalar& bhp,
245 const GroupStateHelperType& groupStateHelper,
246 std::vector<Scalar>& well_flux) const = 0;
247
248 bool wellUnderZeroRateTarget(const GroupStateHelperType& groupStateHelper) const;
249
250 bool stoppedOrZeroRateTarget(const GroupStateHelperType& groupStateHelper) const;
251
252 bool updateWellStateWithTHPTargetProd(const Simulator& simulator,
253 WellStateType& well_state,
254 const GroupStateHelperType& groupStateHelper) const;
255
256 bool wellUnderZeroGroupRateTarget(const GroupStateHelperType& groupStateHelper,
257 const std::optional<bool> group_control = std::nullopt) const;
258
259 enum class IndividualOrGroup { Individual, Group, Both };
260 bool updateWellControl(const Simulator& simulator,
261 const IndividualOrGroup iog,
262 const GroupStateHelperType& groupStateHelper,
263 WellStateType& well_state) /* const */;
264
271 void updateWeldrawMaxRate(const Simulator& simulator,
272 WellStateType& well_state,
273 DeferredLogger& deferred_logger) const;
274
276 const GroupStateHelperType& groupStateHelper,
277 const Well::InjectionControls& inj_controls,
278 const Well::ProductionControls& prod_controls,
279 const Scalar WQTotal,
280 WellStateType& well_state,
281 const bool fixed_control,
282 const bool fixed_status,
283 const bool solving_with_zero_rate);
284
285 virtual void updatePrimaryVariables(const GroupStateHelperType& groupStateHelper) = 0;
286
287 virtual void calculateExplicitQuantities(const Simulator& simulator,
288 const GroupStateHelperType& groupStateHelper) = 0; // should be const?
289
290 virtual void updateProductivityIndex(const Simulator& simulator,
291 const WellProdIndexCalculator<Scalar>& wellPICalc,
292 WellStateType& well_state,
293 DeferredLogger& deferred_logger) const = 0;
294
295 // Add well contributions to matrix
297
299 const BVector& x,
300 const int pressureVarIndex,
301 const bool use_well_weights,
302 const bool contract_d_diagonal,
303 const WellStateType& well_state) const = 0;
304
305 void addCellRates(std::map<int, RateVector>& cellRates_) const;
306
309 template <class CellFilter>
310 void addConstantCellRates(std::map<int, RateVector>& cellRates,
311 const CellFilter& cellFilter) const
312 {
313 if (!this->operability_status_.solvable) {
314 return;
315 }
316 for (int perfIdx = 0; perfIdx < this->number_of_local_perforations_; ++perfIdx) {
317 const auto cellIdx = this->cells()[perfIdx];
318 if (!cellFilter(cellIdx)) {
319 continue;
320 }
321 auto& rates = cellRates.try_emplace(cellIdx, 0.0).first->second;
322 for (auto i = 0*RateVector::dimension; i < RateVector::dimension; ++i) {
323 rates[i] += getValue(connectionRates_[perfIdx][i]);
324 }
325 }
326 }
327
328 Scalar volumetricSurfaceRateForConnection(int cellIdx, int phaseIdx) const;
329
330 // TODO: theoretically, it should be a const function
331 // Simulator is not const is because that assembleWellEq is non-const Simulator
332 void wellTesting(const Simulator& simulator,
333 const double simulation_time,
334 const GroupStateHelperType& groupStateHelper,
335 WellStateType& well_state,
336 WellTestState& welltest_state,
337 GLiftEclWells& ecl_well_map,
338 std::map<std::string, double>& open_times);
339
340 void checkWellOperability(const Simulator& simulator,
341 const WellStateType& well_state,
342 const GroupStateHelperType& groupStateHelper);
343
345 WellStateType& well_state,
346 const GroupState<Scalar>& group_state,
347 GLiftEclWells& ecl_well_map,
348 DeferredLogger& deferred_logger);
349
350 // check whether the well is operable under the current reservoir condition
351 // mostly related to BHP limit and THP limit
352 void updateWellOperability(const Simulator& simulator,
353 const WellStateType& well_state,
354 const GroupStateHelperType& groupStateHelper);
355
356 bool updateWellOperabilityFromWellEq(const Simulator& simulator,
357 const GroupStateHelperType& groupStateHelper);
358
359 // Sets the representative dissolved/vaporised ratios of the well (Rs, Rv,
360 // Rsw, Rvw in the well state) used to split the total surface rates into
361 // free and dissolved/vaporised parts for output. The ratios are the
362 // rate-weighted averages of the perforation ratios, i.e. what the
363 // perforations actually produce. When they are not well defined (e.g.
364 // crossflow) the ratios inferred from the total rates, bounded by the
365 // saturated values at the well pressure, are used instead.
366 //
367 // Called once per timestep from BlackoilWellModel::timeStepSucceeded().
368 void consolidatePhaseMixingRates(WellStateType& well_state) const;
369
370 // update perforation water throughput based on solved water rate
371 virtual void updateWaterThroughput(const double dt,
372 WellStateType& well_state) const = 0;
373
376 virtual std::vector<Scalar>
378 DeferredLogger& deferred_logger) const = 0;
379
382 virtual void getScaledWellFractions(std::vector<Scalar>& scaled_fractions,
383 DeferredLogger& deferred_logger) const = 0;
384
388 void initializeProducerWellState(const Simulator& simulator,
389 WellStateType& well_state,
390 DeferredLogger& deferred_logger) const;
391
400 void stopWellAndSolveWithZeroRate(const Simulator& simulator,
401 const double dt,
402 const GroupStateHelperType& groupStateHelper,
403 WellStateType& well_state);
404
411 void resetStoppedWell(const Simulator& simulator,
412 const double dt,
413 const GroupStateHelperType& groupStateHelper,
414 WellStateType& well_state);
415
416 void solveWellEquation(const Simulator& simulator,
417 const GroupStateHelperType& groupStateHelper,
418 WellStateType& well_state);
419
420 const std::vector<RateVector>& connectionRates() const
421 {
422 return connectionRates_;
423 }
424
425 void updateConnectionDFactor(const Simulator& simulator,
426 SingleWellStateType& ws) const;
427
429 SingleWellStateType& ws) const;
430
431 virtual bool iterateWellEqWithSwitching(const Simulator& simulator,
432 const double dt,
433 const WellInjectionControls& inj_controls,
434 const WellProductionControls& prod_controls,
435 const GroupStateHelperType& groupStateHelper,
436 WellStateType& well_state,
437 const bool fixed_control,
438 const bool fixed_status,
439 const bool solving_with_zero_rate) = 0;
440
441 virtual Scalar maxPerfPress(const Simulator& simulator) const = 0;
442
443 virtual void updateIPRImplicit(const Simulator& simulator,
444 const GroupStateHelperType& groupStateHelper,
445 WellStateType& well_state) = 0;
446
447 static constexpr int numResDofs = Indices::numEq;
448 static constexpr int numWellDofs = numResDofs + 1; // NB will fail for for thermal for now
452 using WVector = Dune::BlockVector<Dune::FieldVector<Scalar, numWellDofs>>;
453
454 virtual void addBCDMatrix(std::vector<BMatrix>& b_matrices,
455 std::vector<CMatrix>& c_matrices,
456 std::vector<DMatrix>& d_matrices,
457 Opm::SparseTable<int>& wcells) const = 0;
458
459protected:
460 // simulation parameters
461 std::vector<RateVector> connectionRates_;
462 std::vector<Scalar> B_avg_;
466
467 Scalar wpolymer() const;
468 Scalar wfoam() const;
469 Scalar wsalt() const;
470 Scalar wmicrobes() const;
471 Scalar woxygen() const;
472 Scalar wurea() const;
473
474 virtual Scalar getRefDensity() const = 0;
475
476 std::vector<Scalar>
477 initialWellRateFractions(const Simulator& ebosSimulator,
478 const WellStateType& well_state) const;
479
480 // check whether the well is operable under BHP limit with current reservoir condition
481 virtual void checkOperabilityUnderBHPLimit(const WellStateType& well_state,
482 const Simulator& simulator,
483 DeferredLogger& deferred_logger) = 0;
484
485 // check whether the well is operable under THP limit with current reservoir condition
486 virtual void checkOperabilityUnderTHPLimit(const Simulator& simulator,
487 const WellStateType& well_state,
488 const GroupStateHelperType& groupStateHelper) = 0;
489
490 virtual void updateIPR(const Simulator& simulator,
491 DeferredLogger& deferred_logger) const = 0;
492
493 virtual void assembleWellEqWithoutIteration(const Simulator& simulator,
494 const GroupStateHelperType& groupStateHelper,
495 const double dt,
496 const WellInjectionControls& inj_controls,
497 const WellProductionControls& prod_controls,
498 WellStateType& well_state,
499 const bool solving_with_zero_rate) = 0;
500
501 // iterate well equations with the specified control until converged
502 virtual bool iterateWellEqWithControl(const Simulator& simulator,
503 const double dt,
504 const WellInjectionControls& inj_controls,
505 const WellProductionControls& prod_controls,
506 const GroupStateHelperType& groupStateHelper,
507 WellStateType& well_state) = 0;
508
509 bool iterateWellEquations(const Simulator& simulator,
510 const double dt,
511 const GroupStateHelperType& groupStateHelper,
512 WellStateType& well_state);
513
514 bool solveWellWithOperabilityCheck(const Simulator& simulator,
515 const double dt,
516 const Well::InjectionControls& inj_controls,
517 const Well::ProductionControls& prod_controls,
518 const GroupStateHelperType& groupStateHelper,
519 WellStateType& well_state);
520
521 std::optional<Scalar>
522 estimateOperableBhp(const Simulator& ebos_simulator,
523 const double dt,
524 const GroupStateHelperType& groupStateHelper,
525 const SummaryState& summary_state,
526 WellStateType& well_state);
527
528 bool solveWellWithBhp(const Simulator& simulator,
529 const double dt,
530 const Scalar bhp,
531 const GroupStateHelperType& groupStateHelper,
532 WellStateType& well_state);
533
534 bool solveWellWithZeroRate(const Simulator& simulator,
535 const double dt,
536 const GroupStateHelperType& groupStateHelper,
537 WellStateType& well_state);
538
539 bool solveWellForTesting(const Simulator& simulator,
540 const GroupStateHelperType& groupStateHelper,
541 WellStateType& well_state);
542
543
544 template<class GasLiftSingleWell>
545 std::unique_ptr<GasLiftSingleWell> initializeGliftWellTest_(const Simulator& simulator,
546 WellStateType& well_state,
547 const GroupState<Scalar>& group_state,
548 GLiftEclWells& ecl_well_map,
549 DeferredLogger& deferred_logger);
550
551 Eval getPerfCellPressure(const FluidState& fs) const;
552
553 // get the transmissibility multiplier for specific perforation
554 template<class Value, class Callback>
555 void getTransMult(Value& trans_mult,
556 const Simulator& simulator,
557 const int cell_idx,
558 Callback& extendEval) const;
559
560 // get the well transmissibility for specific perforation
561 template<class Value>
562 void getTw(std::vector<Value>& wi,
563 const int perf,
564 const IntensiveQuantities& intQuants,
565 const Value& trans_mult,
566 const SingleWellStateType& ws) const;
567
568 // get the mobility for specific perforation
569 template<class Value, class Callback>
570 void getMobility(const Simulator& simulator,
571 const int local_perf_index,
572 std::vector<Value>& mob,
573 Callback& extendEval,
574 [[maybe_unused]] DeferredLogger& deferred_logger) const;
575
576 void computeConnLevelProdInd(const FluidState& fs,
577 const std::function<Scalar(const Scalar)>& connPICalc,
578 const std::vector<Scalar>& mobility,
579 Scalar* connPI) const;
580
581 void computeConnLevelInjInd(const FluidState& fs,
582 const Phase preferred_phase,
583 const std::function<Scalar(const Scalar)>& connIICalc,
584 const std::vector<Scalar>& mobility,
585 Scalar* connII,
586 DeferredLogger& deferred_logger) const;
587
588 Scalar computeConnectionDFactor(const int perf,
589 const IntensiveQuantities& intQuants,
590 const SingleWellStateType& ws) const;
591
594 FSInfo getFirstPerfCellConditions(const Simulator& simulator) const;
595};
596
597} // namespace Opm
598
599#include "WellInterface_impl.hpp"
600
601#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:67
Definition: GasLiftSingleWell.hpp:39
Definition: GroupStateHelper.hpp:57
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:137
OperabilityStatus operability_status_
Definition: WellInterfaceGeneric.hpp:484
const std::vector< int > & cells() const
Well cells.
Definition: WellInterfaceGeneric.hpp:92
int number_of_local_perforations_
Definition: WellInterfaceGeneric.hpp:528
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:80
bool stoppedOrZeroRateTarget(const GroupStateHelperType &groupStateHelper) const
Definition: WellInterface_impl.hpp:2086
bool updateWellOperabilityFromWellEq(const Simulator &simulator, const GroupStateHelperType &groupStateHelper)
Definition: WellInterface_impl.hpp:1642
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:1514
void updateWellOperability(const Simulator &simulator, const WellStateType &well_state, const GroupStateHelperType &groupStateHelper)
Definition: WellInterface_impl.hpp:1604
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:879
Scalar woxygen() const
Definition: WellInterface_impl.hpp:170
virtual Scalar maxPerfPress(const Simulator &simulator) const =0
static constexpr bool has_brine
Definition: WellInterface.hpp:128
IndividualOrGroup
Definition: WellInterface.hpp:259
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: WellInterface.hpp:85
void assembleWellEqWithoutIteration(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, const double dt, WellStateType &well_state, const bool solving_with_zero_rate)
Definition: WellInterface_impl.hpp:1252
virtual void recoverWellSolutionAndUpdateWellState(const Simulator &simulator, const BVector &x, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)=0
void resetStoppedWell(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Make a stopped well consistent after the solve with zero rate failed.
Definition: WellInterface_impl.hpp:1446
Scalar computeConnectionDFactor(const int perf, const IntensiveQuantities &intQuants, const SingleWellStateType &ws) const
Definition: WellInterface_impl.hpp:2346
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:292
virtual void addWellContributions(SparseMatrixAdapter &) const =0
typename WellInterfaceFluidSystem< FluidSystem >::RateConverterType RateConverterType
Definition: WellInterface.hpp:111
const std::vector< RateVector > & connectionRates() const
Definition: WellInterface.hpp:420
Scalar wfoam() const
Definition: WellInterface_impl.hpp:132
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:384
void getTransMult(Value &trans_mult, const Simulator &simulator, const int cell_idx, Callback &extendEval) const
Definition: WellInterface_impl.hpp:2434
std::vector< RateVector > connectionRates_
Definition: WellInterface.hpp:461
bool solveWellForTesting(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1118
void computeConnLevelProdInd(const FluidState &fs, const std::function< Scalar(const Scalar)> &connPICalc, const std::vector< Scalar > &mobility, Scalar *connPI) const
Definition: WellInterface_impl.hpp:2600
void gliftBeginTimeStepWellTestUpdateALQ(const Simulator &simulator, WellStateType &well_state, const GroupState< Scalar > &group_state, GLiftEclWells &ecl_well_map, DeferredLogger &deferred_logger)
Definition: WellInterface_impl.hpp:1542
Scalar volumetricSurfaceRateForConnection(int cellIdx, int phaseIdx) const
Definition: WellInterface_impl.hpp:1494
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:100
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:146
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:2565
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:2235
void getMobility(const Simulator &simulator, const int local_perf_index, std::vector< Value > &mob, Callback &extendEval, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:2447
Opm::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numWellDofs > > DMatrix
Definition: WellInterface.hpp:451
virtual void apply(const BVector &x, BVector &Ax) const =0
Ax = Ax - C D^-1 B x.
GetPropType< TypeTag, Properties::IntensiveQuantities > IntensiveQuantities
Definition: WellInterface.hpp:90
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: WellInterface.hpp:86
static constexpr int numWellDofs
Definition: WellInterface.hpp:448
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:2097
void solveWellEquation(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1174
static constexpr bool has_watVapor
Definition: WellInterface.hpp:129
void updateConnectionDFactor(const Simulator &simulator, SingleWellStateType &ws) const
Definition: WellInterface_impl.hpp:2326
virtual void updateWaterThroughput(const double dt, WellStateType &well_state) const =0
Opm::BlockVector< VectorBlockType > BVector
Definition: WellInterface.hpp:100
GetPropType< TypeTag, Properties::MaterialLaw > MaterialLaw
Definition: WellInterface.hpp:91
virtual Scalar getRefDensity() const =0
typename FluidSystem::IndexTraitsType IndexTraits
Definition: WellInterface.hpp:88
Eval getPerfCellPressure(const FluidState &fs) const
Definition: WellInterface_impl.hpp:2419
void initializeProducerWellState(const Simulator &simulator, WellStateType &well_state, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:2147
std::vector< Scalar > B_avg_
Definition: WellInterface.hpp:462
static constexpr int numResDofs
Definition: WellInterface.hpp:447
static constexpr bool has_bioeffects
Definition: WellInterface.hpp:132
bool changed_to_stopped_this_step_
Definition: WellInterface.hpp:463
virtual void updateWellStateWithTarget(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state) const
Definition: WellInterface_impl.hpp:1672
static constexpr bool has_polymermw
Definition: WellInterface.hpp:126
void addCellRates(std::map< int, RateVector > &cellRates_) const
Definition: WellInterface_impl.hpp:1475
static constexpr bool has_polymer
Definition: WellInterface.hpp:121
virtual void apply(BVector &r) const =0
r = r - C D^-1 Rw
GetPropType< TypeTag, Properties::Grid > Grid
Definition: WellInterface.hpp:84
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:117
virtual void solveEqAndUpdateWellState(const Simulator &simulator, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)=0
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: WellInterface.hpp:87
static constexpr bool has_solvent
Definition: WellInterface.hpp:119
static constexpr bool has_disgas_in_water
Definition: WellInterface.hpp:130
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:131
bool wellUnderZeroRateTarget(const GroupStateHelperType &groupStateHelper) const
Definition: WellInterface_impl.hpp:2054
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:127
GetPropType< TypeTag, Properties::RateVector > RateVector
Definition: WellInterface.hpp:93
void updateConnectionTransmissibilityFactor(const Simulator &simulator, SingleWellStateType &ws) const
Definition: WellInterface_impl.hpp:2388
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:2634
typename GasLiftGroupInfo< Scalar, IndexTraits >::GLiftEclWells GLiftEclWells
Definition: WellInterface.hpp:95
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:2668
Opm::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numResDofs > > BMatrix
Definition: WellInterface.hpp:449
BlackOilFluidStateType< Eval > FluidState
Definition: WellInterface.hpp:149
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:999
Dune::BlockVector< Dune::FieldVector< Scalar, numWellDofs > > WVector
Definition: WellInterface.hpp:452
int number_of_well_reopenings_
Definition: WellInterface.hpp:465
Scalar wsalt() const
Definition: WellInterface_impl.hpp:146
static constexpr bool has_micp
Definition: WellInterface.hpp:133
void stopWellAndSolveWithZeroRate(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Stop the well and solve it with zero rate.
Definition: WellInterface_impl.hpp:1401
bool solveWellWithZeroRate(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1086
bool wellUnderZeroGroupRateTarget(const GroupStateHelperType &groupStateHelper, const std::optional< bool > group_control=std::nullopt) const
Definition: WellInterface_impl.hpp:2071
bool solveWellWithBhp(const Simulator &simulator, const double dt, const Scalar bhp, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1036
Dune::FieldMatrix< Scalar, Indices::numEq, Indices::numEq > MatrixBlockType
Definition: WellInterface.hpp:98
void prepareWellBeforeAssembling(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1289
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:503
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:99
Opm::BCRSMatrix< Dune::FieldMatrix< Scalar, numResDofs, numWellDofs > > CMatrix
Definition: WellInterface.hpp:450
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:63
WellState< Scalar, IndexTraits > WellStateType
Definition: WellInterface.hpp:103
bool updateWellStateWithTHPTargetProd(const Simulator &simulator, WellStateType &well_state, const GroupStateHelperType &groupStateHelper) const
Definition: WellInterface_impl.hpp:2533
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:660
static constexpr bool has_energy
Definition: WellInterface.hpp:123
Scalar wpolymer() const
Definition: WellInterface_impl.hpp:116
SingleWellState< Scalar, IndexTraits > SingleWellStateType
Definition: WellInterface.hpp:104
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:89
bool updateWellControl(const Simulator &simulator, const IndividualOrGroup iog, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:194
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:310
Scalar wurea() const
Definition: WellInterface_impl.hpp:182
void updateGroupTargetFallbackFlag(WellStateType &well_state, DeferredLogger &deferred_logger) const
Definition: WellInterface_impl.hpp:1274
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:2711
virtual void getScaledWellFractions(std::vector< Scalar > &scaled_fractions, DeferredLogger &deferred_logger) const =0
bool thp_update_iterations
Definition: WellInterface.hpp:464
Dune::FieldVector< Scalar, Indices::numEq > VectorBlockType
Definition: WellInterface.hpp:97
void assembleWellEq(const Simulator &simulator, const double dt, const GroupStateHelperType &groupStateHelper, WellStateType &well_state)
Definition: WellInterface_impl.hpp:1236
Scalar wmicrobes() const
Definition: WellInterface_impl.hpp:158
GetPropType< TypeTag, Properties::SparseMatrixAdapter > SparseMatrixAdapter
Definition: WellInterface.hpp:92
Opm::BCRSMatrix< Opm::MatrixBlock< Scalar, 1, 1 > > PressureMatrix
Definition: WellInterface.hpp:101
virtual void scaleSegmentRatesAndPressure(WellStateType &well_state) const
Definition: WellInterface_impl.hpp:1664
GroupStateHelper< Scalar, IndexTraits > GroupStateHelperType
Definition: WellInterface.hpp:105
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:120
void consolidatePhaseMixingRates(WellStateType &well_state) const
Definition: WellInterface_impl.hpp:761
static constexpr EnergyModules energyModuleType
Definition: WellInterface.hpp:122
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:184
Definition: blackoilbioeffectsmodules.hh:45
Dune::BCRSMatrix< B, A > BCRSMatrix
Definition: BCRSMatrix.hpp:35
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
Dune::BlockVector< B, A > BlockVector
Definition: BlockVector.hpp:35
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