Merge pull request #808 from joakim-hove/injection-unitsystem

Add UnitSystem member to Well2 class
This commit is contained in:
Bård Skaflestad
2019-06-12 11:46:45 +02:00
committed by GitHub
7 changed files with 54 additions and 33 deletions

View File

@@ -196,11 +196,11 @@ namespace Opm
const Eclipse3DProperties& eclipseProperties);
bool handleGroupFromWELSPECS(const std::string& groupName, GroupTree& newTree) const;
void addGroup(const std::string& groupName , size_t timeStep);
void addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, WellCompletion::CompletionOrderEnum wellCompletionOrder);
void addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, WellCompletion::CompletionOrderEnum wellCompletionOrder, const UnitSystem& unit_system);
void handleUDQ(const DeckKeyword& keyword, size_t currentStep);
void handleWLIST(const DeckKeyword& keyword, size_t currentStep);
void handleCOMPORD(const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& compordKeyword, size_t currentStep);
void handleWELSPECS( const SCHEDULESection&, size_t, size_t );
void handleWELSPECS( const SCHEDULESection&, size_t, size_t , const UnitSystem& unit_system);
void handleWCONHIST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
void handleWCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
void handleWGRUPCON( const DeckKeyword& keyword, size_t currentStep);

View File

@@ -33,6 +33,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTracerProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellPolymerProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellEconProductionLimits.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
namespace Opm {
@@ -62,7 +63,8 @@ public:
double ref_depth,
Phase phase,
WellProducer::ControlModeEnum whistctl_cmode,
WellCompletion::CompletionOrderEnum ordering);
WellCompletion::CompletionOrderEnum ordering,
const UnitSystem& unit_system);
bool isMultiSegment() const;
bool isAvailableForGroupControl() const;
@@ -165,6 +167,7 @@ private:
double ref_depth;
Phase phase;
WellCompletion::CompletionOrderEnum ordering;
UnitSystem unit_system;
WellCommon::StatusEnum status;
double drainage_radius;

View File

