From 65c323e1a4319cab974b547b56781da6552fb79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Mon, 31 Jan 2022 01:39:11 +0100 Subject: [PATCH] Replace assert with warning. Replace assert with warning when group rates exceeds target. --- .../wells/GasLiftSingleWellGeneric.cpp | 19 ++++++++++++++++++- .../wells/GasLiftSingleWellGeneric.hpp | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/opm/simulators/wells/GasLiftSingleWellGeneric.cpp b/opm/simulators/wells/GasLiftSingleWellGeneric.cpp index cd6344643..81669131f 100644 --- a/opm/simulators/wells/GasLiftSingleWellGeneric.cpp +++ b/opm/simulators/wells/GasLiftSingleWellGeneric.cpp @@ -737,7 +737,10 @@ getRateWithGroupLimit_( double gr_target_temp = *gr_target_opt; double gr_rate_temp = this->group_info_.getRate(rate_type, group_name_temp); - assert(gr_rate_temp <= gr_target_temp); + if (gr_rate_temp > gr_target_temp) { + warnGroupInfoGroupRatesExceedTarget( + rate_type, group_name_temp, gr_rate_temp, gr_target_temp); + } double new_gr_rate_temp = gr_rate_temp + efficiency_temp * delta_rate; if (new_gr_rate_temp > gr_target_temp) { double limited_rate_temp = @@ -1334,6 +1337,20 @@ useFixedAlq_(const GasLiftOpt::Well& well) return true; } } + +void +GasLiftSingleWellGeneric:: +warnGroupInfoGroupRatesExceedTarget( + Rate rate_type, const std::string& gr_name, double rate, double target) const +{ + double fraction = 100.0*std::fabs(rate-target)/target; + const std::string msg = fmt::format("Warning: {} rate for group {} exceeds target: " + "rate = {}, target = {}, relative overrun = {}%", + GasLiftGroupInfo::rateToString(rate_type), + gr_name, rate, target, fraction); + displayDebugMessage_(msg); +} + void GasLiftSingleWellGeneric:: warnMaxIterationsExceeded_() diff --git a/opm/simulators/wells/GasLiftSingleWellGeneric.hpp b/opm/simulators/wells/GasLiftSingleWellGeneric.hpp index 74482028b..0ea308809 100644 --- a/opm/simulators/wells/GasLiftSingleWellGeneric.hpp +++ b/opm/simulators/wells/GasLiftSingleWellGeneric.hpp @@ -309,6 +309,8 @@ protected: const LimitedRates& rates, const LimitedRates& new_rates) const; void updateWellStateAlqFixedValue_(const GasLiftOpt::Well& well); bool useFixedAlq_(const GasLiftOpt::Well& well); + void warnGroupInfoGroupRatesExceedTarget( + Rate rate_type, const std::string& gr_name, double rate, double target) const; void warnMaxIterationsExceeded_(); const GroupState& group_state_;