From eef455106dd96447de927c98dc5483ab2404907f Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 23 Jun 2022 15:14:36 +0200 Subject: [PATCH 1/2] regularize equation for std wells --- opm/simulators/wells/StandardWell.hpp | 2 ++ opm/simulators/wells/StandardWell_impl.hpp | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index d4438ebca..fa0cfe18e 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -250,6 +250,8 @@ namespace Opm protected: + bool regularize_; + // xw = inv(D)*(rw - C*x) void recoverSolutionWell(const BVector& x, BVectorWell& xw) const; diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 8dd1c4549..ec0bbcbf7 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -46,6 +46,7 @@ namespace Opm const std::vector& perf_data) : Base(well, pw_info, time_step, param, rate_converter, pvtRegionIdx, num_components, num_phases, index_of_well, perf_data) , StdWellEval(static_cast&>(*this)) + , regularize_(false) { assert(this->num_components_ == numWellConservationEq); } @@ -449,9 +450,10 @@ namespace Opm const GroupState& group_state, DeferredLogger& deferred_logger) { + // try to regularize equation if the well does not converge + const Scalar regularization_factor = this->regularize_? this->param_.regularization_factor_ms_wells_ : 1.0; + const double volume = 0.002831684659200 * regularization_factor; // 0.1 cu ft; - // TODO: it probably can be static member for StandardWell - const double volume = 0.002831684659200; // 0.1 cu ft; auto& ws = well_state.well(this->index_of_well_); ws.vaporized_oil_rate = 0; @@ -2653,10 +2655,17 @@ namespace Opm const int max_iter = this->param_.max_inner_iter_wells_; int it = 0; bool converged; + bool relax_convergence = false; + this->regularize_ = false; do { assembleWellEqWithoutIteration(ebosSimulator, dt, inj_controls, prod_controls, well_state, group_state, deferred_logger); - auto report = getWellConvergence(well_state, Base::B_avg_, deferred_logger); + if (it > this->param_.strict_inner_iter_wells_) { + relax_convergence = true; + this->regularize_ = true; + } + + auto report = getWellConvergence(well_state, Base::B_avg_, deferred_logger, relax_convergence); converged = report.converged(); if (converged) { From cf1abb086ff0109694fae06924163898ca0b25e2 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 29 Jun 2022 12:54:42 +0200 Subject: [PATCH 2/2] remove msw(ms) from regulariztion parameter --- opm/simulators/flow/BlackoilModelParametersEbos.hpp | 12 ++++++------ opm/simulators/wells/MultisegmentWell_impl.hpp | 2 +- opm/simulators/wells/StandardWell_impl.hpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/opm/simulators/flow/BlackoilModelParametersEbos.hpp b/opm/simulators/flow/BlackoilModelParametersEbos.hpp index c0f07caa6..c178a32be 100644 --- a/opm/simulators/flow/BlackoilModelParametersEbos.hpp +++ b/opm/simulators/flow/BlackoilModelParametersEbos.hpp @@ -141,7 +141,7 @@ struct RelaxedPressureTolMsw { using type = UndefinedProperty; }; template -struct RegularizationFactorMsw { +struct RegularizationFactorWells { using type = UndefinedProperty; }; template @@ -282,7 +282,7 @@ struct StrictInnerIterWells { static constexpr int value = 40; }; template -struct RegularizationFactorMsw { +struct RegularizationFactorWells { using type = GetPropType; static constexpr type value = 100; }; @@ -369,8 +369,8 @@ namespace Opm /// Newton iteration where wells are stricly convergent int strict_outer_iter_wells_; - /// Regularization factor for ms wells - int regularization_factor_ms_wells_; + /// Regularization factor for wells + int regularization_factor_wells_; /// Maximum newton iterations with inner well iterations int max_niter_inner_well_iter_; @@ -444,7 +444,7 @@ namespace Opm max_inner_iter_ms_wells_ = EWOMS_GET_PARAM(TypeTag, int, MaxInnerIterMsWells); strict_inner_iter_wells_ = EWOMS_GET_PARAM(TypeTag, int, StrictInnerIterWells); strict_outer_iter_wells_ = EWOMS_GET_PARAM(TypeTag, int, StrictOuterIterWells); - regularization_factor_ms_wells_ = EWOMS_GET_PARAM(TypeTag, Scalar, RegularizationFactorMsw); + regularization_factor_wells_ = EWOMS_GET_PARAM(TypeTag, Scalar, RegularizationFactorWells); max_niter_inner_well_iter_ = EWOMS_GET_PARAM(TypeTag, int, MaxNewtonIterationsWithInnerWellIterations); shut_unsolvable_wells_ = EWOMS_GET_PARAM(TypeTag, bool, ShutUnsolvableWells); max_inner_iter_wells_ = EWOMS_GET_PARAM(TypeTag, int, MaxInnerIterWells); @@ -485,7 +485,7 @@ namespace Opm EWOMS_REGISTER_PARAM(TypeTag, bool, ShutUnsolvableWells, "Shut unsolvable wells"); EWOMS_REGISTER_PARAM(TypeTag, int, MaxInnerIterWells, "Maximum number of inner iterations for standard wells"); EWOMS_REGISTER_PARAM(TypeTag, bool, AlternativeWellRateInit, "Use alternative well rate initialization procedure"); - EWOMS_REGISTER_PARAM(TypeTag, Scalar, RegularizationFactorMsw, "Regularization factor for ms wells"); + EWOMS_REGISTER_PARAM(TypeTag, Scalar, RegularizationFactorWells, "Regularization factor for wells"); EWOMS_REGISTER_PARAM(TypeTag, Scalar, MaxSinglePrecisionDays, "Maximum time step size where single precision floating point arithmetic can be used solving for the linear systems of equations"); EWOMS_REGISTER_PARAM(TypeTag, int, MaxStrictIter, "Maximum number of Newton iterations before relaxed tolerances are used for the CNV convergence criterion"); EWOMS_REGISTER_PARAM(TypeTag, bool, SolveWelleqInitially, "Fully solve the well equations before each iteration of the reservoir model"); diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index 111be856a..4f9af6d54 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -1636,7 +1636,7 @@ namespace Opm // Add a regularization_factor to increase the accumulation term // This will make the system less stiff and help convergence for // difficult cases - const Scalar regularization_factor = this->regularize_? this->param_.regularization_factor_ms_wells_ : 1.0; + const Scalar regularization_factor = this->regularize_? this->param_.regularization_factor_wells_ : 1.0; // for each component for (int comp_idx = 0; comp_idx < this->num_components_; ++comp_idx) { const EvalWell accumulation_term = regularization_factor * (segment_surface_volume * this->surfaceVolumeFraction(seg, comp_idx) diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index ec0bbcbf7..275d62817 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -451,8 +451,8 @@ namespace Opm DeferredLogger& deferred_logger) { // try to regularize equation if the well does not converge - const Scalar regularization_factor = this->regularize_? this->param_.regularization_factor_ms_wells_ : 1.0; - const double volume = 0.002831684659200 * regularization_factor; // 0.1 cu ft; + const Scalar regularization_factor = this->regularize_? this->param_.regularization_factor_wells_ : 1.0; + const double volume = 0.1 * unit::cubic(unit::feet) * regularization_factor; auto& ws = well_state.well(this->index_of_well_);