Added bitmask status flag to keep track of which controls have been set.
This commit is contained in:
@@ -41,6 +41,8 @@ namespace Opm {
|
||||
m_injectorControlMode(new DynamicState<WellInjector::ControlModeEnum>(timeMap, WellInjector::RATE)),
|
||||
m_producerControlMode(new DynamicState<WellProducer::ControlModeEnum>(timeMap, WellProducer::ORAT)),
|
||||
m_status(new DynamicState<WellCommon::StatusEnum>(timeMap, WellCommon::OPEN)),
|
||||
m_productionControls(new DynamicState<int>(timeMap, 0)),
|
||||
m_injectorControls(new DynamicState<int>(timeMap, 0)),
|
||||
m_inPredictionMode(new DynamicState<bool>(timeMap, true)),
|
||||
m_isProducer(new DynamicState<bool>(timeMap, true)) ,
|
||||
m_completions( new DynamicState<CompletionSetConstPtr>( timeMap , CompletionSetConstPtr( new CompletionSet()) )),
|
||||
@@ -78,16 +80,20 @@ namespace Opm {
|
||||
return m_BHPLimit->get(timeStep);
|
||||
}
|
||||
|
||||
void Well::setBHPLimit(size_t timeStep, double BHPLimit) {
|
||||
void Well::setBHPLimit(size_t timeStep, double BHPLimit , bool producer) {
|
||||
m_BHPLimit->add(timeStep, BHPLimit);
|
||||
if (producer)
|
||||
addProductionControl( timeStep , WellProducer::BHP);
|
||||
}
|
||||
|
||||
double Well::getTHPLimit(size_t timeStep) const {
|
||||
return m_THPLimit->get(timeStep);
|
||||
}
|
||||
|
||||
void Well::setTHPLimit(size_t timeStep, double THPLimit) {
|
||||
void Well::setTHPLimit(size_t timeStep, double THPLimit , bool producer) {
|
||||
m_THPLimit->add(timeStep, THPLimit);
|
||||
if (producer)
|
||||
addProductionControl( timeStep , WellProducer::THP);
|
||||
}
|
||||
|
||||
WellInjector::TypeEnum Well::getInjectorType(size_t timeStep) const {
|
||||
@@ -122,6 +128,7 @@ namespace Opm {
|
||||
void Well::setOilRate(size_t timeStep, double oilRate) {
|
||||
m_oilRate->add(timeStep, oilRate);
|
||||
switch2Producer( timeStep );
|
||||
addProductionControl( timeStep , WellProducer::ORAT );
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +139,7 @@ namespace Opm {
|
||||
void Well::setGasRate(size_t timeStep, double gasRate) {
|
||||
m_gasRate->add(timeStep, gasRate);
|
||||
switch2Producer( timeStep );
|
||||
addProductionControl( timeStep , WellProducer::GRAT );
|
||||
}
|
||||
|
||||
double Well::getWaterRate(size_t timeStep) const {
|
||||
@@ -141,6 +149,7 @@ namespace Opm {
|
||||
void Well::setWaterRate(size_t timeStep, double waterRate) {
|
||||
m_waterRate->add(timeStep, waterRate);
|
||||
switch2Producer( timeStep );
|
||||
addProductionControl( timeStep , WellProducer::WRAT );
|
||||
}
|
||||
|
||||
double Well::getLiquidRate(size_t timeStep) const {
|
||||
@@ -150,6 +159,7 @@ namespace Opm {
|
||||
void Well::setLiquidRate(size_t timeStep, double liquidRate) {
|
||||
m_liquidRate->add(timeStep, liquidRate);
|
||||
switch2Producer( timeStep );
|
||||
addProductionControl( timeStep , WellProducer::LRAT );
|
||||
}
|
||||
|
||||
double Well::getResVRate(size_t timeStep) const {
|
||||
@@ -159,6 +169,7 @@ namespace Opm {
|
||||
void Well::setResVRate(size_t timeStep, double resvRate) {
|
||||
m_resVRate->add(timeStep, resvRate);
|
||||
switch2Producer( timeStep );
|
||||
addProductionControl( timeStep , WellProducer::RESV );
|
||||
}
|
||||
|
||||
double Well::getSurfaceInjectionRate(size_t timeStep) const {
|
||||
@@ -209,6 +220,40 @@ namespace Opm {
|
||||
m_inPredictionMode->add(timeStep, inPredictionMode);
|
||||
}
|
||||
|
||||
|
||||
bool Well::hasProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode) const {
|
||||
int controls = m_productionControls->get( timeStep );
|
||||
if (controls & controlMode)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Well::addProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode) {
|
||||
int controls = m_productionControls->get( timeStep );
|
||||
if ((controls & controlMode) == 0) {
|
||||
controls += controlMode;
|
||||
m_productionControls->add(timeStep , controls );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Well::dropProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode) {
|
||||
int controls = m_productionControls->get( timeStep );
|
||||
if ((controls & controlMode) != 0) {
|
||||
controls -= controlMode;
|
||||
m_productionControls->add(timeStep , controls );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
bool hasInjectorControl(size_t timeStep , WellInjector::ControlModeEnum controlMode) const;
|
||||
void addInjectorControl(size_t timeStep , WellInjector::ControlModeEnum controlMode);
|
||||
*/
|
||||
|
||||
|
||||
// WELSPECS
|
||||
|
||||
int Well::getHeadI() const {
|
||||
|
||||
@@ -55,9 +55,9 @@ namespace Opm {
|
||||
double getReservoirInjectionRate(size_t timeStep) const;
|
||||
void setReservoirInjectionRate(size_t timeStep, double injectionRate);
|
||||
double getBHPLimit(size_t timeStep) const;
|
||||
void setBHPLimit(size_t timeStep, double BHPLimit);
|
||||
void setBHPLimit(size_t timeStep, double BHPLimit , bool producer);
|
||||
double getTHPLimit(size_t timeStep) const;
|
||||
void setTHPLimit(size_t timeStep, double THPLimit);
|
||||
void setTHPLimit(size_t timeStep, double THPLimit , bool producer);
|
||||
WellInjector::TypeEnum getInjectorType(size_t timeStep) const;
|
||||
void setInjectorType(size_t timeStep, WellInjector::TypeEnum injectorType);
|
||||
WellInjector::ControlModeEnum getInjectorControlMode(size_t timeStep) const;
|
||||
@@ -67,6 +67,10 @@ namespace Opm {
|
||||
WellCommon::StatusEnum getStatus(size_t timeStep) const;
|
||||
void setStatus(size_t timeStep, WellCommon::StatusEnum Status);
|
||||
|
||||
bool hasProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode) const;
|
||||
bool hasInjectorControl(size_t timeStep , WellInjector::ControlModeEnum controlMode) const;
|
||||
void dropProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode);
|
||||
|
||||
|
||||
int getHeadI() const;
|
||||
int getHeadJ() const;
|
||||
@@ -83,6 +87,10 @@ namespace Opm {
|
||||
private:
|
||||
void switch2Producer(size_t timeStep );
|
||||
void switch2Injector(size_t timeStep );
|
||||
|
||||
void addInjectorControl(size_t timeStep , WellInjector::ControlModeEnum controlMode);
|
||||
void addProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode);
|
||||
|
||||
|
||||
size_t m_creationTimeStep;
|
||||
std::string m_name;
|
||||
@@ -99,6 +107,8 @@ namespace Opm {
|
||||
std::shared_ptr<DynamicState<WellInjector::ControlModeEnum> > m_injectorControlMode;
|
||||
std::shared_ptr<DynamicState<WellProducer::ControlModeEnum> > m_producerControlMode;
|
||||
std::shared_ptr<DynamicState<WellCommon::StatusEnum> > m_status;
|
||||
std::shared_ptr<DynamicState<int> > m_productionControls;
|
||||
std::shared_ptr<DynamicState<int> > m_injectorControls;
|
||||
|
||||
std::shared_ptr<DynamicState<bool> > m_inPredictionMode;
|
||||
std::shared_ptr<DynamicState<bool> > m_isProducer;
|
||||
|
||||
@@ -258,11 +258,13 @@ BOOST_AUTO_TEST_CASE(XHPLimitDefault) {
|
||||
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
|
||||
Opm::Well well("WELL1", 1, 2, 2334.32, timeMap, 0);
|
||||
|
||||
well.setBHPLimit( 1 , 100 );
|
||||
well.setBHPLimit( 1 , 100 , true);
|
||||
BOOST_CHECK_EQUAL( 100 , well.getBHPLimit( 5 ));
|
||||
|
||||
well.setTHPLimit( 1 , 200 );
|
||||
BOOST_CHECK( well.hasProductionControl( 5 , Opm::WellProducer::BHP ));
|
||||
|
||||
well.setTHPLimit( 1 , 200 , false );
|
||||
BOOST_CHECK_EQUAL( 200 , well.getTHPLimit( 5 ));
|
||||
BOOST_CHECK( !well.hasProductionControl( 5 , Opm::WellProducer::THP ));
|
||||
}
|
||||
|
||||
|
||||
@@ -294,6 +296,52 @@ BOOST_AUTO_TEST_CASE(WellStatus) {
|
||||
|
||||
well.setStatus( 1 , Opm::WellCommon::OPEN );
|
||||
BOOST_CHECK_EQUAL( Opm::WellCommon::OPEN , well.getStatus( 5 ));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) {
|
||||
|
||||
Opm::TimeMapPtr timeMap = createXDaysTimeMap(20);
|
||||
Opm::Well well("WELL1", 1, 2, 2334.32, timeMap, 0);
|
||||
|
||||
|
||||
BOOST_CHECK( !well.hasProductionControl( 1 , Opm::WellProducer::ORAT ));
|
||||
BOOST_CHECK( !well.hasProductionControl( 1 , Opm::WellProducer::RESV ));
|
||||
|
||||
well.setOilRate( 2 , 100 );
|
||||
BOOST_CHECK( well.hasProductionControl( 2, Opm::WellProducer::ORAT ));
|
||||
BOOST_CHECK( !well.hasProductionControl( 2 , Opm::WellProducer::RESV ));
|
||||
|
||||
well.setResVRate( 2 , 100 );
|
||||
BOOST_CHECK( well.hasProductionControl( 2 , Opm::WellProducer::RESV ));
|
||||
|
||||
well.setOilRate( 10 , 100 );
|
||||
well.setWaterRate( 10 , 100 );
|
||||
well.setGasRate( 10 , 100 );
|
||||
well.setLiquidRate( 10 , 100 );
|
||||
well.setResVRate( 10 , 100 );
|
||||
well.setBHPLimit( 10 , 100 , true);
|
||||
well.setTHPLimit( 10 , 100 , true);
|
||||
|
||||
BOOST_CHECK( well.hasProductionControl( 10 , Opm::WellProducer::ORAT ));
|
||||
BOOST_CHECK( well.hasProductionControl( 10 , Opm::WellProducer::WRAT ));
|
||||
BOOST_CHECK( well.hasProductionControl( 10 , Opm::WellProducer::GRAT ));
|
||||
BOOST_CHECK( well.hasProductionControl( 10 , Opm::WellProducer::LRAT ));
|
||||
BOOST_CHECK( well.hasProductionControl( 10 , Opm::WellProducer::RESV ));
|
||||
BOOST_CHECK( well.hasProductionControl( 10 , Opm::WellProducer::BHP ));
|
||||
BOOST_CHECK( well.hasProductionControl( 10 , Opm::WellProducer::THP ));
|
||||
|
||||
well.dropProductionControl( 11 , Opm::WellProducer::RESV );
|
||||
|
||||
BOOST_CHECK( well.hasProductionControl( 11 , Opm::WellProducer::ORAT ));
|
||||
BOOST_CHECK( well.hasProductionControl( 11 , Opm::WellProducer::WRAT ));
|
||||
BOOST_CHECK( well.hasProductionControl( 11 , Opm::WellProducer::GRAT ));
|
||||
BOOST_CHECK( well.hasProductionControl( 11 , Opm::WellProducer::LRAT ));
|
||||
BOOST_CHECK( !well.hasProductionControl( 11 , Opm::WellProducer::RESV ));
|
||||
BOOST_CHECK( well.hasProductionControl( 11 , Opm::WellProducer::BHP ));
|
||||
BOOST_CHECK( well.hasProductionControl( 11 , Opm::WellProducer::THP ));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user