2013-12-18 08:06:38 -06:00
|
|
|
/*
|
|
|
|
Copyright 2013 Statoil ASA.
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#if HAVE_DYNAMIC_BOOST_TEST
|
|
|
|
#define BOOST_TEST_DYN_LINK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define NVERBOSE // Suppress own messages when throw()ing
|
|
|
|
|
|
|
|
#define BOOST_TEST_MODULE WellsManagerTests
|
|
|
|
#include <boost/test/unit_test.hpp>
|
2014-01-07 09:10:45 -06:00
|
|
|
|
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
|
|
|
|
2013-12-18 08:06:38 -06:00
|
|
|
#include <opm/core/wells/WellsManager.hpp>
|
2014-01-05 08:03:30 -06:00
|
|
|
#include <opm/core/wells.h>
|
|
|
|
#include <opm/core/well_controls.h>
|
|
|
|
|
2013-12-18 08:06:38 -06:00
|
|
|
#include <opm/core/io/eclipse/EclipseGridParser.hpp>
|
|
|
|
#include <opm/core/grid/GridManager.hpp>
|
|
|
|
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
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];
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls0)); // The number of controls for the injector == 3??
|
2014-01-03 08:02:11 -06:00
|
|
|
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls0 , 0) );
|
|
|
|
BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls0 , 1) );
|
|
|
|
BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls0 , 2) );
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// The different targets
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 100.0 / 86400 , well_controls_iget_target(ctrls0,0));
|
|
|
|
BOOST_CHECK_EQUAL( 200.0 / 86400 , well_controls_iget_target(ctrls0,1));
|
|
|
|
BOOST_CHECK_EQUAL( 400 * 100000 , well_controls_iget_target(ctrls0,2));
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// Which control is active
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 0 , well_controls_get_current(ctrls0) );
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// The phase distribution in the active target
|
2014-01-06 03:26:46 -06:00
|
|
|
{
|
|
|
|
const double * distr = well_controls_iget_distr( ctrls0 , 0 );
|
|
|
|
BOOST_CHECK_EQUAL( 0 , distr[0] ); // Water
|
|
|
|
BOOST_CHECK_EQUAL( 0 , distr[1] ); // Oil
|
|
|
|
BOOST_CHECK_EQUAL( 1 , distr[2] ); // Gas
|
|
|
|
}
|
2014-01-03 08:02:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// The producer
|
|
|
|
{
|
|
|
|
const struct WellControls * ctrls1 = ctrls[1];
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 2 , well_controls_get_num( ctrls1 )); // The number of controls for the producer == 2??
|
|
|
|
BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls1 , 0) );
|
|
|
|
BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls1 , 1) );
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// The different targets
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( -20000.0 / 86400 , well_controls_iget_target(ctrls1,0));
|
|
|
|
BOOST_CHECK_EQUAL( 1000 * 100000 , well_controls_iget_target(ctrls1,1));
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// Which control is active
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 0 , well_controls_get_current(ctrls1));
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// The phase distribution in the active target
|
2014-01-06 03:26:46 -06:00
|
|
|
{
|
|
|
|
const double * distr = well_controls_iget_distr( ctrls1 , 0 );
|
|
|
|
BOOST_CHECK_EQUAL( 0 , distr[0] ); // Water
|
|
|
|
BOOST_CHECK_EQUAL( 1 , distr[1] ); // Oil
|
|
|
|
BOOST_CHECK_EQUAL( 0 , distr[2] ); // Gas
|
|
|
|
}
|
2014-01-03 08:02:11 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void check_controls_epoch1( struct WellControls ** ctrls) {
|
|
|
|
// The injector
|
|
|
|
{
|
|
|
|
const struct WellControls * ctrls0 = ctrls[0];
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls0)); // The number of controls for the injector == 3??
|
2014-01-03 08:02:11 -06:00
|
|
|
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls0 , 0 ));
|
|
|
|
BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls0 , 1 ));
|
|
|
|
BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls0 , 2 ));
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// The different targets
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_CLOSE( 10.0 / 86400 , well_controls_iget_target(ctrls0 , 0) , 0.001);
|
|
|
|
BOOST_CHECK_CLOSE( 20.0 / 86400 , well_controls_iget_target(ctrls0 , 1) , 0.001);
|
|
|
|
BOOST_CHECK_CLOSE( 40 * 100000 , well_controls_iget_target(ctrls0 , 2) , 0.001);
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// Which control is active
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 1 , well_controls_get_current(ctrls0));
|
|
|
|
|
|
|
|
{
|
|
|
|
const double * distr = well_controls_iget_distr( ctrls0 , 1 );
|
|
|
|
BOOST_CHECK_EQUAL( 1 , distr[0] ); // Water
|
|
|
|
BOOST_CHECK_EQUAL( 0 , distr[1] ); // Oil
|
|
|
|
BOOST_CHECK_EQUAL( 0 , distr[2] ); // Gas
|
|
|
|
}
|
2014-01-03 08:02:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// The producer
|
|
|
|
{
|
|
|
|
const struct WellControls * ctrls1 = ctrls[1];
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls1)); // The number of controls for the producer - now 3.
|
|
|
|
BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls1 , 0) );
|
|
|
|
BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls1 , 1) );
|
|
|
|
BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls1 , 2) );
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// The different targets
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_CLOSE( -999.0 / 86400 , well_controls_iget_target(ctrls1 , 0), 0.001);
|
|
|
|
BOOST_CHECK_CLOSE( -123.0 / 86400 , well_controls_iget_target(ctrls1 , 1), 0.001);
|
|
|
|
BOOST_CHECK_CLOSE( 100 * 100000 , well_controls_iget_target(ctrls1 , 2), 0.001);
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
// Which control is active
|
2014-01-06 03:26:46 -06:00
|
|
|
BOOST_CHECK_EQUAL( 1 , well_controls_get_current(ctrls1) );
|
|
|
|
|
|
|
|
{
|
|
|
|
const double * distr = well_controls_iget_distr( ctrls1 , 1 );
|
|
|
|
BOOST_CHECK_EQUAL( 1 , distr[0] ); // Water
|
|
|
|
BOOST_CHECK_EQUAL( 1 , distr[1] ); // Oil
|
|
|
|
BOOST_CHECK_EQUAL( 1 , distr[2] ); // Gas
|
|
|
|
}
|
2014-01-03 08:02:11 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
2013-12-18 08:06:38 -06:00
|
|
|
}
|
2014-01-03 08:02:11 -06:00
|
|
|
|
2014-01-07 09:10:45 -06:00
|
|
|
BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
|
|
|
|
|
|
|
|
Opm::ParserPtr parser(new Opm::Parser());
|
2014-01-08 09:10:55 -06:00
|
|
|
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(parser->parse("wells_manager_data.data")));
|
2014-01-07 09:10:45 -06:00
|
|
|
|
|
|
|
Opm::EclipseGridParser Deck("wells_manager_data.data");
|
|
|
|
Opm::GridManager gridManager(Deck);
|
|
|
|
|
|
|
|
Deck.setCurrentEpoch(0);
|
|
|
|
{
|
2014-01-08 09:10:55 -06:00
|
|
|
Opm::WellsManager wellsManager(eclipseState, 0, Deck, *gridManager.c_grid(), NULL);
|
2014-01-07 09:10:45 -06:00
|
|
|
Opm::WellsManager oldWellsManager(Deck, *gridManager.c_grid(), NULL);
|
|
|
|
|
|
|
|
const Wells* wells = wellsManager.c_wells();
|
|
|
|
wells_static_check( wells );
|
|
|
|
check_controls_epoch0( wells->ctrls );
|
|
|
|
|
|
|
|
BOOST_CHECK(wells_equal(wells, oldWellsManager.c_wells()));
|
|
|
|
}
|
|
|
|
|
|
|
|
Deck.setCurrentEpoch(1);
|
|
|
|
{
|
2014-01-08 09:10:55 -06:00
|
|
|
Opm::WellsManager wellsManager(eclipseState, 1,Deck, *gridManager.c_grid(), NULL);
|
2014-01-07 09:10:45 -06:00
|
|
|
Opm::WellsManager oldWellsManager(Deck, *gridManager.c_grid(), NULL);
|
|
|
|
|
|
|
|
const Wells* wells = wellsManager.c_wells();
|
|
|
|
wells_static_check( wells );
|
|
|
|
check_controls_epoch1( wells->ctrls );
|
|
|
|
|
|
|
|
BOOST_CHECK(wells_equal(wells, oldWellsManager.c_wells()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-03 08:02:11 -06:00
|
|
|
|
|
|
|
|
2014-01-03 08:14:49 -06:00
|
|
|
BOOST_AUTO_TEST_CASE(WellsEqual) {
|
|
|
|
Opm::EclipseGridParser Deck("wells_manager_data.data");
|
|
|
|
Opm::GridManager gridManager(Deck);
|
|
|
|
|
|
|
|
Deck.setCurrentEpoch(0);
|
|
|
|
Opm::WellsManager wellsManager0(Deck, *gridManager.c_grid(), NULL);
|
|
|
|
|
|
|
|
Deck.setCurrentEpoch(1);
|
|
|
|
Opm::WellsManager wellsManager1(Deck, *gridManager.c_grid(), NULL);
|
|
|
|
|
|
|
|
BOOST_CHECK( wells_equal( wellsManager0.c_wells() , wellsManager0.c_wells()) );
|
|
|
|
BOOST_CHECK( !wells_equal( wellsManager0.c_wells() , wellsManager1.c_wells()) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(ControlsEqual) {
|
|
|
|
Opm::EclipseGridParser Deck("wells_manager_data.data");
|
|
|
|
Opm::GridManager gridManager(Deck);
|
|
|
|
|
|
|
|
Deck.setCurrentEpoch(0);
|
|
|
|
Opm::WellsManager wellsManager0(Deck, *gridManager.c_grid(), NULL);
|
|
|
|
|
|
|
|
Deck.setCurrentEpoch(1);
|
|
|
|
Opm::WellsManager wellsManager1(Deck, *gridManager.c_grid(), NULL);
|
|
|
|
|
|
|
|
BOOST_CHECK( well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0]));
|
|
|
|
BOOST_CHECK( well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1]));
|
|
|
|
BOOST_CHECK( well_controls_equal( wellsManager1.c_wells()->ctrls[0] , wellsManager1.c_wells()->ctrls[0]));
|
|
|
|
BOOST_CHECK( well_controls_equal( wellsManager1.c_wells()->ctrls[1] , wellsManager1.c_wells()->ctrls[1]));
|
|
|
|
|
|
|
|
BOOST_CHECK( !well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[1]));
|
|
|
|
BOOST_CHECK( !well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[0]));
|
|
|
|
BOOST_CHECK( !well_controls_equal( wellsManager1.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0]));
|
|
|
|
BOOST_CHECK( !well_controls_equal( wellsManager1.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1]));
|
|
|
|
}
|
|
|
|
|
|
|
|
|