From db88058b34a2d7712847af1e5a333f42b9671838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Sun, 6 Apr 2014 23:33:43 +0200 Subject: [PATCH] Use preferred phase of producer well to set comp_fraction. This replaces the previous hack, that set comp_fraction to (0,1,0) always. --- opm/core/wells/WellsManager.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index d7ef2c8cb..add4ada07 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -762,10 +762,29 @@ namespace Opm } set_current_control(well_index, cpos, w_); - // Set well component fraction in producers to 1 for all phases. This HACK make sure volrates are nonzero for all perforations. - double cf[3] = { 0, 1, 0}; - std::copy(cf, cf + phaseUsage.num_phases, w_->comp_frac + well_index*phaseUsage.num_phases); - + // Set well component fraction to match preferred phase for the well. + double cf[3] = { 0.0, 0.0, 0.0 }; + { + switch (well->getPreferredPhase()) { + case Phase::WATER: + if (!phaseUsage.phase_used[BlackoilPhases::Aqua]) { + OPM_THROW(std::runtime_error, "Water phase not used, yet found water-preferring well."); + } + cf[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; + break; + case Phase::OIL: + if (!phaseUsage.phase_used[BlackoilPhases::Liquid]) { + OPM_THROW(std::runtime_error, "Oil phase not used, yet found oil-preferring well."); + } + cf[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0; + case Phase::GAS: + if (!phaseUsage.phase_used[BlackoilPhases::Vapour]) { + OPM_THROW(std::runtime_error, "Gas phase not used, yet found gas-preferring well."); + } + cf[phaseUsage.phase_pos[BlackoilPhases::Vapour]] = 1.0; + } + std::copy(cf, cf + phaseUsage.num_phases, w_->comp_frac + well_index*phaseUsage.num_phases); + } } well_index++; }