Bug fix: nan if liquid rate was zero

This commit is contained in:
Svenn Tveit 2024-10-24 09:37:03 +02:00 committed by Tor Harald Sandve
parent 4ffee2c359
commit b42537155e

View File

@ -545,9 +545,11 @@ getProducerWellRates_(const Well* well, int well_index)
}
if (controls.hasControl(Well::ProducerCMode::LRAT)) {
Scalar liquid_rate = oil_rate + water_rate;
Scalar liquid_rate_lim = std::min(static_cast<Scalar>(controls.liquid_rate), liquid_rate);
water_rate = water_rate / liquid_rate * liquid_rate_lim;
oil_rate = oil_rate / liquid_rate * liquid_rate_lim;
Scalar liquid_rate_lim = static_cast<Scalar>(controls.liquid_rate);
if (liquid_rate > liquid_rate_lim) {
water_rate = water_rate / liquid_rate * liquid_rate_lim;
oil_rate = oil_rate / liquid_rate * liquid_rate_lim;
}
}
return {oil_rate, gas_rate, water_rate, oil_pot, gas_pot, water_pot};
@ -656,9 +658,11 @@ initializeGroupRatesRecursive_(const Group& group)
water_rate = std::min(water_rate, *water_target);
if (liquid_target) {
Scalar liquid_rate = oil_rate + water_rate;
Scalar liquid_rate_limited = std::min(liquid_rate, *liquid_target);
oil_rate = oil_rate / liquid_rate * liquid_rate_limited;
water_rate = water_rate / liquid_rate * liquid_rate_limited;
Scalar liquid_rate_limited = *liquid_target;
if (liquid_rate > liquid_rate_limited) {
oil_rate = oil_rate / liquid_rate * liquid_rate_limited;
water_rate = water_rate / liquid_rate * liquid_rate_limited;
}
}
}
return std::make_tuple(oil_rate, gas_rate, water_rate, oil_potential, gas_potential, water_potential, alq);