From 487ff810fd0480303f2bef71e6e22d8844b2d1fe Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 3 Jan 2014 15:02:11 +0100 Subject: [PATCH] Added test_wellmanager which loads wellmanager from deck and tests many values. --- tests/test_wellsmanager.cpp | 158 ++++++++++++++++++++++++++++++++-- tests/wells_manager_data.data | 25 ++++-- 2 files changed, 171 insertions(+), 12 deletions(-) diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index c37feed3b..6e8ba621c 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -31,10 +31,156 @@ #include #include -BOOST_AUTO_TEST_CASE(Constructor_Old_Works) { - Opm::EclipseGridParser oldParser("wells_manager_data.data"); - Opm::GridManager gridManager(oldParser); - Opm::WellsManager wellsManager(oldParser, *gridManager.c_grid(), NULL); - const Wells* oldWells = wellsManager.c_wells(); - BOOST_CHECK_EQUAL(oldWells->number_of_wells, 2); + +void wells_static_check(const Wells* wells) { + BOOST_CHECK_EQUAL(2 , wells->number_of_wells); + BOOST_CHECK_EQUAL(3 , wells->number_of_phases); + + BOOST_CHECK_EQUAL("INJ1" , wells->name[0]); + BOOST_CHECK_EQUAL("PROD1" , wells->name[1]); + + /* The mapping from well number into the wells->WI and wells->well_cells arrays. */ + BOOST_CHECK_EQUAL(0 , wells->well_connpos[0]); + BOOST_CHECK_EQUAL(1 , wells->well_connpos[1]); + BOOST_CHECK_EQUAL(2 , wells->well_connpos[2]); + + /* Connection factor */ + BOOST_CHECK_CLOSE(1.2279166666666664e-12 , wells->WI[0] , 0.001); + BOOST_CHECK_CLOSE(1.2279166666666664e-12 , wells->WI[1] , 0.001); + + /* Completed cells */ + BOOST_CHECK_EQUAL(0 , wells->well_cells[0]); + BOOST_CHECK_EQUAL(9 + 2*10 + 2*10*10 , wells->well_cells[1]); } + + +/* + The number of controls is determined by looking at which elements + have been given explicit - non-default - values in the WCONxxxx + keyword. Is that at all interesting? +*/ + + +void check_controls_epoch0( struct WellControls ** ctrls) { + // The injector + { + const struct WellControls * ctrls0 = ctrls[0]; + BOOST_CHECK_EQUAL( 3 , ctrls0->num); // The number of controls for the injector == 3?? + + BOOST_CHECK_EQUAL( SURFACE_RATE , ctrls0->type[0] ); + BOOST_CHECK_EQUAL( RESERVOIR_RATE , ctrls0->type[1] ); + BOOST_CHECK_EQUAL( BHP , ctrls0->type[2] ); + + // The different targets + BOOST_CHECK_EQUAL( 100.0 / 86400 , ctrls0->target[0]); + BOOST_CHECK_EQUAL( 200.0 / 86400 , ctrls0->target[1]); + BOOST_CHECK_EQUAL( 400 * 100000 , ctrls0->target[2]); + + // Which control is active + BOOST_CHECK_EQUAL( 0 , ctrls0->current ); + + // The phase distribution in the active target + BOOST_CHECK_EQUAL( 0 , ctrls0->distr[0] ); // Water + BOOST_CHECK_EQUAL( 0 , ctrls0->distr[1] ); // Oil + BOOST_CHECK_EQUAL( 1 , ctrls0->distr[2] ); // Gas + } + + // The producer + { + const struct WellControls * ctrls1 = ctrls[1]; + BOOST_CHECK_EQUAL( 2 , ctrls1->num); // The number of controls for the producer == 2?? + BOOST_CHECK_EQUAL( SURFACE_RATE , ctrls1->type[0] ); + BOOST_CHECK_EQUAL( BHP , ctrls1->type[1] ); + + // The different targets + BOOST_CHECK_EQUAL( -20000.0 / 86400 , ctrls1->target[0]); + BOOST_CHECK_EQUAL( 1000 * 100000 , ctrls1->target[1]); + + // Which control is active + BOOST_CHECK_EQUAL( 0 , ctrls1->current ); + + // The phase distribution in the active target + BOOST_CHECK_EQUAL( 0 , ctrls1->distr[0] ); // Water + BOOST_CHECK_EQUAL( 1 , ctrls1->distr[1] ); // Oil + BOOST_CHECK_EQUAL( 0 , ctrls1->distr[2] ); // Gas + } +} + + + + +void check_controls_epoch1( struct WellControls ** ctrls) { + // The injector + { + const struct WellControls * ctrls0 = ctrls[0]; + BOOST_CHECK_EQUAL( 3 , ctrls0->num); // The number of controls for the injector == 3?? + + BOOST_CHECK_EQUAL( SURFACE_RATE , ctrls0->type[0] ); + BOOST_CHECK_EQUAL( RESERVOIR_RATE , ctrls0->type[1] ); + BOOST_CHECK_EQUAL( BHP , ctrls0->type[2] ); + + // The different targets + BOOST_CHECK_CLOSE( 10.0 / 86400 , ctrls0->target[0] , 0.001); + BOOST_CHECK_CLOSE( 20.0 / 86400 , ctrls0->target[1] , 0.001); + BOOST_CHECK_CLOSE( 40 * 100000 , ctrls0->target[2] , 0.001); + + // Which control is active + BOOST_CHECK_EQUAL( 1 , ctrls0->current ); + + // The phase distribution in the active target + BOOST_CHECK_EQUAL( 1 , ctrls0->distr[3] ); // Water + BOOST_CHECK_EQUAL( 0 , ctrls0->distr[4] ); // Oil + BOOST_CHECK_EQUAL( 0 , ctrls0->distr[5] ); // Gas + } + + // The producer + { + const struct WellControls * ctrls1 = ctrls[1]; + BOOST_CHECK_EQUAL( 3 , ctrls1->num); // The number of controls for the producer - now 3. + BOOST_CHECK_EQUAL( SURFACE_RATE , ctrls1->type[0] ); + BOOST_CHECK_EQUAL( RESERVOIR_RATE , ctrls1->type[1] ); + BOOST_CHECK_EQUAL( BHP , ctrls1->type[2] ); + + // The different targets + BOOST_CHECK_CLOSE( -999.0 / 86400 , ctrls1->target[0], 0.001); + BOOST_CHECK_CLOSE( -123.0 / 86400 , ctrls1->target[1], 0.001); + BOOST_CHECK_CLOSE( 100 * 100000 , ctrls1->target[2], 0.001); + + // Which control is active + BOOST_CHECK_EQUAL( 1 , ctrls1->current ); + + // The phase distribution in the active target + BOOST_CHECK_EQUAL( 1 , ctrls1->distr[3] ); // Water + BOOST_CHECK_EQUAL( 1 , ctrls1->distr[4] ); // Oil + BOOST_CHECK_EQUAL( 1 , ctrls1->distr[5] ); // Gas + } +} + + + + +BOOST_AUTO_TEST_CASE(Constructor_Works) { + Opm::EclipseGridParser Deck("wells_manager_data.data"); + Opm::GridManager gridManager(Deck); + + Deck.setCurrentEpoch(0); + { + Opm::WellsManager wellsManager(Deck, *gridManager.c_grid(), NULL); + const Wells* wells = wellsManager.c_wells(); + wells_static_check( wells ); + check_controls_epoch0( wells->ctrls ); + } + + + Deck.setCurrentEpoch(1); + { + Opm::WellsManager wellsManager(Deck, *gridManager.c_grid(), NULL); + const Wells* wells = wellsManager.c_wells(); + + wells_static_check( wells ); + check_controls_epoch1( wells->ctrls ); + } +} + + + diff --git a/tests/wells_manager_data.data b/tests/wells_manager_data.data index be631de85..4c810afab 100755 --- a/tests/wells_manager_data.data +++ b/tests/wells_manager_data.data @@ -3,15 +3,15 @@ GAS WATER DIMENS - 15 5 5 / + 10 10 5 / GRID DXV -15*1000.0 / +10*1000.0 / DYV -5*1000.0 / +10*1000.0 / DZV 10.0 20.0 30.0 10.0 5.0 / @@ -26,18 +26,31 @@ WELSPECS COMPDAT 'INJ1' 1 1 1 1 'OPEN' 1 10.6092 0.5 / 'PROD1' 10 3 3 3 'OPEN' 0 10.6092 0.5 / - - / +/ WCONPROD 'PROD1' 'OPEN' 'ORAT' 20000 4* 1000 / / WCONINJE - 'INJ1' 'GAS' 'OPEN' 'RATE' 100000 100000 50000/ + 'INJ1' 'GAS' 'OPEN' 'RATE' 100 200 400 / / +DATES + 1 'FEB' 2000 / +/ + +WCONPROD + 'PROD1' 'OPEN' 'RESV' 999 3* 123 100 / +/ + +WCONINJE + 'INJ1' 'WATER' 'OPEN' 'RESV' 10 20 40 / +/ + + + TSTEP 14.0 /