23 #ifndef OPM_STANDARDWELL_HEADER_INCLUDED 24 #define OPM_STANDARDWELL_HEADER_INCLUDED 26 #include <opm/simulators/timestepping/ConvergenceReport.hpp> 28 #include <opm/simulators/wells/RatioCalculator.hpp> 29 #include <opm/simulators/wells/VFPInjProperties.hpp> 30 #include <opm/simulators/wells/VFPProdProperties.hpp> 31 #include <opm/simulators/wells/WellInterface.hpp> 32 #include <opm/simulators/wells/WellProdIndexCalculator.hpp> 33 #include <opm/simulators/wells/ParallelWellInfo.hpp> 37 #include <opm/material/densead/Evaluation.hpp> 38 #include <opm/input/eclipse/Schedule/ScheduleTypes.hpp> 40 #include <opm/simulators/wells/StandardWellEval.hpp> 42 #include <dune/common/dynvector.hh> 43 #include <dune/common/dynmatrix.hh> 51 template<
typename TypeTag>
54 GetPropType<TypeTag, Properties::Indices>>
65 using typename Base::Simulator;
66 using typename Base::IntensiveQuantities;
67 using typename Base::FluidSystem;
68 using typename Base::MaterialLaw;
69 using typename Base::ModelParameters;
70 using typename Base::Indices;
71 using typename Base::RateConverterType;
72 using typename Base::SparseMatrixAdapter;
73 using typename Base::FluidState;
74 using typename Base::RateVector;
77 using Base::has_solvent;
78 using Base::has_zFraction;
79 using Base::has_polymer;
80 using Base::has_polymermw;
82 using Base::has_brine;
83 using Base::has_energy;
84 using Base::has_bioeffects;
88 using PolymerModule = BlackOilPolymerModule<TypeTag, has_polymer>;
89 using typename Base::PressureMatrix;
92 static constexpr
int numWellConservationEq = Indices::numPhases + Indices::numSolvents;
94 static constexpr
int numWellControlEq = 1;
97 static constexpr
int numStaticWellEq = numWellConservationEq + numWellControlEq;
102 static constexpr
int Bhp = numStaticWellEq - numWellControlEq;
104 using StdWellEval::WQTotal;
106 using typename Base::Scalar;
113 using typename Base::BVector;
115 using Eval =
typename StdWellEval::Eval;
116 using EvalWell =
typename StdWellEval::EvalWell;
117 using BVectorWell =
typename StdWellEval::BVectorWell;
119 using IndexTraits =
typename FluidSystem::IndexTraitsType;
125 const ModelParameters& param,
126 const RateConverterType& rate_converter,
127 const int pvtRegionIdx,
128 const int num_conservation_quantities,
129 const int num_phases,
130 const int index_of_well,
133 virtual void init(
const std::vector<Scalar>& depth_arg,
134 const Scalar gravity_arg,
135 const std::vector<Scalar>& B_avg,
136 const bool changed_to_open_this_step)
override;
140 const std::vector<Scalar>& B_avg,
141 const bool relax_tolerance)
const override;
144 virtual void apply(
const BVector& x, BVector& Ax)
const override;
146 virtual void apply(BVector& r)
const override;
159 std::vector<Scalar>& well_potentials)
override;
163 void solveEqAndUpdateWellState(
const Simulator& simulator,
167 void calculateExplicitQuantities(
const Simulator& simulator,
170 void updateProductivityIndex(
const Simulator& simulator,
175 Scalar connectionDensity(
const int globalConnIdx,
176 const int openConnIdx)
const override;
178 void addWellContributions(SparseMatrixAdapter& mat)
const override;
180 void addWellPressureEquations(PressureMatrix& mat,
182 const int pressureVarIndex,
183 const bool use_well_weights,
187 bool iterateWellEqWithControl(
const Simulator& simulator,
189 const Well::InjectionControls& inj_controls,
190 const Well::ProductionControls& prod_controls,
195 bool iterateWellEqWithSwitching(
const Simulator& simulator,
197 const Well::InjectionControls& inj_controls,
198 const Well::ProductionControls& prod_controls,
201 const bool fixed_control,
202 const bool fixed_status,
203 const bool solving_with_zero_rate)
override;
206 Scalar computeWellRatesAndBhpWithThpAlqProd(
const Simulator& ebos_simulator,
208 const SummaryState &summary_state,
209 std::vector<Scalar>& potentials,
212 void computeWellRatesWithThpAlqProd(
const Simulator& ebos_simulator,
214 const SummaryState& summary_state,
215 std::vector<Scalar>& potentials,
218 std::optional<Scalar>
219 computeBhpAtThpLimitProdWithAlq(
const Simulator& ebos_simulator,
221 const SummaryState& summary_state,
222 const Scalar alq_value,
223 bool iterate_if_no_solution)
const override;
225 void updateIPRImplicit(
const Simulator& simulator,
229 void computeWellRatesWithBhp(
const Simulator& ebosSimulator,
231 std::vector<Scalar>& well_flux,
234 Scalar maxPerfPress(
const Simulator& simulator)
const override;
237 using Base::vfp_properties_;
243 std::vector<Scalar> getPrimaryVars()
const override;
245 int setPrimaryVars(
typename std::vector<Scalar>::const_iterator it)
override;
251 void addBCDMatrix(std::vector<typename Base::BMatrix>& b_matrices,
252 std::vector<typename Base::CMatrix>& c_matrices,
253 std::vector<typename Base::DMatrix>& d_matrices,
258 if constexpr (Base::numWellDofs == StdWellEval::numWellDofs) {
259 StdWellEval::addBCDMatrix(b_matrices, c_matrices, d_matrices, wcells);
261 OPM_THROW(std::runtime_error,
262 "system_cpr preconditioner with standard wells is only supported for standard " 263 "3-phase blackoil (Indices::numEq == 3). This model has different equation count.");
271 void updateWellState(
const Simulator& simulator,
272 const BVectorWell& dwells,
276 using WellConnectionProps =
typename StdWellEval::StdWellConnections::Properties;
281 computePropertiesForWellConnectionPressures(
const Simulator& simulator,
284 void computeWellConnectionDensitesPressures(
const Simulator& simulator,
286 const WellConnectionProps& props);
288 void computeWellConnectionPressures(
const Simulator& simulator,
291 template<
class Value>
292 void computePerfRate(
const IntensiveQuantities& intQuants,
293 const std::vector<Value>& mob,
295 const std::vector<Value>& Tw,
298 std::vector<Value>& cq_s,
302 template<
class Value>
303 void computePerfRate(
const std::vector<Value>& mob,
304 const Value& pressure,
310 std::vector<Value>& b_perfcells_dense,
311 const std::vector<Value>& Tw,
314 const Value& skin_pressure,
315 const std::vector<Value>& cmix_s,
316 std::vector<Value>& cq_s,
320 void computeWellRatesWithBhpIterations(
const Simulator& ebosSimulator,
323 std::vector<Scalar>& well_flux)
const override;
326 computeWellPotentialWithTHP(
const Simulator& ebosSimulator,
330 bool computeWellPotentialsImplicit(
const Simulator& ebos_simulator,
332 std::vector<Scalar>& well_potentials)
const;
336 Scalar getRefDensity()
const override;
339 template<
class Value>
340 void getTransMult(Value& trans_mult,
341 const Simulator& simulator,
342 const int cell_indx)
const;
345 template<
class Value>
346 void getMobility(
const Simulator& simulator,
348 std::vector<Value>& mob,
351 void updateWaterMobilityWithPolymer(
const Simulator& simulator,
353 std::vector<EvalWell>& mob_water,
356 void updatePrimaryVariablesNewton(
const BVectorWell& dwells,
357 const bool stop_or_zero_rate_target,
360 void updateWellStateFromPrimaryVariables(
WellStateType& well_state,
361 const SummaryState& summary_state,
364 void assembleWellEqWithoutIteration(
const Simulator& simulator,
367 const Well::InjectionControls& inj_controls,
368 const Well::ProductionControls& prod_controls,
370 const bool solving_with_zero_rate)
override;
372 void assembleWellEqWithoutIterationImpl(
const Simulator& simulator,
375 const Well::InjectionControls& inj_controls,
376 const Well::ProductionControls& prod_controls,
378 const bool solving_with_zero_rate);
380 void calculateSinglePerf(
const Simulator& simulator,
383 std::vector<RateVector>& connectionRates,
384 std::vector<EvalWell>& cq_s,
385 EvalWell& water_flux_s,
386 EvalWell& cq_s_zfrac_effective,
390 void checkOperabilityUnderBHPLimit(
const WellStateType& well_state,
391 const Simulator& simulator,
395 void checkOperabilityUnderTHPLimit(
const Simulator& simulator,
400 void updateIPR(
const Simulator& simulator,
405 bool allDrawDownWrongDirection(
const Simulator& simulator)
const;
412 bool openCrossFlowAvoidSingularity(
const Simulator& simulator)
const;
418 EvalWell pskin(
const Scalar throughput,
419 const EvalWell& water_velocity,
420 const EvalWell& poly_inj_conc,
424 EvalWell pskinwater(
const Scalar throughput,
425 const EvalWell& water_velocity,
429 EvalWell wpolymermw(
const Scalar throughput,
430 const EvalWell& water_velocity,
434 void handleInjectivityRate(
const Simulator& simulator,
436 std::vector<EvalWell>& cq_s)
const;
439 void handleInjectivityEquations(
const Simulator& simulator,
442 const EvalWell& water_flux_s,
445 void updateWaterThroughput(
const double dt,
449 void checkConvergenceExtraEqs(
const std::vector<Scalar>& res,
453 void updateConnectionRatePolyMW(
const EvalWell& cq_s_poly,
454 const IntensiveQuantities& int_quants,
457 std::vector<RateVector>& connectionRates,
460 std::optional<Scalar>
462 const Simulator& simulator,
464 const SummaryState& summary_state)
const;
466 std::optional<Scalar>
467 computeBhpAtThpLimitInj(
const Simulator& simulator,
469 const SummaryState& summary_state)
const;
472 Eval connectionRateEnergy(
const std::vector<EvalWell>& cq_s,
473 const IntensiveQuantities& intQuants,
477 Scalar cachedRefDensity{0};
482 #include "StandardWell_impl.hpp" 484 #endif // OPM_STANDARDWELL_HEADER_INCLUDED Definition: StandardWellEval.hpp:47
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
Definition: blackoilfoammodules.hh:57
virtual ConvergenceReport getWellConvergence(const GroupStateHelperType &groupStateHelper, const std::vector< Scalar > &B_avg, const bool relax_tolerance) const override
check whether the well equations get converged for this well
Definition: StandardWell_impl.hpp:1230
Definition: StandardWell.hpp:52
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Definition: BlackoilWellModelConstraints.hpp:37
Facility for converting component rates at surface conditions to phase (voidage) rates at reservoir c...
void recoverWellSolutionAndUpdateWellState(const Simulator &simulator, const BVector &x, const GroupStateHelperType &groupStateHelper, WellStateType &well_state) override
using the solution x to recover the solution xw for wells and applying xw to update Well State ...
Definition: StandardWell_impl.hpp:1489
Contains classes extending the black-oil model.
Definition: BlackoilWellModelGasLift.hpp:38
Definition: PerforationData.hpp:55
std::vector< Scalar > computeCurrentWellRates(const Simulator &ebosSimulator, DeferredLogger &deferred_logger) const override
Compute well rates based on current reservoir conditions and well variables.
Definition: StandardWell_impl.hpp:2590
Class encapsulating some information about parallel wells.
Definition: MSWellHelpers.hpp:34
Definition: DeferredLogger.hpp:56
Collect per-connection static information to enable calculating connection-level or well-level produc...
Definition: WellProdIndexCalculator.hpp:36
void getScaledWellFractions(std::vector< Scalar > &scaled_fractions, DeferredLogger &deferred_logger) const override
Get scaled well fractions from primary variables Implemented by derived classes that have access to p...
Definition: StandardWell_impl.hpp:2658
Static data associated with a well perforation.
Definition: BlackoilWellModelRestart.hpp:41
Represents the convergence status of the whole simulator, to make it possible to query and store the ...
Definition: ConvergenceReport.hpp:37
virtual void apply(const BVector &x, BVector &Ax) const override
Ax = Ax - C D^-1 B x.
Definition: StandardWell_impl.hpp:1457
const std::string & name() const
Well name.
Definition: WellInterfaceGeneric.cpp:167
void computeWellPotentials(const Simulator &simulator, const WellStateType &well_state, const GroupStateHelperType &groupStateHelper, std::vector< Scalar > &well_potentials) override
computing the well potentials for group control
Definition: StandardWell_impl.hpp:1800
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: TemperatureModel.hpp:65