Merge remote-tracking branch 'upstream/master' into timestepcontrol

This commit is contained in:
Robert Kloefkorn 2014-10-17 11:28:04 +02:00
commit e552acc244
4 changed files with 98 additions and 19 deletions

View File

@ -1071,6 +1071,15 @@ namespace Opm
return wells_group;
}
/*
Wells which are shut with the WELOPEN or WCONPROD keywords
typically will not have any valid control settings, it is then
impossible to set a valid control mode. The Schedule::Well
objects from opm-parser have the possible well controle mode
'CMODE_UNDEFINED' - we do not carry that over the specification
objects here.
*/
std::shared_ptr<WellsGroupInterface> createWellWellsGroup(WellConstPtr well, size_t timeStep, const PhaseUsage& phase_usage )
{
InjectionSpecification injection_specification;
@ -1079,19 +1088,23 @@ namespace Opm
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
if (properties.controlMode != WellInjector::CMODE_UNDEFINED) {
injection_specification.control_mode_ = toInjectionControlMode(WellInjector::ControlMode2String(properties.controlMode));
}
}
else if (well->isProducer(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
if (properties.controlMode != WellProducer::CMODE_UNDEFINED) {
production_specification.control_mode_ = toProductionControlMode(WellProducer::ControlMode2String(properties.controlMode));
}
}
std::shared_ptr<WellsGroupInterface> wells_group(new WellNode(well->name(), production_specification, injection_specification, phase_usage));
return wells_group;

View File

@ -413,6 +413,7 @@ namespace Opm
if (well->getStatus(timeStep) == WellCommon::SHUT) {
well_controls_shut_well( w_->ctrls[well_index] );
well_index++;
continue;
}
@ -476,13 +477,11 @@ namespace Opm
OPM_THROW(std::runtime_error, "We cannot handle THP limit for well " << well_names[well_index]);
}
if (!ok) {
OPM_THROW(std::runtime_error, "Failure occured appending controls for well " << well_names[well_index]);
}
{
if (injectionProperties.controlMode != WellInjector::CMODE_UNDEFINED) {
WellsManagerDetail::InjectionControl::Mode mode = WellsManagerDetail::InjectionControl::mode( injectionProperties.controlMode );
int cpos = control_pos[mode];
if (cpos == -1 && mode != WellsManagerDetail::InjectionControl::GRUP) {
@ -492,7 +491,6 @@ namespace Opm
set_current_control(well_index, cpos, w_);
}
// Set well component fraction.
double cf[3] = { 0.0, 0.0, 0.0 };
{
@ -615,16 +613,18 @@ namespace Opm
OPM_THROW(std::runtime_error, "Failure occured appending controls for well " << well_names[well_index]);
}
WellsManagerDetail::ProductionControl::Mode mode = WellsManagerDetail::ProductionControl::mode(productionProperties.controlMode);
int cpos = control_pos[mode];
if (cpos == -1 && mode != WellsManagerDetail::ProductionControl::GRUP) {
OPM_THROW(std::runtime_error, "Control mode type " << mode << " not present in well " << well_names[well_index]);
}
if (cpos == -1 && mode != WellsManagerDetail::ProductionControl::GRUP) {
OPM_THROW(std::runtime_error, "Control mode type " << mode << " not present in well " << well_names[well_index]);
}
else {
set_current_control(well_index, cpos, w_);
if (productionProperties.controlMode != WellProducer::CMODE_UNDEFINED) {
WellsManagerDetail::ProductionControl::Mode mode = WellsManagerDetail::ProductionControl::mode(productionProperties.controlMode);
int cpos = control_pos[mode];
if (cpos == -1 && mode != WellsManagerDetail::ProductionControl::GRUP) {
OPM_THROW(std::runtime_error, "Control mode type " << mode << " not present in well " << well_names[well_index]);
}
if (cpos == -1 && mode != WellsManagerDetail::ProductionControl::GRUP) {
OPM_THROW(std::runtime_error, "Control mode type " << mode << " not present in well " << well_names[well_index]);
}
else {
set_current_control(well_index, cpos, w_);
}
}
// Set well component fraction to match preferred phase for the well.

View File

@ -172,6 +172,23 @@ void check_controls_epoch1( struct WellControls ** ctrls) {
}
}
void check_controls_epoch3( struct WellControls ** ctrls) {
// The new producer
const struct WellControls * ctrls1 = ctrls[1];
const struct WellControls * ctrls2 = ctrls[2];
BOOST_CHECK_EQUAL( 0 , well_controls_get_num(ctrls1));
BOOST_CHECK( well_controls_well_is_shut( ctrls1));
BOOST_CHECK_EQUAL( 0 , well_controls_get_num(ctrls2));
BOOST_CHECK( well_controls_well_is_shut(ctrls2));
}
BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
const std::string filename = "wells_manager_data.data";
@ -192,6 +209,20 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
wells_static_check( wellsManager.c_wells() );
check_controls_epoch1( wellsManager.c_wells()->ctrls );
}
{
Opm::WellsManager wellsManager(eclipseState, 3, *gridManager.c_grid(), NULL);
const Wells* wells = wellsManager.c_wells();
BOOST_CHECK_EQUAL(3 , wells->number_of_wells);
BOOST_CHECK_EQUAL( wells->name[0] , "INJ1");
BOOST_CHECK_EQUAL( wells->name[1] , "PROD1");
BOOST_CHECK_EQUAL( wells->name[2] , "NEW");
check_controls_epoch3( wellsManager.c_wells()->ctrls );
}
}

View File

@ -43,7 +43,7 @@ WCONINJE
/
DATES
DATES -- Step1
1 'FEB' 2000 /
/
@ -56,15 +56,50 @@ WCONINJE
/
DATES
DATES -- Step2
1 'MAR' 2000 /
/
WCONPROD
'PROD1' 'SHUT' 15* /
'PROD1' 'SHUT' /
/
DATES -- Step3
1 'APR' 2000 /
/
WELSPECS
'NEW' 'G' 2 2 1* 'OIL' 2* 'STOP' 4* /
/
COMPDAT
'NEW' 2 2 2 2 'OPEN' 1 10.6092 0.5 /
/
WCONHIST
'NEW' 'OPEN' 'ORAT' 0.000 0.000 0.000 5* /
/
WCONPROD
'NEW' 'SHUT' /
/
WCONPROD
'PROD1' 'SHUT' /
/
END