Merge pull request #3114 from bska/rst-read-vfpexp

Restore Explicit THP Control Options from Restart File
This commit is contained in:
Markus Blatt 2022-10-07 09:19:01 +02:00 committed by GitHub
commit 9f02b613e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 147 additions and 1 deletions

View File

@ -24,6 +24,10 @@ namespace Opm {
class DeckRecord;
} // namespace Opm
namespace Opm { namespace RestartIO {
struct RstWell;
}} // namespace Opm::RestartIO
namespace Opm {
class WVFPEXP
@ -32,6 +36,7 @@ namespace Opm {
static WVFPEXP serializationTestObject();
void update(const DeckRecord& record);
void update(const RestartIO::RstWell& rst_well);
bool explicit_lookup() const;
bool shut() const;

View File

@ -89,6 +89,9 @@ struct RstWell
int wtest_remaining;
int econ_limit_quantity;
int econ_workover_procedure_2;
int thp_lookup_procedure_vfptable;
int close_if_thp_stabilised;
int prevent_thpctrl_if_unstable;
bool glift_active;
bool glift_alloc_extra_gas;

View File

@ -19,6 +19,9 @@
#include <opm/input/eclipse/Schedule/Well/WVFPEXP.hpp>
#include <opm/io/eclipse/rst/well.hpp>
#include <opm/output/eclipse/VectorItems/well.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/W.hpp>
#include <opm/input/eclipse/Deck/DeckRecord.hpp>
@ -59,6 +62,24 @@ namespace Opm {
m_prevent = Prevent::No;
}
void WVFPEXP::update(const RestartIO::RstWell& rst_well) {
namespace Value = Opm::RestartIO::Helpers::
VectorItems::IWell::Value::WVfpExp;
this->m_explicit = rst_well.thp_lookup_procedure_vfptable == Value::Lookup::Explicit;
this->m_shut = rst_well.close_if_thp_stabilised == static_cast<int>(Value::CloseStabilised::Yes);
if (rst_well.prevent_thpctrl_if_unstable == static_cast<int>(Value::PreventTHP::Yes1)) {
this->m_prevent = Prevent::ReportFirst;
}
else if (rst_well.prevent_thpctrl_if_unstable == static_cast<int>(Value::PreventTHP::Yes2)) {
this->m_prevent = Prevent::ReportEvery;
}
else {
this->m_prevent = Prevent::No;
}
}
bool WVFPEXP::explicit_lookup() const {
return m_explicit;
}

View File

@ -245,6 +245,15 @@ Opm::Well::WellGuideRate guideRate(const Opm::RestartIO::RstWell& rst_well)
};
}
std::shared_ptr<Opm::WVFPEXP>
explicitTHPOptions(const Opm::RestartIO::RstWell& rst_well)
{
auto options = std::make_shared<Opm::WVFPEXP>();
options->update(rst_well);
return options;
}
constexpr Opm::Well::ProducerCMode def_whistctl_cmode = Opm::Well::ProducerCMode::CMODE_UNDEFINED;
const static bool def_automatic_shutin = true;
constexpr double def_solvent_fraction = 0;
@ -284,7 +293,7 @@ Well::Well(const RestartIO::RstWell& rst_well,
connections(std::make_shared<WellConnections>(order_from_int(rst_well.completion_ordering), headI, headJ)),
production(std::make_shared<WellProductionProperties>(unit_system_arg, wname)),
injection(std::make_shared<WellInjectionProperties>(unit_system_arg, wname)),
wvfpexp(std::make_shared<WVFPEXP>()),
wvfpexp(explicitTHPOptions(rst_well)),
status(status_from_int(rst_well.well_status))
{
if (this->wtype.producer()) {

View File

@ -100,6 +100,9 @@ RstWell::RstWell(const ::Opm::UnitSystem& unit_system,
wtest_remaining( iwel[VI::IWell::WTestRemaining] -1),
econ_limit_quantity( iwel[VI::IWell::EconLimitQuantity]),
econ_workover_procedure_2( iwel[VI::IWell::EconWorkoverProcedure_2]),
thp_lookup_procedure_vfptable( iwel[VI::IWell::THPLookupVFPTable]),
close_if_thp_stabilised( iwel[VI::IWell::CloseWellIfTHPStabilised]),
prevent_thpctrl_if_unstable( iwel[VI::IWell::PreventTHPIfUnstable]),
glift_active( iwel[VI::IWell::LiftOpt] == 1),
glift_alloc_extra_gas( iwel[VI::IWell::LiftOptAllocExtra] == 1),
// The values orat_target -> bhp_target_float will be used in UDA values. The

View File

@ -47,6 +47,7 @@
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
#include <opm/input/eclipse/Schedule/Well/WellEconProductionLimits.hpp>
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
#include <opm/input/eclipse/Schedule/Well/WVFPEXP.hpp>
#include <opm/input/eclipse/Units/UnitSystem.hpp>
@ -193,6 +194,12 @@ WCONPROD
'OP_4' 'OPEN' 'ORAT' 20000 4* 1000 /
/
WVFPEXP
'OP_1' 1* 'YES' /
'OP_2' 'EXP' 'NO' 'YES1' /
'OP_3' 'EXP' 'YES' 'YES2' /
/
DATES -- 5
30 AUG 2014 /
/
@ -684,3 +691,101 @@ BOOST_AUTO_TEST_CASE(Construct_Well_Guide_Rates_Group_Control_Object)
BOOST_CHECK_CLOSE(op_3.getGuideRate(), -1.0, 1.0e-7);
BOOST_CHECK_CLOSE(op_3.getGuideRateScalingFactor(), 0.625, 1.0e-7);
}
BOOST_AUTO_TEST_CASE(Explicit_THP_Control_Options)
{
namespace WVfpExp = Opm::RestartIO::Helpers::VectorItems::
IWell::Value::WVfpExp;
const auto simCase = SimulationCase{first_sim()};
const auto rptStep = std::size_t{5};
const auto baseName = std::string { "TEST_RST_WVFPEXP" };
const auto state =
makeRestartState(simCase, baseName, rptStep, "test_rst_wvfpexp");
const auto& op_1 = state.get_well("OP_1");
const auto& op_2 = state.get_well("OP_2");
const auto& op_3 = state.get_well("OP_3");
const auto& op_4 = state.get_well("OP_4");
BOOST_CHECK_EQUAL(op_1.thp_lookup_procedure_vfptable, WVfpExp::Lookup::Implicit);
BOOST_CHECK_EQUAL(op_1.close_if_thp_stabilised,
static_cast<int>(WVfpExp::CloseStabilised::Yes));
BOOST_CHECK_EQUAL(op_1.prevent_thpctrl_if_unstable,
static_cast<int>(WVfpExp::PreventTHP::No));
BOOST_CHECK_EQUAL(op_2.thp_lookup_procedure_vfptable, WVfpExp::Lookup::Explicit);
BOOST_CHECK_EQUAL(op_2.close_if_thp_stabilised,
static_cast<int>(WVfpExp::CloseStabilised::No));
BOOST_CHECK_EQUAL(op_2.prevent_thpctrl_if_unstable,
static_cast<int>(WVfpExp::PreventTHP::Yes1));
BOOST_CHECK_EQUAL(op_3.thp_lookup_procedure_vfptable, WVfpExp::Lookup::Explicit);
BOOST_CHECK_EQUAL(op_3.close_if_thp_stabilised,
static_cast<int>(WVfpExp::CloseStabilised::Yes));
BOOST_CHECK_EQUAL(op_3.prevent_thpctrl_if_unstable,
static_cast<int>(WVfpExp::PreventTHP::Yes2));
BOOST_CHECK_EQUAL(op_4.thp_lookup_procedure_vfptable, WVfpExp::Lookup::Implicit);
BOOST_CHECK_EQUAL(op_4.close_if_thp_stabilised,
static_cast<int>(WVfpExp::CloseStabilised::No));
BOOST_CHECK_EQUAL(op_4.prevent_thpctrl_if_unstable,
static_cast<int>(WVfpExp::PreventTHP::No));
}
BOOST_AUTO_TEST_CASE(Construct_Well_Explicit_THP_Control_Options_Object)
{
const auto simCase = SimulationCase{first_sim()};
const auto rptStep = std::size_t{5};
const auto baseName = std::string { "TEST_RST_WVFPEXP" };
const auto state =
makeRestartState(simCase, baseName, rptStep, "test_rst_wvfpexp");
auto makeTHPOptions = [&state, rptStep](const std::string& well_name)
{
return Opm::Well {
state.get_well(well_name),
static_cast<int>(rptStep),
Opm::TracerConfig{},
Opm::UnitSystem::newMETRIC(),
1.0e+20
}.getWVFPEXP();
};
const auto op_1 = makeTHPOptions("OP_1");
const auto op_2 = makeTHPOptions("OP_2");
const auto op_3 = makeTHPOptions("OP_3");
const auto op_4 = makeTHPOptions("OP_4");
// 1* YES /
BOOST_CHECK_MESSAGE(! op_1.explicit_lookup(), "Well 'OP_1' must have IMPLICIT THP lookup");
BOOST_CHECK_MESSAGE( op_1.shut(), "Well 'OP_1' must SHUT if operating in stabilised region");
BOOST_CHECK_MESSAGE(! op_1.prevent(), "Well 'OP_1' must NOT prevent switching to THP control when constrained to unstable VFP table region");
BOOST_CHECK_MESSAGE(! op_1.report_first(), "Well 'OP_1' must NOT report first time THP control switching prevented");
BOOST_CHECK_MESSAGE(! op_1.report_every(), "Well 'OP_1' must NOT report every time THP control switching prevented");
// EXP NO YES1 /
BOOST_CHECK_MESSAGE( op_2.explicit_lookup(), "Well 'OP_2' must have EXPLICIT THP lookup");
BOOST_CHECK_MESSAGE(! op_2.shut(), "Well 'OP_2' must remain open if operating in stabilised region");
BOOST_CHECK_MESSAGE( op_2.prevent(), "Well 'OP_2' must prevent switching to THP control when constrained to unstable VFP table region");
BOOST_CHECK_MESSAGE( op_2.report_first(), "Well 'OP_2' must report first time THP control switching prevented");
BOOST_CHECK_MESSAGE(! op_2.report_every(), "Well 'OP_2' must NOT report every time THP control switching prevented");
// EXP YES YES2 /
BOOST_CHECK_MESSAGE( op_3.explicit_lookup(), "Well 'OP_3' must have EXPLICIT THP lookup");
BOOST_CHECK_MESSAGE( op_3.shut(), "Well 'OP_3' must SHUT if operating in stabilised region");
BOOST_CHECK_MESSAGE( op_3.prevent(), "Well 'OP_3' must prevent switching to THP control when constrained to unstable VFP table region");
BOOST_CHECK_MESSAGE(! op_3.report_first(), "Well 'OP_3' must NOT report first time THP control switching prevented");
BOOST_CHECK_MESSAGE( op_3.report_every(), "Well 'OP_3' must report every time THP control switching prevented");
// All defaults.
BOOST_CHECK_MESSAGE(! op_4.explicit_lookup(), "Well 'OP_4' must have IMPLICIT THP lookup");
BOOST_CHECK_MESSAGE(! op_4.shut(), "Well 'OP_4' must remain open if operating in stabilised region");
BOOST_CHECK_MESSAGE(! op_4.prevent(), "Well 'OP_4' must NOT prevent switching to THP control when constrained to unstable VFP table region");
BOOST_CHECK_MESSAGE(! op_4.report_first(), "Well 'OP_4' must NOT report first time THP control switching prevented");
BOOST_CHECK_MESSAGE(! op_4.report_every(), "Well 'OP_4' must NOT report every time THP control switching prevented");
}