From 00f7f8a7a05b64caee62e8bb22d6ef217db54259 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Tue, 1 Sep 2026 09:34:34 +0200 Subject: [PATCH] Ensure GUIDRAT is checked when WGRUPCON value is defaulted + add utility function to get potential. --- .../eclipse/Schedule/Group/GuideRate.cpp | 22 ++++++++++++++++++- .../eclipse/Schedule/Group/GuideRate.hpp | 8 +++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/opm/input/eclipse/Schedule/Group/GuideRate.cpp b/opm/input/eclipse/Schedule/Group/GuideRate.cpp index d5c999ac54d..eef2e0b0429 100644 --- a/opm/input/eclipse/Schedule/Group/GuideRate.cpp +++ b/opm/input/eclipse/Schedule/Group/GuideRate.cpp @@ -133,6 +133,24 @@ double Opm::GuideRate::get(const std::string& name, const Phase& phase) const return iter->second; } +double Opm::GuideRate::getPotential(const std::string& name, + const GuideRateModel::Target model_target) const +{ + if ((model_target == GuideRateModel::Target::NONE) || + (model_target == GuideRateModel::Target::COMB)) + { + // No potential can be associated with these targets. + return 0.0; + } + + auto pot = this->potentials.find(name); + if (pot == this->potentials.end()) { + return 0.0; + } + + return pot->second.eval(model_target); +} + double Opm::GuideRate::getSI(const std::string& well, const Well::GuideRateTarget target, const RateVector& rates) const @@ -340,9 +358,11 @@ void Opm::GuideRate::well_compute(const std::string& wgname, const auto& model = config.has_model() ? config.model() : GuideRateModel{}; this->assign_grvalue(wgname, model, { sim_time, well.guide_rate, model_target }); + return; } } - else if (config.has_model()) { // GUIDERAT + // A well can have WGRUPCON with defaulted guide rate, in which case we must check for GUIDRAT + if (config.has_model()) { // GUIDERAT if (! this->schedule.hasWell(wgname, report_step)) { // 'wgname' might be a group or the well is not yet online. return; diff --git a/opm/input/eclipse/Schedule/Group/GuideRate.hpp b/opm/input/eclipse/Schedule/Group/GuideRate.hpp index 156000c0a66..b2f33b9f2cc 100644 --- a/opm/input/eclipse/Schedule/Group/GuideRate.hpp +++ b/opm/input/eclipse/Schedule/Group/GuideRate.hpp @@ -145,6 +145,14 @@ class GuideRate double get(const std::string& name, const GuideRateModel::Target model_target, const RateVector& rates) const; double get(const std::string& group, const Phase& phase) const; + /// \brief Guide rate of a well or group based on its potentials alone. + /// + /// This is the value that get() returns when no GUIDERAT/WGRUPCON guide + /// rate has been computed for 'name'. Callers that need the "default" + /// (potential based) guide rate irrespective of whether GUIDERAT is + /// active use this accessor. Returns 0.0 if no potentials are stored. + double getPotential(const std::string& name, const GuideRateModel::Target model_target) const; + double getSI(const std::string& well, const WellGuideRateTarget target, const RateVector& rates) const; double getSI(const std::string& group, const Group::GuideRateProdTarget target, const RateVector& rates) const; double getSI(const std::string& wgname, const GuideRateModel::Target target, const RateVector& rates) const;