diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake
index e05348ea..3a1ce398 100644
--- a/CMakeLists_files.cmake
+++ b/CMakeLists_files.cmake
@@ -191,6 +191,7 @@ list (APPEND TEST_SOURCE_FILES
tests/test_minpvprocessor.cpp
tests/test_gridutilities.cpp
tests/test_anisotropiceikonal.cpp
+ tests/test_stoppedwells.cpp
)
# originally generated with the command:
@@ -219,9 +220,10 @@ list (APPEND TEST_DATA_FILES
tests/wells_manager_data.data
tests/wells_manager_data_expanded.data
tests/wells_manager_data_wellSTOP.data
- tests/wells_group.data
- tests/TESTTIMER.DATA
+ tests/wells_group.data
+ tests/TESTTIMER.DATA
tests/CORNERPOINT_ACTNUM.DATA
+ tests/wells_stopped.data
)
# originally generated with the command:
diff --git a/tests/test_stoppedwells.cpp b/tests/test_stoppedwells.cpp
new file mode 100644
index 00000000..5eee914e
--- /dev/null
+++ b/tests/test_stoppedwells.cpp
@@ -0,0 +1,95 @@
+/*
+ Copyright 2014 IRIS
+
+ 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 .
+*/
+
+#include
+
+#if HAVE_DYNAMIC_BOOST_TEST
+#define BOOST_TEST_DYN_LINK
+#endif
+
+#define BOOST_TEST_MODULE StoppedWellsTests
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+using namespace Opm;
+
+BOOST_AUTO_TEST_CASE(TestStoppedWells)
+{
+ const std::string filename = "wells_stopped.data";
+ Opm::ParserPtr parser(new Opm::Parser());
+ Opm::DeckConstPtr deck(parser->parseFile(filename));
+
+ Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck));
+ Opm::GridManager gridManager(deck);
+
+ double target_surfacerate_inj;
+ double target_surfacerate_prod;
+
+ BlackoilState state;
+ const std::vector pressure = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+ state.pressure() = pressure;
+
+ // Both wells are open in the first schedule step
+ {
+ Opm::WellsManager wellsManager(eclipseState , 0 , *gridManager.c_grid(), NULL);
+ const Wells* wells = wellsManager.c_wells();
+ const struct WellControls* ctrls0 = wells->ctrls[0];
+ const struct WellControls* ctrls1 = wells->ctrls[1];
+ BOOST_CHECK(well_controls_well_is_open(ctrls0));
+ BOOST_CHECK(well_controls_well_is_open(ctrls1));
+
+ target_surfacerate_inj = well_controls_iget_target(ctrls0 , 0);
+ target_surfacerate_prod = well_controls_iget_target(ctrls1 , 0);
+
+ WellState wellstate;
+ wellstate.init(wells, state);
+ const std::vector wellrates = wellstate.wellRates();
+ BOOST_CHECK_EQUAL (target_surfacerate_inj, wellrates[2]); // Gas injector
+ BOOST_CHECK_EQUAL (target_surfacerate_prod, wellrates[4]); // Oil target rate
+ }
+
+
+ // The injector is stopped
+ {
+ Opm::WellsManager wellsManager(eclipseState , 1 , *gridManager.c_grid(), NULL);
+ const Wells* wells = wellsManager.c_wells();
+ const struct WellControls* ctrls0 = wells->ctrls[0];
+ const struct WellControls* ctrls1 = wells->ctrls[1];
+ BOOST_CHECK(well_controls_well_is_shut(ctrls0)); // injector is stopped
+ BOOST_CHECK(well_controls_well_is_open(ctrls1));
+
+ WellState wellstate;
+ wellstate.init(wells, state);
+
+ const std::vector wellrates = wellstate.wellRates();
+ BOOST_CHECK_EQUAL (0, wellrates[2]); // Gas injector
+ BOOST_CHECK_EQUAL (target_surfacerate_prod, wellrates[4]); // Oil target rate
+ }
+
+}
diff --git a/tests/wells_stopped.data b/tests/wells_stopped.data
new file mode 100644
index 00000000..3a39481b
--- /dev/null
+++ b/tests/wells_stopped.data
@@ -0,0 +1,58 @@
+RUNSPEC
+
+OIL
+GAS
+WATER
+
+
+DIMENS
+ 10 10 1 /
+
+GRID
+
+DXV
+10*1000.0
+/
+
+DYV
+10*1000.0
+/
+
+DZ
+100*20.0
+/
+
+TOPS
+100*10
+/
+
+
+SCHEDULE
+
+WELSPECS
+ 'INJ1' 'G' 1 1 8335 'GAS' /
+ 'PROD1' 'G' 10 10 8400 'OIL' /
+/
+
+COMPDAT
+ 'INJ1' 1 1 1 1 'OPEN' 1 10.6092 0.5 /
+ 'PROD1' 10 1 1 1 'OPEN' 0 10.6092 0.5 /
+/
+
+WCONPROD
+ 'PROD1' 'OPEN' 'ORAT' 20000 4* 1000 /
+/
+
+WCONINJE
+ 'INJ1' 'GAS' 'OPEN' 'RATE' 100 200 400 /
+/
+
+
+TSTEP
+ 1 /
+
+WELOPEN
+ 'INJ1' 'STOP' 5* /
+/
+
+END