OPM 147: WELOPEN: Shut well if all completions are closed; throw exception if trying to open a well with all completions shut

This commit is contained in:
chflo 2015-01-16 17:49:28 +01:00
parent b7127ae2c9
commit 4d7213651c
4 changed files with 88 additions and 5 deletions

View File

@ -65,4 +65,16 @@ namespace Opm {
}
bool CompletionSet::allCompletionsShut( ) const {
bool allShut = true;
for (auto ci = m_completions.begin(); ci != m_completions.end(); ++ci) {
CompletionConstPtr completion_ptr = *ci;
if (completion_ptr->getState() != WellCompletion::StateEnum::SHUT) {
allShut = false;
break;
}
}
return allShut;
}
}

View File

@ -39,6 +39,7 @@ namespace Opm {
size_t size() const;
CompletionSet * shallowCopy() const;
CompletionConstPtr get(size_t index) const;
bool allCompletionsShut() const;
private:
std::vector<CompletionConstPtr> m_completions;
};

View File

@ -418,7 +418,6 @@ namespace Opm {
const std::vector<WellPtr>& wells = getWells(wellNamePattern);
for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) {
WellPtr well = *wellIter;
@ -475,12 +474,24 @@ namespace Opm {
newCompletionSet->add(newCompletion);
}
well->addCompletionSet(currentStep, newCompletionSet);
if (newCompletionSet->allCompletionsShut()) {
well->setStatus(currentStep, WellCommon::StatusEnum::SHUT);
}
}
if(!haveCompletionData) {
else if(!haveCompletionData) {
WellCommon::StatusEnum status = WellCommon::StatusFromString( record->getItem("STATUS")->getTrimmedString(0));
well->setStatus(currentStep, status);
if ((WellCommon::StatusEnum::OPEN == status) && well->getCompletions(currentStep)->allCompletionsShut()) {
std::cerr << "ERROR when handling WELOPEN for well "<< well->name() << ": Cannot open a well where all completions are shut" << std::endl;
throw std::exception();
} else
{
well->setStatus(currentStep, status);
}
}
}
}
}

View File

@ -313,11 +313,20 @@ static DeckPtr createDeckWithWellsAndCompletionDataWithWELOPEN() {
" 'OP_1' OPEN / \n"
" 'OP_2' OPEN 0 0 0 4 6 / \n "
" 'OP_3' OPEN 0 0 0 / \n"
"/\n"
"DATES -- 5\n"
" 10 OKT 2008 / \n"
"/\n"
"WELOPEN\n"
" 'OP_1' SHUT 0 0 0 0 0 / \n "
"/\n";
return parser.parseString(input);
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsAndCompletionDataWithWELOPEN) {
DeckPtr deck = createDeckWithWellsAndCompletionDataWithWELOPEN();
Schedule schedule(deck);
@ -374,12 +383,63 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsAndCompletionDataWithWELOPEN) {
completion = completionSet->get(index);
BOOST_CHECK_EQUAL(WellCompletion::StateEnum::OPEN, completion->getState());
well = schedule.getWell("OP_1");
currentStep = 0;
BOOST_CHECK_EQUAL(WellCommon::StatusEnum::OPEN, well->getStatus(currentStep));
currentStep = 3;
BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(currentStep));
currentStep = 4;
BOOST_CHECK_EQUAL(WellCommon::StatusEnum::OPEN, well->getStatus(currentStep));
currentStep = 5;
BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(currentStep));
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWELOPEN_OpenWellWithShutCompletionsThrowsExcpetion) {
Opm::Parser parser;
std::string input =
"START -- 0 \n"
"1 NOV 1979 / \n"
"SCHEDULE\n"
"DATES -- 1\n"
" 1 DES 1979/ \n"
"/\n"
"WELSPECS\n"
" 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
"/\n"
"COMPDAT\n"
" 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
" 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n"
" 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
"/\n"
"DATES -- 2\n"
" 10 JUL 2008 / \n"
"/\n"
"WELOPEN\n"
" 'OP_1' OPEN / \n"
"/\n"
"DATES -- 3\n"
" 10 OKT 2008 / \n"
"/\n"
"WELOPEN\n"
" 'OP_1' SHUT 0 0 0 0 0 / \n "
"/\n"
"DATES -- 4\n"
" 10 NOV 2008 / \n"
"/\n"
"WELOPEN\n"
" 'OP_1' OPEN / \n "
"/\n";
DeckPtr deck = parser.parseString(input);
BOOST_CHECK_THROW(Schedule schedule(deck), std::exception);
}
@ -387,4 +447,3 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsAndCompletionDataWithWELOPEN) {