From 52746a645598d401633665aa1aac91befc4e5da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Fri, 16 May 2014 09:07:43 +0200 Subject: [PATCH] Fix two bugs in updateWellControls(). The bugs were: - Not accounting for the different storage orders used for the state.qs variable and the WellState*::wellRates() field. - When switching to rate control, well rates for phases other than that to be controlled by were set to zero. --- opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 24e57e925..357b21a7e 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -458,8 +458,8 @@ namespace { // Initial well rates. assert (not xw.wellRates().empty()); - // Need to reshuffle well rates, from ordered by wells, then phase, - // to ordered by phase, then wells. + // Need to reshuffle well rates, from phase running fastest + // to wells running fastest. const int nw = wells_.number_of_wells; // The transpose() below switches the ordering. const DataBlock wrates = Eigen::Map(& xw.wellRates()[0], nw, np).transpose(); @@ -1059,7 +1059,9 @@ namespace { break; case SURFACE_RATE: for (int phase = 0; phase < np; ++phase) { - xw.wellRates()[np*w + phase] = target * distr[phase]; + if (distr[phase] > 0.0) { + xw.wellRates()[np*w + phase] = target * distr[phase]; + } } rates_changed = true; break; @@ -1076,7 +1078,11 @@ namespace { bhp = ADB::function(new_bhp, bhp.derivative()); } if (rates_changed) { - ADB::V new_qs = Eigen::Map(xw.wellRates().data(), np*nw); + // Need to reshuffle well rates, from phase running fastest + // to wells running fastest. + // The transpose() below switches the ordering. + const DataBlock wrates = Eigen::Map(xw.wellRates().data(), nw, np).transpose(); + const ADB::V new_qs = Eigen::Map(wrates.data(), nw*np); well_phase_flow_rate = ADB::function(new_qs, well_phase_flow_rate.derivative()); } }