diff --git a/opm/autodiff/MultisegmentWell.hpp b/opm/autodiff/MultisegmentWell.hpp index 772297919..a124a7cae 100644 --- a/opm/autodiff/MultisegmentWell.hpp +++ b/opm/autodiff/MultisegmentWell.hpp @@ -332,7 +332,7 @@ namespace Opm // handling the overshooting and undershooting of the fractions void processFractions(const int seg) const; - void updateWellStateFromPrimaryVariabls(WellState& well_state) const; + void updateWellStateFromPrimaryVariables(WellState& well_state) const; }; // obtain y = D^-1 * x diff --git a/opm/autodiff/MultisegmentWell_impl.hpp b/opm/autodiff/MultisegmentWell_impl.hpp index 555372c99..8605f4f4b 100644 --- a/opm/autodiff/MultisegmentWell_impl.hpp +++ b/opm/autodiff/MultisegmentWell_impl.hpp @@ -787,24 +787,27 @@ namespace Opm primary_variables_[seg][GFrac] = old_primary_variables[seg][GFrac] - dx_limited; } + // handling the overshooting or undershooting of the fractions + processFractions(seg); + // update the segment pressure { const int sign = dwells[seg][SPres] > 0.? 1 : -1; - const double dx_limited = sign * std::min(std::abs(dwells[seg][SPres]), dBHPLimit); + const double current_pressure = old_primary_variables[seg][SPres]; + const double dx_limited = sign * std::min(std::abs(dwells[seg][SPres]), dBHPLimit * current_pressure); primary_variables_[seg][SPres] = old_primary_variables[seg][SPres] - dx_limited; } - // update the total rate // TODO: should we have a limitation of the total rate change + + // update the total rate // TODO: should we have a limitation of the total rate change? { - primary_variables_[seg][SPres] = old_primary_variables[seg][SPres] - dwells[seg][SPres]; + primary_variables_[seg][GTotal] = old_primary_variables[seg][GTotal] - dwells[seg][GTotal]; } // TODO: not handling solvent related for now - // handling the overshooting or undershooting of the fraction first - processFractions(seg); } - updateWellStateFromPrimaryVariabls(well_state); + updateWellStateFromPrimaryVariables(well_state); } @@ -1583,7 +1586,7 @@ namespace Opm template void MultisegmentWell:: - updateWellStateFromPrimaryVariabls(WellState& well_state) const + updateWellStateFromPrimaryVariables(WellState& well_state) const { for (int seg = 0; seg < numberOfSegments(); ++seg) { std::vector fractions(number_of_phases_, 0.0);