From 22b94b75e625c901a1d7057e4e45791d097bc1f3 Mon Sep 17 00:00:00 2001 From: babrodtk Date: Fri, 7 Aug 2015 07:58:44 +0200 Subject: [PATCH] VFP table which maps THP==BHP gives identical results --- opm/autodiff/BlackoilModelBase_impl.hpp | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 1e3d9bef4..2bc709419 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -1178,6 +1178,8 @@ namespace detail { // switch control to first broken constraint. const int np = wells().number_of_phases; const int nw = wells().number_of_wells; + const Opm::PhaseUsage& pu = fluid_.phaseUsage(); + const std::vector wr = xw.wellRates(); for (int w = 0; w < nw; ++w) { const WellControls* wc = wells().ctrls[w]; // The current control in the well state overrides @@ -1224,9 +1226,29 @@ namespace detail { xw.bhp()[w] = target; break; - case THP: - xw.thp()[w] = target; + case THP: { + double aqua = 0.0; + double liquid = 0.0; + double vapour = 0.0; + + if (active_[ Water ]) { + aqua = wr[w*np + pu.phase_pos[ Water ] ]; + } + if (active_[ Oil ]) { + liquid = wr[w*np + pu.phase_pos[ Oil ] ]; + } + if (active_[ Gas ]) { + vapour = wr[w*np + pu.phase_pos[ Gas ] ]; + } + + const int vfp = well_controls_iget_vfp(wc, current); + const double& thp = well_controls_iget_target(wc, current); + const double& alq = well_controls_iget_alq(wc, current); + + //Set *BHP* target by calculating bhp from THP + xw.bhp()[w] = vfp_properties_->getProd()->bhp(vfp, aqua, liquid, vapour, thp, alq).value; break; + } case RESERVOIR_RATE: // No direct change to any observable quantity at