From b9b0257e8aedbe67ae6a31c0e64736b115b39f5e Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 9 Dec 2024 13:21:01 +0100 Subject: [PATCH] avoid negative rs/rv max --- opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp b/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp index b208334d7..b789dbe19 100644 --- a/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp +++ b/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp @@ -289,11 +289,11 @@ copyToWellState(const MultisegmentWellGeneric& mswell, Scalar rvMax = 0.0; if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { // Both oil and gas active. - rsMax = FluidSystem::oilPvt() - .saturatedGasDissolutionFactor(pvtReg, temperature, segment_pressure[seg]); + rsMax = std::max(Scalar{0.0}, FluidSystem::oilPvt() + .saturatedGasDissolutionFactor(pvtReg, temperature, segment_pressure[seg])); - rvMax = FluidSystem::gasPvt() - .saturatedOilVaporizationFactor(pvtReg, temperature, segment_pressure[seg]); + rvMax = std::max(Scalar{0.0}, FluidSystem::gasPvt() + .saturatedOilVaporizationFactor(pvtReg, temperature, segment_pressure[seg])); } // 1) Infer phase splitting for oil/gas.