From b32e2f6b3224131bc8335db28647a0843f64abdf Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 25 Nov 2024 15:43:59 +0100 Subject: [PATCH] Guard against small rates in fraction calculation --- opm/simulators/wells/BlackoilWellModelGeneric.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 4ad94f447..d77c36352 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -1222,7 +1222,9 @@ updateAndCommunicateGroupData(const int reportStepIdx, phaseIdx, /*isInjector*/ false); } - Scalar rel_change = std::abs( (gr_rate_nupcol - gr_rate) / (0.5*gr_rate_nupcol + 0.5*gr_rate)); + Scalar small_rate = 1e-12; // m3/s + Scalar denominator = (0.5*gr_rate_nupcol + 0.5*gr_rate); + Scalar rel_change = denominator > small_rate ? std::abs( (gr_rate_nupcol - gr_rate) / denominator) : 0.0; if ( rel_change > tol_nupcol) { this->updateNupcolWGState(); const std::string control_str = is_vrep? "VREP" : "REIN";