Merge pull request #6185 from lisajulia/fix/divisions-by-zero

Do not divide by zero but check before dividing
This commit is contained in:
Markus Blatt authored and GitHub committed 2025-04-24 12:51:10 +02:00
commit 357c60c2ba
2 files changed
+5 -9

No files matched your search

+4 -8
View File
@@ -557,11 +557,9 @@ production(const std::size_t reportStepNum,
if (values[Ix::WaterRate] == 0.0) {
values[Ix::WatGasRatio] = 0;
} else {
} else if (values[Ix::GasRate] != 0.0) {
values[Ix::WatGasRatio] = values[Ix::WaterRate] / values[Ix::GasRate];
}
if (std::isnan(values[Ix::WatGasRatio])) {
} else {
values[Ix::WatGasRatio] = 0.0;
}
@@ -600,11 +598,9 @@ production(const std::size_t reportStepNum,
{
if (v[Ix::WaterRate] == 0.0) {
v[Ix::WatGasRatio] = 0.0;
} else {
} else if (v[Ix::GasRate] != 0.0) {
v[Ix::WatGasRatio] = v[Ix::WaterRate] / v[Ix::GasRate];
}
if (std::isnan(v[Ix::WatGasRatio])) {
} else {
v[Ix::WatGasRatio] = 0.0;
}
};
+1 -1
View File
@@ -35,7 +35,7 @@ pressureAverage(const Scalar pressurePvHydrocarbon,
if (hydrocarbon && (pvHydrocarbon > 1e-10))
return pressurePvHydrocarbon / pvHydrocarbon;
return pressurePv / pv;
return (pressurePv == 0) ? 0 : pressurePv / pv;
}
template<class Scalar>