Add posibility to store closed completions in wellTestState
This commit is contained in:
@@ -46,33 +46,67 @@ public:
|
||||
int num_attempt;
|
||||
};
|
||||
|
||||
struct ClosedCompletion {
|
||||
std::string wellName;
|
||||
size_t completion;
|
||||
double last_test;
|
||||
int num_attempt;
|
||||
};
|
||||
|
||||
/*
|
||||
The simulator has decided to close a particular well; we then add it here
|
||||
as a closed well with a particualar reason.
|
||||
*/
|
||||
void addClosedWell(const std::string& well_name, WellTestConfig::Reason reason, double sim_time);
|
||||
|
||||
/*
|
||||
The simulator has decided to close a particular completion in a well; we then add it here
|
||||
as a closed completions
|
||||
*/
|
||||
void addClosedCompletion(const std::string& well_name, size_t completionIdx, double sim_time);
|
||||
|
||||
/*
|
||||
The update will consult the WellTestConfig object and return a list of
|
||||
wells which should be checked for possible reopening; observe that the
|
||||
update method will update the internal state of the object by counting up
|
||||
the openiing attempts, and also set the time for the last attempt to open.
|
||||
*/
|
||||
std::vector<std::pair<std::string, WellTestConfig::Reason>> update(const WellTestConfig& config, double sim_time);
|
||||
std::vector<std::pair<std::string, WellTestConfig::Reason>> updateWell(const WellTestConfig& config, double sim_time);
|
||||
|
||||
/*
|
||||
If the simulator decides that a constraint is no longer met the drop()
|
||||
The update will consult the WellTestConfig object and return a list of
|
||||
completions which should be checked for possible reopening; observe that the
|
||||
update method will update the internal state of the object by counting up
|
||||
the openiing attempts, and also set the time for the last attempt to open.
|
||||
*/
|
||||
std::vector<std::pair<std::string, size_t>> updateCompletion(const WellTestConfig& config, double sim_time);
|
||||
|
||||
|
||||
/*
|
||||
If the simulator decides that a constraint is no longer met the dropWell()
|
||||
method should be called to indicate that this reason for keeping the well
|
||||
closed is no longer active.
|
||||
*/
|
||||
void drop(const std::string& well_name, WellTestConfig::Reason reason);
|
||||
void dropWell(const std::string& well_name, WellTestConfig::Reason reason);
|
||||
|
||||
/*
|
||||
If the simulator decides that a constraint is no longer met the dropCompletion()
|
||||
method should be called to indicate that this reason for keeping the well
|
||||
closed is no longer active.
|
||||
*/
|
||||
void dropCompletion(const std::string& well_name, size_t completionIdx);
|
||||
|
||||
bool has(const std::string well_name, WellTestConfig::Reason reason) const;
|
||||
bool hasWell(const std::string well_name, WellTestConfig::Reason reason) const;
|
||||
void openWell(const std::string& well_name);
|
||||
size_t size() const;
|
||||
|
||||
bool hasCompletion(const std::string well_name, const size_t completionIdx) const;
|
||||
|
||||
size_t sizeWells() const;
|
||||
size_t sizeCompletions() const;
|
||||
|
||||
private:
|
||||
std::vector<ClosedWell> wells;
|
||||
std::vector<ClosedCompletion> completions;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
namespace Opm {
|
||||
|
||||
void WellTestState::addClosedWell(const std::string& well_name, WellTestConfig::Reason reason, double sim_time) {
|
||||
if (this->has(well_name, reason))
|
||||
if (this->hasWell(well_name, reason))
|
||||
return;
|
||||
|
||||
this->wells.push_back({well_name, reason, sim_time, 0});
|
||||
@@ -40,7 +40,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void WellTestState::drop(const std::string& well_name, WellTestConfig::Reason reason) {
|
||||
void WellTestState::dropWell(const std::string& well_name, WellTestConfig::Reason reason) {
|
||||
wells.erase(std::remove_if(wells.begin(),
|
||||
wells.end(),
|
||||
[&well_name, reason](const ClosedWell& well) { return (well.name == well_name && well.reason == reason); }),
|
||||
@@ -48,7 +48,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
bool WellTestState::has(const std::string well_name, WellTestConfig::Reason reason) const {
|
||||
bool WellTestState::hasWell(const std::string well_name, WellTestConfig::Reason reason) const {
|
||||
const auto well_iter = std::find_if(wells.begin(),
|
||||
wells.end(),
|
||||
[&well_name, &reason](const ClosedWell& well)
|
||||
@@ -58,12 +58,11 @@ namespace Opm {
|
||||
return (well_iter != wells.end());
|
||||
}
|
||||
|
||||
size_t WellTestState::size() const {
|
||||
size_t WellTestState::sizeWells() const {
|
||||
return this->wells.size();
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::pair<std::string, WellTestConfig::Reason>> WellTestState::update(const WellTestConfig& config, double sim_time) {
|
||||
std::vector<std::pair<std::string, WellTestConfig::Reason>> WellTestState::updateWell(const WellTestConfig& config, double sim_time) {
|
||||
std::vector<std::pair<std::string, WellTestConfig::Reason>> output;
|
||||
for (auto& closed_well : this->wells) {
|
||||
if (config.has(closed_well.name, closed_well.reason)) {
|
||||
@@ -81,6 +80,59 @@ namespace Opm {
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void WellTestState::addClosedCompletion(const std::string& well_name, size_t completionIdx, double sim_time) {
|
||||
if (this->hasCompletion(well_name, completionIdx))
|
||||
return;
|
||||
|
||||
this->completions.push_back({well_name, completionIdx, sim_time, 0});
|
||||
}
|
||||
|
||||
|
||||
void WellTestState::dropCompletion(const std::string& well_name, size_t completionIdx) {
|
||||
completions.erase(std::remove_if(completions.begin(),
|
||||
completions.end(),
|
||||
[&well_name, completionIdx](const ClosedCompletion& completion) { return (completion.wellName == well_name && completion.completion == completionIdx); }),
|
||||
completions.end());
|
||||
}
|
||||
|
||||
|
||||
bool WellTestState::hasCompletion(const std::string well_name, const size_t completionIdx) const {
|
||||
const auto completion_iter = std::find_if(completions.begin(),
|
||||
completions.end(),
|
||||
[&well_name, &completionIdx](const ClosedCompletion& completion)
|
||||
{
|
||||
return (completionIdx == completion.completion && completion.wellName == well_name);
|
||||
});
|
||||
return (completion_iter != completions.end());
|
||||
}
|
||||
|
||||
size_t WellTestState::sizeCompletions() const {
|
||||
return this->completions.size();
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, size_t>> WellTestState::updateCompletion(const WellTestConfig& config, double sim_time) {
|
||||
std::vector<std::pair<std::string, size_t>> output;
|
||||
for (auto& closed_completion : this->completions) {
|
||||
if (config.has(closed_completion.wellName, WellTestConfig::Reason::COMPLETION)) {
|
||||
const auto& well_config = config.get(closed_completion.wellName, WellTestConfig::Reason::COMPLETION);
|
||||
double elapsed = sim_time - closed_completion.last_test;
|
||||
|
||||
if (elapsed >= well_config.test_interval)
|
||||
if (well_config.num_test == 0 || (closed_completion.num_attempt < well_config.num_test)) {
|
||||
closed_completion.last_test = sim_time;
|
||||
closed_completion.num_attempt += 1;
|
||||
output.push_back(std::make_pair(closed_completion.wellName, closed_completion.completion));
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ BOOST_AUTO_TEST_CASE(WTEST_STATE2) {
|
||||
WellTestState st;
|
||||
wc.add_well("WELL_NAME", WellTestConfig::Reason::PHYSICAL, 0, 0, 0);
|
||||
st.addClosedWell("WELL_NAME", WellTestConfig::Reason::PHYSICAL, 100);
|
||||
BOOST_CHECK_EQUAL(st.size(), 1);
|
||||
BOOST_CHECK_EQUAL(st.sizeWells(), 1);
|
||||
|
||||
auto shut_wells = st.update(wc, 5000);
|
||||
auto shut_wells = st.updateWell(wc, 5000);
|
||||
BOOST_CHECK_EQUAL( shut_wells.size(), 1);
|
||||
}
|
||||
|
||||
@@ -84,38 +84,81 @@ BOOST_AUTO_TEST_CASE(WTEST_STATE) {
|
||||
WellTestConfig wc;
|
||||
WellTestState st;
|
||||
st.addClosedWell("WELL_NAME", WellTestConfig::Reason::ECONOMIC, 100);
|
||||
BOOST_CHECK_EQUAL(st.size(), 1);
|
||||
BOOST_CHECK_EQUAL(st.sizeWells(), 1);
|
||||
|
||||
st.addClosedWell("WELL_NAME", WellTestConfig::Reason::ECONOMIC, 100);
|
||||
BOOST_CHECK_EQUAL(st.size(), 1);
|
||||
BOOST_CHECK_EQUAL(st.sizeWells(), 1);
|
||||
|
||||
st.addClosedWell("WELL_NAME", WellTestConfig::Reason::PHYSICAL, 100);
|
||||
BOOST_CHECK_EQUAL(st.size(), 2);
|
||||
BOOST_CHECK_EQUAL(st.sizeWells(), 2);
|
||||
|
||||
st.addClosedWell("WELLX", WellTestConfig::Reason::PHYSICAL, 100);
|
||||
BOOST_CHECK_EQUAL(st.size(), 3);
|
||||
BOOST_CHECK_EQUAL(st.sizeWells(), 3);
|
||||
|
||||
auto shut_wells = st.update(wc, 5000);
|
||||
auto shut_wells = st.updateWell(wc, 5000);
|
||||
BOOST_CHECK_EQUAL( shut_wells.size(), 0);
|
||||
|
||||
wc.add_well("WELL_NAME", WellTestConfig::Reason::PHYSICAL, 1000, 2, 0);
|
||||
// Not sufficient time has passed.
|
||||
BOOST_CHECK_EQUAL( st.update(wc, 200).size(), 0);
|
||||
BOOST_CHECK_EQUAL( st.updateWell(wc, 200).size(), 0);
|
||||
|
||||
// We should test it:
|
||||
BOOST_CHECK_EQUAL( st.update(wc, 1200).size(), 1);
|
||||
BOOST_CHECK_EQUAL( st.updateWell(wc, 1200).size(), 1);
|
||||
|
||||
// Not sufficient time has passed.
|
||||
BOOST_CHECK_EQUAL( st.update(wc, 1700).size(), 0);
|
||||
BOOST_CHECK_EQUAL( st.updateWell(wc, 1700).size(), 0);
|
||||
|
||||
// We should test it:
|
||||
BOOST_CHECK_EQUAL( st.update(wc, 2400).size(), 1);
|
||||
BOOST_CHECK_EQUAL( st.updateWell(wc, 2400).size(), 1);
|
||||
|
||||
// Too many attempts:
|
||||
BOOST_CHECK_EQUAL( st.update(wc, 24000).size(), 0);
|
||||
BOOST_CHECK_EQUAL( st.updateWell(wc, 24000).size(), 0);
|
||||
|
||||
st.drop("WELL_NAME", WellTestConfig::Reason::ECONOMIC);
|
||||
st.dropWell("WELL_NAME", WellTestConfig::Reason::ECONOMIC);
|
||||
|
||||
st.openWell("WELL_NAME");
|
||||
BOOST_CHECK_EQUAL(st.size(), 1);
|
||||
BOOST_CHECK_EQUAL(st.sizeWells(), 1);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(WTEST_STATE_COMPLETIONS) {
|
||||
WellTestConfig wc;
|
||||
WellTestState st;
|
||||
st.addClosedCompletion("WELL_NAME", 2, 100);
|
||||
BOOST_CHECK_EQUAL(st.sizeCompletions(), 1);
|
||||
|
||||
st.addClosedCompletion("WELL_NAME", 2, 100);
|
||||
BOOST_CHECK_EQUAL(st.sizeCompletions(), 1);
|
||||
|
||||
st.addClosedCompletion("WELL_NAME", 3, 100);
|
||||
BOOST_CHECK_EQUAL(st.sizeCompletions(), 2);
|
||||
|
||||
st.addClosedCompletion("WELLX", 3, 100);
|
||||
BOOST_CHECK_EQUAL(st.sizeCompletions(), 3);
|
||||
|
||||
auto closed_completions = st.updateWell(wc, 5000);
|
||||
BOOST_CHECK_EQUAL( closed_completions.size(), 0);
|
||||
|
||||
wc.add_well("WELL_NAME", WellTestConfig::Reason::COMPLETION, 1000, 2, 0);
|
||||
// Not sufficient time has passed.
|
||||
BOOST_CHECK_EQUAL( st.updateCompletion(wc, 200).size(), 0);
|
||||
|
||||
// We should test it:
|
||||
BOOST_CHECK_EQUAL( st.updateCompletion(wc, 1200).size(), 2);
|
||||
|
||||
// Not sufficient time has passed.
|
||||
BOOST_CHECK_EQUAL( st.updateCompletion(wc, 1700).size(), 0);
|
||||
|
||||
// We should test it:
|
||||
BOOST_CHECK_EQUAL( st.updateCompletion(wc, 2400).size(), 2);
|
||||
|
||||
// Too many attempts:
|
||||
BOOST_CHECK_EQUAL( st.updateCompletion(wc, 24000).size(), 0);
|
||||
|
||||
st.dropCompletion("WELL_NAME", 2);
|
||||
st.dropCompletion("WELLX", 3);
|
||||
BOOST_CHECK_EQUAL(st.sizeCompletions(), 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user