Skip to content

Commit

Permalink
Merge pull request #1127 from joakim-hove/rft-config-bug
Browse files Browse the repository at this point in the history
Rft config bug
  • Loading branch information
Alf Birger Rustad authored Sep 11, 2017
2 parents 7fbc0ac + 0930dc0 commit c2bf2f0
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 60 deletions.
50 changes: 6 additions & 44 deletions lib/eclipse/EclipseState/Schedule/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,23 +1310,15 @@ namespace Opm {

const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);

for( auto* well : getWells( wellNamePattern ) ) {

well->setRFTActive(currentStep, true);
size_t numStep = m_timeMap.numTimesteps();
if(currentStep<numStep){
well->setRFTActive(currentStep+1, false);
}
}
for( auto* well : getWells( wellNamePattern ) )
well->updateRFTActive( currentStep, RFTConnections::RFTEnum::YES);
}

for( auto& well : this->m_wells ) {
well.setRFTForWellWhenFirstOpen(m_timeMap.numTimesteps(), currentStep);
}
for( auto& well : this->m_wells )
well.setRFTForWellWhenFirstOpen( currentStep );
}

void Schedule::handleWRFTPLT( const DeckKeyword& keyword, size_t currentStep) {

for( const auto& record : keyword ) {

const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
Expand All @@ -1335,38 +1327,8 @@ namespace Opm {
PLTConnections::PLTEnum PLTKey = PLTConnections::PLTEnumFromString(record.getItem("OUTPUT_PLT").getTrimmedString(0));

for( auto* well : getWells( wellNamePattern ) ) {
switch(RFTKey){
case RFTConnections::RFTEnum::YES:
well->setRFTActive(currentStep, true);
break;
case RFTConnections::RFTEnum::REPT:
well->setRFTActive(currentStep, true);
break;
case RFTConnections::RFTEnum::TIMESTEP:
well->setRFTActive(currentStep, true);
break;
case RFTConnections::RFTEnum::FOPN:
well->setRFTForWellWhenFirstOpen(m_timeMap.numTimesteps(),currentStep);
break;
case RFTConnections::RFTEnum::NO:
well->setRFTActive(currentStep, false);
break;
}

switch(PLTKey){
case PLTConnections::PLTEnum::YES:
well->setPLTActive(currentStep, true);
break;
case PLTConnections::PLTEnum::REPT:
well->setPLTActive(currentStep, true);
break;
case PLTConnections::PLTEnum::TIMESTEP:
well->setPLTActive(currentStep, true);
break;
case PLTConnections::PLTEnum::NO:
well->setPLTActive(currentStep, false);
break;
}
well->updateRFTActive( currentStep, RFTKey );
well->updatePLTActive( currentStep, PLTKey );
}
}
}
Expand Down
51 changes: 39 additions & 12 deletions lib/eclipse/EclipseState/Schedule/Well.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,42 @@ namespace Opm {



void Well::setRFTActive(size_t time_step, bool value){
m_rft.update(time_step, value);
void Well::updateRFTActive(size_t time_step, RFTConnections::RFTEnum mode) {
switch(mode) {
case RFTConnections::RFTEnum::YES:
m_rft.update_elm(time_step, true);
break;
case RFTConnections::RFTEnum::TIMESTEP:
m_rft.update_elm(time_step, true);
break;
case RFTConnections::RFTEnum::REPT:
m_rft.update(time_step, true);
break;
case RFTConnections::RFTEnum::FOPN:
setRFTForWellWhenFirstOpen(time_step);
break;
case RFTConnections::RFTEnum::NO:
m_rft.update(time_step, false);
break;
default:
break;
}
}

void Well::updatePLTActive(size_t time_step, PLTConnections::PLTEnum mode){
switch(mode) {
case PLTConnections::PLTEnum::YES:
m_plt.update_elm(time_step, true);
break;
case PLTConnections::PLTEnum::REPT:
m_plt.update(time_step, true);
break;
case PLTConnections::PLTEnum::NO:
m_plt.update(time_step, false);
break;
default:
break;
}
}

bool Well::getRFTActive(size_t time_step) const{
Expand All @@ -404,9 +438,6 @@ namespace Opm {
bool Well::getPLTActive(size_t time_step) const{
return bool( m_plt.get(time_step) );
}
void Well::setPLTActive(size_t time_step, bool value){
m_plt.update(time_step, value);
}

/*
The first report step where *either* RFT or PLT output is active.
Expand Down Expand Up @@ -443,19 +474,15 @@ namespace Opm {
return -1;
}

void Well::setRFTForWellWhenFirstOpen(int numSteps,size_t currentStep){
void Well::setRFTForWellWhenFirstOpen(size_t currentStep){
int time;
if(getStatus(currentStep)==WellCommon::StatusEnum::OPEN ){
time = currentStep;
}else {
time = findWellFirstOpen(currentStep);
}
if(time>-1){
setRFTActive(time, true);
if(time < numSteps){
setRFTActive(time+1, false);
}
}
if (time > -1)
updateRFTActive(time, RFTConnections::RFTEnum::YES);
}

WellCompletion::CompletionOrderEnum Well::getWellCompletionOrdering() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef DYNAMICSTATE_HPP_
#define DYNAMICSTATE_HPP_

#include <stdexcept>
#include <vector>
#include <algorithm>

Expand Down Expand Up @@ -104,6 +105,13 @@ class DynamicState {
return true;
}

void update_elm( size_t index, const T& value ) {
if (this->m_data.size() <= index)
throw std::out_of_range("Invalid index for update_elm()");

this->m_data[index] = value;
}

/// Will return the index of the first occurence of @value, or
/// -1 if @value is not found.
int find(const T& value) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/WellPolymerProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/SegmentSet.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>

namespace Opm {
Expand Down Expand Up @@ -129,17 +130,17 @@ namespace Opm {

int firstRFTOutput( ) const;
bool getRFTActive(size_t time_step) const;
void setRFTActive(size_t time_step, bool value);
void updateRFTActive(size_t time_step, RFTConnections::RFTEnum mode);
bool getPLTActive(size_t time_step) const;
void setPLTActive(size_t time_step, bool value);
void updatePLTActive(size_t time_step, PLTConnections::PLTEnum mode);
int findWellFirstOpen(int startTimeStep) const;

/*
Will return the report step when the well is created with
WELSPECS, actually opening the well might be later.
*/
size_t firstTimeStep( ) const;
void setRFTForWellWhenFirstOpen(int numSteps,size_t currentStep);
void setRFTForWellWhenFirstOpen(size_t currentStep);

static bool wellNameInWellNamePattern(const std::string& wellName, const std::string& wellNamePattern);

Expand Down
20 changes: 20 additions & 0 deletions lib/eclipse/tests/DynamicStateTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,23 @@ BOOST_AUTO_TEST_CASE( find ) {
BOOST_CHECK_EQUAL( state.find( 400 ) , 4 );
BOOST_CHECK_EQUAL( state.find( 500 ) , -1 );
}


BOOST_AUTO_TEST_CASE( update_elm ) {
const std::time_t startDate = Opm::TimeMap::mkdate(2010, 1, 1);
Opm::TimeMap timeMap{ startDate };
for (size_t i = 0; i < 5; i++)
timeMap.addTStep((i+1) * 24 * 60 * 60);

Opm::DynamicState<int> state(timeMap , 137);
state.update( 5, 88 );
BOOST_CHECK_THROW( state.update_elm(10,88) , std::out_of_range );
BOOST_CHECK_EQUAL( state[2],137 );
BOOST_CHECK_EQUAL( state[3],137 );
BOOST_CHECK_EQUAL( state[4],137 );

state.update_elm(3,88);
BOOST_CHECK_EQUAL( state[2],137 );
BOOST_CHECK_EQUAL( state[3],88 );
BOOST_CHECK_EQUAL( state[4],137 );
}
10 changes: 10 additions & 0 deletions lib/eclipse/tests/data/integration_tests/SCHEDULE/SCHEDULE_WELLS2
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ WELSPECS
'W_4' 'OP' 32 19 1* 'OIL' 7* /
/

WRFTPLT
'W_1' 'YES' 'NO' 'NO' /
'W_2' 'REPT' 'NO' 'NO' /
/

COMPDAT
-- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro
'W_1' 30 37 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 /
Expand Down Expand Up @@ -51,6 +56,11 @@ TSTEP -- 4
TSTEP -- 5
10 /

WRFTPLT
'W_2' 'NO' 'NO' 'NO' /
/


TSTEP -- 6
10 /

Expand Down
7 changes: 6 additions & 1 deletion lib/eclipse/tests/integration/ScheduleCreateFromDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ BOOST_AUTO_TEST_CASE(WellTesting) {
BOOST_CHECK_EQUAL( 0 , well2->getProductionPropertiesCopy(8).ResVRate);

BOOST_CHECK_EQUAL( WellCommon::SHUT , well2->getStatus(3));

BOOST_CHECK( !well2->getRFTActive( 2 ) );
BOOST_CHECK( well2->getRFTActive( 3 ) );
BOOST_CHECK( well2->getRFTActive( 4 ) );
BOOST_CHECK( !well2->getRFTActive( 5 ) );
{
const WellProductionProperties& prop3 = well2->getProductionProperties(3);
BOOST_CHECK_EQUAL( WellProducer::ORAT , prop3.controlMode);
Expand Down Expand Up @@ -221,6 +224,8 @@ BOOST_AUTO_TEST_CASE(WellTesting) {
{
auto* well1 = sched.getWell("W_1");

BOOST_CHECK_EQUAL( well1->firstRFTOutput( ) , 3);
BOOST_CHECK( well1->getRFTActive( 3 ) );
BOOST_CHECK(well1->getProductionPropertiesCopy(0).predictionMode);
BOOST_CHECK_EQUAL(0, well1->getProductionPropertiesCopy(0).OilRate);

Expand Down

0 comments on commit c2bf2f0

Please sign in to comment.