diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index 4adcbc7f2..751661a90 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -2850,7 +2850,7 @@ namespace Opm { } } - // there should be always some avaible bhp/thp constraints there + // there should be always some available bhp/thp constraints there if (std::isinf(bhp) || std::isnan(bhp)) { OPM_THROW(std::runtime_error, "Unvalid bhp value obtained during the potential calculation for well " << wells().name[well_index]); } @@ -2859,6 +2859,13 @@ namespace Opm { computeWellRatesWithBhp(ebosSimulator, bhp, well_index, potentials); + // checking whether the potentials have valid values + for (const double value : potentials) { + if (std::isinf(value) || std::isnan(value)) { + OPM_THROW(std::runtime_error, "Unvalid potential value obtained during the potential calculation for well " << wells().name[well_index]); + } + } + if (!converged) { old_bhp = bhp; for (int p = 0; p < np; ++p) {