diff --git a/opm/simulators/wells/WellBhpThpCalculator.cpp b/opm/simulators/wells/WellBhpThpCalculator.cpp index 6081e8afe..2fdb8caf1 100644 --- a/opm/simulators/wells/WellBhpThpCalculator.cpp +++ b/opm/simulators/wells/WellBhpThpCalculator.cpp @@ -132,7 +132,8 @@ double WellBhpThpCalculator::calculateThpFromBhp(const std::vector& rate const double vfp_ref_depth = well_.vfpProperties()->getProd()->getTable(table_id).getDatumDepth(); const double dp = wellhelpers::computeHydrostaticCorrection(well_.refDepth(), vfp_ref_depth, rho, well_.gravity()); - thp = well_.vfpProperties()->getProd()->thp(table_id, aqua, liquid, vapour, bhp + dp, alq); + thp = well_.vfpProperties()->getProd()->thp( + table_id, aqua, liquid, vapour, bhp + dp - pressure_loss, alq.value()); } else { OPM_DEFLOG_THROW(std::logic_error, "Expected INJECTOR or PRODUCER well", deferred_logger); @@ -273,8 +274,9 @@ void WellBhpThpCalculator::updateThp(const double rho, if (active[Gas]) { rates[ Gas ] = ws.surface_rates[pu.phase_pos[ Gas ] ]; } - - ws.thp = this->calculateThpFromBhp(rates, ws.bhp, rho, alq_value(), deferred_logger); + const std::optional alq = this->well_.isProducer() ? std::optional(alq_value()) : std::nullopt; + const double thp_limit = well_.getTHPConstraint(summary_state); + ws.thp = this->calculateThpFromBhp(rates, ws.bhp, rho, alq_value(), thp_limit, deferred_logger); } template