From c6bbe5d24b6977efac2b01b427356561e07abb9b Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Thu, 3 Jan 2019 12:21:25 +0100 Subject: [PATCH] re-organizing the history() for WellProductionProperties --- .../EclipseState/Schedule/Schedule.cpp | 8 ++ .../Schedule/WellProductionProperties.cpp | 81 ++++++++++--------- .../SCHEDULE/SCHEDULE_SHUT_WELL | 2 +- 3 files changed, 54 insertions(+), 37 deletions(-) diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index efb508903..ceb6bdc5d 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -986,6 +986,9 @@ namespace Opm { updateWellStatus( *well, currentStep, status ); WellInjectionProperties properties(well->getInjectionPropertiesCopy(currentStep)); + std::cout << " well " << well->name() << " currentStep " << currentStep << " prev_properties " << std::endl + << properties << std::endl; + properties.injectorType = injectorType; if (!record.getItem("RATE").defaultApplied(0)) { @@ -1004,6 +1007,8 @@ namespace Opm { // Otherwise, we need to make a decision // TODO: some tests are required to check how WELTARG interacts with WCONINJH BHP control const bool switching_from_producer = well->isProducer(currentStep); + std::cout << " well " << well->name() << " switching_from_producer " << switching_from_producer + << " at report step " << currentStep << std::endl; if (properties.predictionMode || properties.controlMode == WellInjector::BHP || switching_from_producer) { // there is no document about what value the default BHP limit should be // we use the one from WCONINJE for now @@ -1025,6 +1030,9 @@ namespace Opm { properties.VFPTableNumber = VFPTableNumber; } + std::cout << " well " << well->name() << " currentStep " << currentStep << " new_properties " << std::endl + << properties << std::endl; + if (well->setInjectionProperties(currentStep, properties)) m_events.addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep ); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp index 077603f9a..492b9c0c3 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp @@ -53,47 +53,56 @@ namespace Opm { // update LiquidRate p.LiquidRate = p.WaterRate + p.OilRate; - const auto& cmodeItem = record.getItem("CMODE"); - if ( !cmodeItem.defaultApplied(0) ) { - namespace wp = WellProducer; - auto cmode = wp::ControlModeFromString( cmodeItem.getTrimmedString( 0 ) ); - - // when there is an effective control mode specified by WHISTCL, we always use this control mode - if (effectiveHistoryProductionControl(controlModeWHISTCL) ) { - cmode = controlModeWHISTCL; - } - - if (effectiveHistoryProductionControl(cmode) ) { - p.addProductionControl( cmode ); - p.controlMode = cmode; - } else { - const std::string cmode_string = cmodeItem.getTrimmedString( 0 ); - const std::string msg = "unsupported control mode " + cmode_string + " for WCONHIST"; - throw std::invalid_argument(msg); - } - - // always have a BHP control/limit, while the limit value needs to be determined - // the control mode added above can be a BHP control or a type of RATE control - if ( !p.hasProductionControl( wp::BHP ) ) - p.addProductionControl( wp::BHP ); - - if (cmode == wp::BHP) { - p.BHPLimit = record.getItem( "BHP" ).getSIDouble( 0 ); - } else { - if (!prev_properties.predictionMode && !switching_from_injector) { - p.BHPLimit = prev_properties.BHPLimit; - } else { - // by default the BHP limit is 1 atm - p.BHPLimit = 1. * unit::atm; - } - } - } - if ( record.getItem( "BHP" ).hasValue(0) ) p.BHPH = record.getItem("BHP").getSIDouble(0); if ( record.getItem( "THP" ).hasValue(0) ) p.THPH = record.getItem("THP").getSIDouble(0); + const auto& cmodeItem = record.getItem("CMODE"); + + if ( cmodeItem.defaultApplied(0) ) { + const std::string msg = "control mode can not be defaulted for keyword WCONHIST"; + throw std::invalid_argument(msg); + } + + namespace wp = WellProducer; + auto cmode = wp::ControlModeFromString( cmodeItem.getTrimmedString( 0 ) ); + + // when there is an effective control mode specified by WHISTCL, we always use this control mode + if (effectiveHistoryProductionControl(controlModeWHISTCL) ) { + cmode = controlModeWHISTCL; + } + + if (effectiveHistoryProductionControl(cmode) ) { + p.addProductionControl( cmode ); + p.controlMode = cmode; + } else { + const std::string cmode_string = cmodeItem.getTrimmedString( 0 ); + const std::string msg = "unsupported control mode " + cmode_string + " for WCONHIST"; + throw std::invalid_argument(msg); + } + + // always have a BHP control/limit, while the limit value needs to be determined + // the control mode added above can be a BHP control or a type of RATE control + if ( !p.hasProductionControl( wp::BHP ) ) + p.addProductionControl( wp::BHP ); + + if (cmode == wp::BHP) { + p.BHPLimit = p.BHPH; + } else { + // when first time the well is claimed to be history matching producer + // or switching from injector to producer + // or switching from BHP control to RATE control + // we use the defaulted BHP limit, otherwise, we use the previous BHP limit + if ( prev_properties.predictionMode || switching_from_injector + || prev_properties.controlMode == wp::BHP ) { + // by default the BHP limit is 1 atm + p.BHPLimit = 1. * unit::atm; + } else { + p.BHPLimit = prev_properties.BHPLimit; + } + } + p.VFPTableNumber = record.getItem("VFPTable").get< int >(0); if (p.VFPTableNumber == 0) diff --git a/tests/parser/data/integration_tests/SCHEDULE/SCHEDULE_SHUT_WELL b/tests/parser/data/integration_tests/SCHEDULE/SCHEDULE_SHUT_WELL index d0cdc9ae2..51ad0cd49 100644 --- a/tests/parser/data/integration_tests/SCHEDULE/SCHEDULE_SHUT_WELL +++ b/tests/parser/data/integration_tests/SCHEDULE/SCHEDULE_SHUT_WELL @@ -70,7 +70,7 @@ WELOPEN / WCONHIST - 'W3' 'SHUT' / + 'W3' 'SHUT' 'ORAT'/ /