@@ -224,7 +224,7 @@ namespace Opm {
handleWLIST( keyword, currentStep );
else if (keyword.name() == "WELSPECS")
handleWELSPECS( section, keywordIdx, currentStep );
handleWELSPECS( section, keywordIdx, currentStep, unit_system);
else if (keyword.name() == "WHISTCTL")
handleWHISTCTL(keyword, currentStep, parseContext, errors);
@@ -526,7 +526,8 @@ namespace Opm {
void Schedule::handleWELSPECS( const SCHEDULESection& section,
size_t index,
size_t currentStep ) {
size_t currentStep,
const UnitSystem& unit_system) {
bool needNewTree = false;
auto newTree = m_rootGroupTree.get(currentStep);
@@ -567,8 +568,8 @@ namespace Opm {
}
}
}
addWell(wellName, record, currentStep, wellConnectionOrder);
addWellToGroup( this->m_groups.at( groupName ), wellName, currentStep);
this->addWell(wellName, record, currentStep, wellConnectionOrder, unit_system);
this->addWellToGroup(this->m_groups.at( groupName ), wellName, currentStep);
} else {
const auto headI = record.getItem( "HEAD_I" ).get< int >( 0 ) - 1;
const auto headJ = record.getItem( "HEAD_J" ).get< int >( 0 ) - 1;
@@ -1786,7 +1787,12 @@ namespace Opm {
return m_rootGroupTree.get(timeStep);
}
void Schedule::addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, WellCompletion::CompletionOrderEnum wellConnectionOrder) {
void Schedule::addWell(const std::string& wellName,
const DeckRecord& record,
size_t timeStep,
WellCompletion::CompletionOrderEnum wellConnectionOrder,
const UnitSystem& unit_system) {
// We change from eclipse's 1 - n, to a 0 - n-1 solution
int headI = record.getItem("HEAD_I").get< int >(0) - 1;
int headJ = record.getItem("HEAD_J").get< int >(0) - 1;
@@ -1829,7 +1835,16 @@ namespace Opm {
auto& dynamic_state = wells_static.at(wellName);
const std::string& group = record.getItem<ParserKeywords::WELSPECS::GROUP>().getTrimmedString(0);
std::size_t insert_index = this->wells_static.size() - 1;
auto well_ptr = std::make_shared<Well2>(wellName, group, timeStep, insert_index, headI, headJ, refDepth, preferredPhase, this->global_whistctl_mode[timeStep], wellConnectionOrder);
auto well_ptr = std::make_shared<Well2>(wellName,
group,
timeStep,
insert_index,
headI, headJ,
refDepth,
preferredPhase,
this->global_whistctl_mode[timeStep],
wellConnectionOrder,
unit_system);
well_ptr->updateCrossFlow(allowCrossFlow);
well_ptr->updateAutoShutin(automaticShutIn);

View File

@@ -81,7 +81,8 @@ Well2::Well2(const std::string& wname,
double ref_depth,
Phase phase,
WellProducer::ControlModeEnum whistctl_cmode,
WellCompletion::CompletionOrderEnum ordering):
WellCompletion::CompletionOrderEnum ordering,
const UnitSystem& unit_system):
wname(wname),
group_name(gname),
init_step(init_step),
@@ -91,6 +92,7 @@ Well2::Well2(const std::string& wname,
ref_depth(ref_depth),
phase(phase),
ordering(ordering),
unit_system(unit_system),
status(WellCommon::SHUT),
drainage_radius(ParserKeywords::WELSPECS::D_RADIUS::defaultValue),
allow_cross_flow(DeckItem::to_bool(ParserKeywords::WELSPECS::CROSSFLOW::defaultValue)),

View File

@@ -158,8 +158,8 @@ BOOST_AUTO_TEST_CASE(GroupAddWell) {
auto timeMap = createXDaysTimeMap( 10 );
Opm::Group group("G1" , 1, timeMap , 0);
auto well1 = std::make_shared< Well2 >("WELL1", "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
auto well2 = std::make_shared< Well2 >("WELL2", "G1", 0, 2, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
auto well1 = std::make_shared< Well2 >("WELL1", "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
auto well2 = std::make_shared< Well2 >("WELL2", "G1", 0, 2, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK_EQUAL(0U , group.numWells(2));
group.addWell( 3 , well1->name() );
@@ -195,8 +195,8 @@ BOOST_AUTO_TEST_CASE(GroupAddAndDelWell) {
auto timeMap = createXDaysTimeMap( 10 );
Opm::Group group("G1" , 1, timeMap , 0);
auto well1 = std::make_shared< Well2 >("WELL1", "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
auto well2 = std::make_shared< Well2 >("WELL2", "G1", 0, 2, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
auto well1 = std::make_shared< Well2 >("WELL1", "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
auto well2 = std::make_shared< Well2 >("WELL2", "G1", 0, 2, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK_EQUAL(0U , group.numWells(2));
group.addWell( 3 , well1->name() );
@@ -228,8 +228,8 @@ BOOST_AUTO_TEST_CASE(GroupAddAndDelWell) {
BOOST_AUTO_TEST_CASE(getWells) {
auto timeMap = createXDaysTimeMap( 10 );
Opm::Group group("G1" , 1, timeMap , 0);
auto well1 = std::make_shared< Well2 >("WELL1", "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
auto well2 = std::make_shared< Well2 >("WELL2", "G1", 0, 2, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
auto well1 = std::make_shared< Well2 >("WELL1", "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
auto well2 = std::make_shared< Well2 >("WELL2", "G1", 0, 2, 0, 0, 0.0, Opm::Phase::OIL, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
group.addWell( 2 , well1->name() );
group.addWell( 3 , well1->name() );

View File

@@ -26,6 +26,7 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
@@ -189,7 +190,7 @@ BOOST_AUTO_TEST_CASE(WellCOMPDATtestINPUT) {
}
BOOST_AUTO_TEST_CASE(NewWellZeroCompletions) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK_EQUAL( 0U , well.getConnections( ).size() );
}
@@ -197,7 +198,7 @@ BOOST_AUTO_TEST_CASE(NewWellZeroCompletions) {
BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
// HACK: This test checks correctly setting of isProducer/isInjector. This property depends on which of
// WellProductionProperties/WellInjectionProperties is set last, independent of actual values.
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
/* 1: Well is created as producer */
BOOST_CHECK_EQUAL( false , well.isInjector());
@@ -212,7 +213,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
BOOST_CHECK_EQUAL( 100 , well.getInjectionProperties().surfaceInjectionRate);
{
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
/* Set a reservoir injection rate => Well becomes an Injector */
auto injectionProps2 = std::make_shared<Opm::WellInjectionProperties>(well.getInjectionProperties());
@@ -224,7 +225,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
}
{
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
/* Set rates => Well becomes a producer; injection rate should be set to 0. */
auto injectionProps3 = std::make_shared<Opm::WellInjectionProperties>(well.getInjectionProperties());
@@ -247,7 +248,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
}
BOOST_AUTO_TEST_CASE(GroupnameCorretlySet) {
Opm::Well2 well("WELL1" , "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1" , "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK_EQUAL("G1" , well.groupName());
well.updateGroup( "GROUP2");
@@ -256,7 +257,7 @@ BOOST_AUTO_TEST_CASE(GroupnameCorretlySet) {
BOOST_AUTO_TEST_CASE(addWELSPECS_setData_dataSet) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK_EQUAL(23, well.getHeadI());
BOOST_CHECK_EQUAL(42, well.getHeadJ());
@@ -266,7 +267,7 @@ BOOST_AUTO_TEST_CASE(addWELSPECS_setData_dataSet) {
BOOST_AUTO_TEST_CASE(XHPLimitDefault) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
auto productionProps = std::make_shared<Opm::WellProductionProperties>(well.getProductionProperties());
@@ -286,7 +287,7 @@ BOOST_AUTO_TEST_CASE(XHPLimitDefault) {
BOOST_AUTO_TEST_CASE(InjectorType) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
auto injectionProps = std::make_shared<Opm::WellInjectionProperties>(well.getInjectionProperties());
injectionProps->injectorType = Opm::WellInjector::WATER;
@@ -302,7 +303,7 @@ BOOST_AUTO_TEST_CASE(InjectorType) {
BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK( !well.getProductionProperties().hasProductionControl( Opm::WellProducer::ORAT ));
@@ -349,7 +350,7 @@ BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) {
BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RATE ));
BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RESV ));
@@ -391,7 +392,7 @@ BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) {
/*********************************************************************/
BOOST_AUTO_TEST_CASE(WellGuideRatePhase_GuideRatePhaseSet) {
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK_EQUAL(Opm::GuideRate::UNDEFINED, well.getGuideRatePhase());
@@ -402,7 +403,7 @@ BOOST_AUTO_TEST_CASE(WellGuideRatePhase_GuideRatePhaseSet) {
}
BOOST_AUTO_TEST_CASE(WellEfficiencyFactorSet) {
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC());
BOOST_CHECK_EQUAL(1.0, well.getEfficiencyFactor());
BOOST_CHECK( well.updateEfficiencyFactor(0.9));
@@ -754,7 +755,7 @@ BOOST_AUTO_TEST_CASE(CMODE_DEFAULT) {
BOOST_AUTO_TEST_CASE(WELL_CONTROLS) {
Opm::Well2 well("WELL", "GROUP", 0, 0, 0, 0, 1000, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Opm::WellCompletion::DEPTH);
Opm::Well2 well("WELL", "GROUP", 0, 0, 0, 0, 1000, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Opm::WellCompletion::DEPTH, UnitSystem::newMETRIC());
Opm::SummaryState st;
const auto prod_controls = well.productionControls(st);
}

View File

@@ -35,7 +35,7 @@
using namespace Opm;
inline std::string prefix() {
inline std::string path_prefix() {
return boost::unit_test::framework::master_test_suite().argv[1];
}
@@ -304,7 +304,7 @@ BOOST_AUTO_TEST_CASE( NorneRestartConfig ) {
rptConfig.push_back( std::make_tuple(241 , true , boost::gregorian::date( 2006,10,10)) );
Parser parser;
auto deck = parser.parseFile( prefix() + "IOConfig/RPTRST_DECK.DATA");
auto deck = parser.parseFile( path_prefix() + "IOConfig/RPTRST_DECK.DATA");
EclipseState state(deck);
Schedule schedule(deck, state.getInputGrid(), state.get3DProperties(), state.runspec());
@@ -350,7 +350,7 @@ BOOST_AUTO_TEST_CASE( RestartConfig2 ) {
Parser parser;
auto deck = parser.parseFile(prefix() + "IOConfig/RPT_TEST2.DATA");
auto deck = parser.parseFile(path_prefix() + "IOConfig/RPT_TEST2.DATA");
EclipseState state( deck);
Schedule schedule(deck, state.getInputGrid(), state.get3DProperties(), state.runspec());
const auto& rstConfig = state.cfg().restart();
@@ -363,6 +363,6 @@ BOOST_AUTO_TEST_CASE( RestartConfig2 ) {
BOOST_AUTO_TEST_CASE( SPE9END ) {
Parser parser;
auto deck = parser.parseFile(prefix() + "IOConfig/SPE9_END.DATA");
auto deck = parser.parseFile(path_prefix() + "IOConfig/SPE9_END.DATA");
BOOST_CHECK_NO_THROW( EclipseState state( deck) );
}