Store Raw WELPI in Well::productivity_index

This makes the interface less convenient to use, but it is the only
way to guarantee that we have a consistent notion of preferred phase
for injectors.  The downside is that the users of

    Well::getWellPIScalingFactor()

must convert the argument to raw/input units before calling the
function.
This commit is contained in:
Bård Skaflestad 2020-10-28 22:13:01 +01:00
parent 6f124fb478
commit 54e2eb5597
2 changed files with 7 additions and 19 deletions

View File

@ -1108,10 +1108,6 @@ namespace {
using WELL_NAME = ParserKeywords::WELPI::WELL_NAME;
using PI = ParserKeywords::WELPI::STEADY_STATE_PRODUCTIVITY_OR_INJECTIVITY_INDEX_VALUE;
const auto& usys = handlerContext.section.unitSystem();
const auto gasPI = UnitSystem::measure::gas_productivity_index;
const auto liqPI = UnitSystem::measure::liquid_productivity_index;
for (const auto& record : handlerContext.keyword) {
const auto well_names = this->wellNames(record.getItem<WELL_NAME>().getTrimmedString(0),
handlerContext.currentStep);
@ -1123,18 +1119,15 @@ namespace {
const auto rawProdIndex = record.getItem<PI>().get<double>(0);
for (const auto& well_name : well_names) {
// All wells in a single record *hopefully* have the same preferred phase...
const auto& well = this->getWell(well_name, handlerContext.currentStep);
const auto unitPI = (well.getPreferredPhase() == Phase::GAS) ? gasPI : liqPI;
auto well2 = std::make_shared<Well>(this->getWell(well_name, handlerContext.currentStep));
// Note: Need to ensure we have an independent copy of
// well's connections because
// Well::updateWellProductivityIndex() implicitly mutates
// internal state in the WellConnections class.
auto well2 = std::make_shared<Well>(well);
auto connections = std::make_shared<WellConnections>(well2->getConnections());
well2->forceUpdateConnections(std::move(connections));
if (well2->updateWellProductivityIndex(usys.to_si(unitPI, rawProdIndex)))
if (well2->updateWellProductivityIndex(rawProdIndex))
this->updateWell(std::move(well2), handlerContext.currentStep);
this->addWellGroupEvent(well_name, ScheduleEvents::WELL_PRODUCTIVITY_INDEX, handlerContext.currentStep);

View File

@ -60,11 +60,6 @@
using namespace Opm;
namespace {
double liquid_PI_unit()
{
return UnitSystem::newMETRIC().to_si(UnitSystem::measure::liquid_productivity_index, 1.0);
}
double cp_rm3_per_db()
{
return prefix::centi*unit::Poise * unit::cubic(unit::meter)
@ -3816,7 +3811,7 @@ END
const auto expectCF = (200.0 / 100.0) * 100.0*cp_rm3_per_db();
auto wellP = sched.getWell("P", 1);
const auto scalingFactor = wellP.getWellPIScalingFactor(100.0*liquid_PI_unit());
const auto scalingFactor = wellP.getWellPIScalingFactor(100.0);
BOOST_CHECK_CLOSE(scalingFactor, 2.0, 1.0e-10);
std::vector<bool> scalingApplicable;
@ -3835,7 +3830,7 @@ END
const auto expectCF = (200.0 / 100.0) * 100.0*cp_rm3_per_db();
auto wellP = sched.getWell("P", 2);
const auto scalingFactor = wellP.getWellPIScalingFactor(100.0*liquid_PI_unit());
const auto scalingFactor = wellP.getWellPIScalingFactor(100.0);
BOOST_CHECK_CLOSE(scalingFactor, 2.0, 1.0e-10);
std::vector<bool> scalingApplicable;
@ -3959,7 +3954,7 @@ END
// Apply WELPI scaling after end of time series => no change to CTFs
{
const auto report_step = std::size_t{1};
const auto scalingFactor = getScalingFactor(report_step, 100.0*liquid_PI_unit());
const auto scalingFactor = getScalingFactor(report_step, 100.0);
BOOST_CHECK_CLOSE(scalingFactor, 2.0, 1.0e-10);
@ -4025,7 +4020,7 @@ END
// Apply WELPI scaling after first WELPI specification
{
const auto report_step = std::size_t{1};
const auto scalingFactor = getScalingFactor(report_step, 100.0*liquid_PI_unit());
const auto scalingFactor = getScalingFactor(report_step, 100.0);
BOOST_CHECK_CLOSE(scalingFactor, 2.0, 1.0e-10);
@ -4093,7 +4088,7 @@ END
// Apply WELPI scaling after second WELPI specification
{
const auto report_step = std::size_t{3};
const auto scalingFactor = getScalingFactor(report_step, 200.0*liquid_PI_unit());
const auto scalingFactor = getScalingFactor(report_step, 200.0);
BOOST_CHECK_CLOSE(scalingFactor, 0.25, 1.0e-10);