From 5eaed335b9ab69b30957c26e95accc941cf1893a Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 21 Mar 2014 00:35:15 +0100 Subject: [PATCH] Changed the access to Parser/EclipseState/Schedule to use new well injection and production properties. To be aligned with opm-parser:e75970a28b96374409a55e3e6cea2198b6a0ea23 --- opm/core/wells/WellsGroup.cpp | 22 ++++---- opm/core/wells/WellsManager.cpp | 94 ++++++++++++++++++--------------- tests/test_wellsgroup.cpp | 16 +++--- 3 files changed, 71 insertions(+), 61 deletions(-) diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index ee45b6ed..050e1871 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -1171,19 +1171,21 @@ namespace Opm InjectionSpecification injection_specification; ProductionSpecification production_specification; if (well->isInjector(timeStep)) { - injection_specification.BHP_limit_ = well->getBHPLimit(timeStep); - injection_specification.injector_type_ = toInjectorType(WellInjector::Type2String(well->getInjectorType(timeStep))); - injection_specification.control_mode_ = toInjectionControlMode(WellInjector::ControlMode2String(well->getInjectorControlMode(timeStep))); - injection_specification.surface_flow_max_rate_ = well->getSurfaceInjectionRate(timeStep); - injection_specification.reservoir_flow_max_rate_ = well->getReservoirInjectionRate(timeStep); + const WellInjectionProperties& properties = well->getInjectionProperties(timeStep); + injection_specification.BHP_limit_ = properties.BHPLimit; + injection_specification.injector_type_ = toInjectorType(WellInjector::Type2String(properties.injectorType)); + injection_specification.control_mode_ = toInjectionControlMode(WellInjector::ControlMode2String(properties.controlMode)); + injection_specification.surface_flow_max_rate_ = properties.surfaceInjectionRate; + injection_specification.reservoir_flow_max_rate_ = properties.reservoirInjectionRate; production_specification.guide_rate_ = 0.0; // We know we're not a producer } else if (well->isProducer(timeStep)) { - production_specification.BHP_limit_ = well->getBHPLimit(timeStep); - production_specification.reservoir_flow_max_rate_ = well->getResVRate(timeStep); - production_specification.oil_max_rate_ = well->getOilRate(timeStep); - production_specification.control_mode_ = toProductionControlMode(WellProducer::ControlMode2String(well->getProducerControlMode(timeStep))); - production_specification.water_max_rate_ = well->getWaterRate(timeStep); + const WellProductionProperties& properties = well->getProductionProperties(timeStep); + production_specification.BHP_limit_ = properties.BHPLimit; + production_specification.reservoir_flow_max_rate_ = properties.ResVRate; + production_specification.oil_max_rate_ = properties.OilRate; + production_specification.control_mode_ = toProductionControlMode(WellProducer::ControlMode2String(properties.controlMode)); + production_specification.water_max_rate_ = properties.WaterRate; injection_specification.guide_rate_ = 0.0; // we know we're not an injector } std::shared_ptr wells_group(new WellNode(well->name(), production_specification, injection_specification, phase_usage)); diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index c438b29e..3421d3c2 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -1131,14 +1131,15 @@ namespace Opm } if (well->isInjector(timeStep)) { - clear_well_controls(well_index, w_); + const WellInjectionProperties& injectionProperties = well->getInjectionProperties(timeStep); int ok = 1; int control_pos[5] = { -1, -1, -1, -1, -1 }; - - if (well->hasInjectionControl(timeStep , WellInjector::RATE)) { + + clear_well_controls(well_index, w_); + if (injectionProperties.hasInjectionControl(WellInjector::RATE)) { control_pos[InjectionControl::RATE] = well_controls_get_num(w_->ctrls[well_index]); double distr[3] = { 0.0, 0.0, 0.0 }; - WellInjector::TypeEnum injectorType = well->getInjectorType(timeStep); + WellInjector::TypeEnum injectorType = injectionProperties.injectorType; if (injectorType == WellInjector::TypeEnum::WATER) { distr[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; @@ -1149,16 +1150,16 @@ namespace Opm } ok = append_well_controls(SURFACE_RATE, - well->getSurfaceInjectionRate( timeStep ) , + injectionProperties.surfaceInjectionRate, distr, well_index, w_); } - if (ok && well->hasInjectionControl(timeStep , WellInjector::RESV)) { + if (ok && injectionProperties.hasInjectionControl(WellInjector::RESV)) { control_pos[InjectionControl::RESV] = well_controls_get_num(w_->ctrls[well_index]); double distr[3] = { 0.0, 0.0, 0.0 }; - WellInjector::TypeEnum injectorType = well->getInjectorType(timeStep); + WellInjector::TypeEnum injectorType = injectionProperties.injectorType; if (injectorType == WellInjector::TypeEnum::WATER) { distr[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; @@ -1169,22 +1170,22 @@ namespace Opm } ok = append_well_controls(RESERVOIR_RATE, - well->getReservoirInjectionRate( timeStep ), + injectionProperties.reservoirInjectionRate, distr, well_index, w_); } - if (ok && well->hasInjectionControl(timeStep , WellInjector::BHP)) { + if (ok && injectionProperties.hasInjectionControl(WellInjector::BHP)) { control_pos[InjectionControl::BHP] = well_controls_get_num(w_->ctrls[well_index]); ok = append_well_controls(BHP, - well->getBHPLimit(timeStep), + injectionProperties.BHPLimit, NULL, well_index, w_); } - if (ok && well->hasInjectionControl(timeStep , WellInjector::THP)) { + if (ok && injectionProperties.hasInjectionControl(WellInjector::THP)) { OPM_THROW(std::runtime_error, "We cannot handle THP limit for well " << well_names[well_index]); } @@ -1195,7 +1196,7 @@ namespace Opm { - InjectionControl::Mode mode = InjectionControl::mode( well->getInjectorControlMode(timeStep) ); + InjectionControl::Mode mode = InjectionControl::mode( injectionProperties.controlMode ); int cpos = control_pos[mode]; if (cpos == -1 && mode != InjectionControl::GRUP) { OPM_THROW(std::runtime_error, "Control not specified in well " << well_names[well_index]); @@ -1211,34 +1212,39 @@ namespace Opm // Set well component fraction. double cf[3] = { 0.0, 0.0, 0.0 }; - if (well->getInjectorType(timeStep) == WellInjector::WATER) { - if (!phaseUsage.phase_used[BlackoilPhases::Aqua]) { - OPM_THROW(std::runtime_error, "Water phase not used, yet found water-injecting well."); - } - cf[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; - } else if (well->getInjectorType(timeStep) == WellInjector::OIL) { - if (!phaseUsage.phase_used[BlackoilPhases::Liquid]) { - OPM_THROW(std::runtime_error, "Oil phase not used, yet found oil-injecting well."); - } - cf[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0; - } else if (well->getInjectorType(timeStep) == WellInjector::GAS) { - if (!phaseUsage.phase_used[BlackoilPhases::Vapour]) { - OPM_THROW(std::runtime_error, "Gas phase not used, yet found gas-injecting well."); - } - cf[phaseUsage.phase_pos[BlackoilPhases::Vapour]] = 1.0; - } - std::copy(cf, cf + phaseUsage.num_phases, w_->comp_frac + well_index*phaseUsage.num_phases); + { + WellInjector::TypeEnum injectorType = injectionProperties.injectorType; + if (injectorType == WellInjector::WATER) { + if (!phaseUsage.phase_used[BlackoilPhases::Aqua]) { + OPM_THROW(std::runtime_error, "Water phase not used, yet found water-injecting well."); + } + cf[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; + } else if (injectorType == WellInjector::OIL) { + if (!phaseUsage.phase_used[BlackoilPhases::Liquid]) { + OPM_THROW(std::runtime_error, "Oil phase not used, yet found oil-injecting well."); + } + cf[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0; + } else if (injectorType == WellInjector::GAS) { + if (!phaseUsage.phase_used[BlackoilPhases::Vapour]) { + OPM_THROW(std::runtime_error, "Gas phase not used, yet found gas-injecting well."); + } + cf[phaseUsage.phase_pos[BlackoilPhases::Vapour]] = 1.0; + } + std::copy(cf, cf + phaseUsage.num_phases, w_->comp_frac + well_index*phaseUsage.num_phases); + } } if (well->isProducer(timeStep)) { // Add all controls that are present in well. // First we must clear existing controls, in case the // current WCONPROD line is modifying earlier controls. - clear_well_controls(well_index, w_); + const WellProductionProperties& productionProperties = well->getProductionProperties(timeStep); int control_pos[9] = { -1, -1, -1, -1, -1, -1, -1, -1, -1 }; int ok = 1; - if (ok && well->hasProductionControl(timeStep , WellProducer::ORAT)) { + + clear_well_controls(well_index, w_); + if (ok && productionProperties.hasProductionControl(WellProducer::ORAT)) { if (!phaseUsage.phase_used[BlackoilPhases::Liquid]) { OPM_THROW(std::runtime_error, "Oil phase not active and ORAT control specified."); } @@ -1247,13 +1253,13 @@ namespace Opm double distr[3] = { 0.0, 0.0, 0.0 }; distr[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0; ok = append_well_controls(SURFACE_RATE, - -well->getOilRate( timeStep ), + -productionProperties.OilRate, distr, well_index, w_); } - if (ok && well->hasProductionControl(timeStep , WellProducer::WRAT)) { + if (ok && productionProperties.hasProductionControl(WellProducer::WRAT)) { if (!phaseUsage.phase_used[BlackoilPhases::Aqua]) { OPM_THROW(std::runtime_error, "Water phase not active and WRAT control specified."); } @@ -1261,13 +1267,13 @@ namespace Opm double distr[3] = { 0.0, 0.0, 0.0 }; distr[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; ok = append_well_controls(SURFACE_RATE, - -well->getWaterRate(timeStep), + -productionProperties.WaterRate, distr, well_index, w_); } - if (ok && well->hasProductionControl(timeStep , WellProducer::GRAT)) { + if (ok && productionProperties.hasProductionControl(WellProducer::GRAT)) { if (!phaseUsage.phase_used[BlackoilPhases::Vapour]) { OPM_THROW(std::runtime_error, "Gas phase not active and GRAT control specified."); } @@ -1275,13 +1281,13 @@ namespace Opm double distr[3] = { 0.0, 0.0, 0.0 }; distr[phaseUsage.phase_pos[BlackoilPhases::Vapour]] = 1.0; ok = append_well_controls(SURFACE_RATE, - -well->getGasRate( timeStep ), + -productionProperties.GasRate, distr, well_index, w_); } - if (ok && well->hasProductionControl(timeStep , WellProducer::LRAT)) { + if (ok && productionProperties.hasProductionControl(WellProducer::LRAT)) { if (!phaseUsage.phase_used[BlackoilPhases::Aqua]) { OPM_THROW(std::runtime_error, "Water phase not active and LRAT control specified."); } @@ -1293,32 +1299,32 @@ namespace Opm distr[phaseUsage.phase_pos[BlackoilPhases::Aqua]] = 1.0; distr[phaseUsage.phase_pos[BlackoilPhases::Liquid]] = 1.0; ok = append_well_controls(SURFACE_RATE, - -well->getLiquidRate(timeStep), + -productionProperties.LiquidRate , distr, well_index, w_); } - if (ok && well->hasProductionControl(timeStep , WellProducer::RESV)) { + if (ok && productionProperties.hasProductionControl(WellProducer::RESV)) { control_pos[ProductionControl::RESV] = well_controls_get_num(w_->ctrls[well_index]); double distr[3] = { 1.0, 1.0, 1.0 }; ok = append_well_controls(RESERVOIR_RATE, - -well->getResVRate(timeStep), + -productionProperties.ResVRate , distr, well_index, w_); } - if (ok && well->hasProductionControl(timeStep , WellProducer::BHP)) { + if (ok && productionProperties.hasProductionControl(WellProducer::BHP)) { control_pos[ProductionControl::BHP] = well_controls_get_num(w_->ctrls[well_index]); ok = append_well_controls(BHP, - well->getBHPLimit( timeStep ) , + productionProperties.BHPLimit , NULL, well_index, w_); } - if (ok && well->hasProductionControl(timeStep , WellProducer::THP)) { + if (ok && productionProperties.hasProductionControl(WellProducer::THP)) { OPM_THROW(std::runtime_error, "We cannot handle THP limit for well " << well_names[well_index]); } @@ -1326,7 +1332,7 @@ namespace Opm OPM_THROW(std::runtime_error, "Failure occured appending controls for well " << well_names[well_index]); } - ProductionControl::Mode mode = ProductionControl::mode(well->getProducerControlMode(timeStep)); + ProductionControl::Mode mode = ProductionControl::mode(productionProperties.controlMode); int cpos = control_pos[mode]; if (well->getStatus(timeStep) == WellCommon::SHUT) { well_controls_shut_well( w_->ctrls[well_index] ); diff --git a/tests/test_wellsgroup.cpp b/tests/test_wellsgroup.cpp index 9ba9e0ef..46fd8eb0 100644 --- a/tests/test_wellsgroup.cpp +++ b/tests/test_wellsgroup.cpp @@ -59,16 +59,18 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromWell) { std::shared_ptr wellsGroup = createWellWellsGroup(well, 2, pu); BOOST_CHECK_EQUAL(well->name(), wellsGroup->name()); if (well->isInjector(2)) { - BOOST_CHECK_EQUAL(well->getSurfaceInjectionRate(2), wellsGroup->injSpec().surface_flow_max_rate_); - BOOST_CHECK_EQUAL(well->getBHPLimit(2), wellsGroup->injSpec().BHP_limit_); - BOOST_CHECK_EQUAL(well->getReservoirInjectionRate(2), wellsGroup->injSpec().reservoir_flow_max_rate_); + const WellInjectionProperties& properties = well->getInjectionProperties(2); + BOOST_CHECK_EQUAL(properties.surfaceInjectionRate, wellsGroup->injSpec().surface_flow_max_rate_); + BOOST_CHECK_EQUAL(properties.BHPLimit, wellsGroup->injSpec().BHP_limit_); + BOOST_CHECK_EQUAL(properties.reservoirInjectionRate, wellsGroup->injSpec().reservoir_flow_max_rate_); BOOST_CHECK_EQUAL(0.0, wellsGroup->prodSpec().guide_rate_); } if (well->isProducer(2)) { - BOOST_CHECK_EQUAL(well->getResVRate(2), wellsGroup->prodSpec().reservoir_flow_max_rate_); - BOOST_CHECK_EQUAL(well->getBHPLimit(2), wellsGroup->prodSpec().BHP_limit_); - BOOST_CHECK_EQUAL(well->getOilRate(2), wellsGroup->prodSpec().oil_max_rate_); - BOOST_CHECK_EQUAL(well->getWaterRate(2), wellsGroup->prodSpec().water_max_rate_); + const WellProductionProperties& properties = well->getProductionProperties(2); + BOOST_CHECK_EQUAL(properties.ResVRate, wellsGroup->prodSpec().reservoir_flow_max_rate_); + BOOST_CHECK_EQUAL(properties.BHPLimit, wellsGroup->prodSpec().BHP_limit_); + BOOST_CHECK_EQUAL(properties.OilRate, wellsGroup->prodSpec().oil_max_rate_); + BOOST_CHECK_EQUAL(properties.WaterRate, wellsGroup->prodSpec().water_max_rate_); BOOST_CHECK_EQUAL(0.0, wellsGroup->injSpec().guide_rate_); } }