Guard against small rates in fraction calculation

This commit is contained in:
Tor Harald Sandve 2024-11-25 15:43:59 +01:00
parent 554acb4019
commit b32e2f6b32

View File

@ -1222,7 +1222,9 @@ updateAndCommunicateGroupData(const int reportStepIdx,
phaseIdx, phaseIdx,
/*isInjector*/ false); /*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) { if ( rel_change > tol_nupcol) {
this->updateNupcolWGState(); this->updateNupcolWGState();
const std::string control_str = is_vrep? "VREP" : "REIN"; const std::string control_str = is_vrep? "VREP" : "REIN";