Remove unused code.

This commit is contained in:
Atgeirr Flø Rasmussen committed 2019-11-25 11:00:21 +01:00
1 parent bddeaba880
commit e718bf3ccf
21 files changed
-7041

No files matched your search

-115
View File
@@ -1,115 +0,0 @@
/*
Copyright 2012 SINTEF ICT, Applied Mathematics.
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 <chrono>
#include <config.h>
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE WellCollectionTest
#include <boost/test/unit_test.hpp>
#include <opm/core/wells/WellCollection.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
Parser parser;
std::string scheduleFile("wells_group.data");
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Runspec runspec(deck);
const Schedule sched(deck, grid, eclipseProperties, runspec);
SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
WellCollection collection;
// Add groups to WellCollection
const auto& fieldGroup = sched.getGroup("FIELD", 2);
collection.addField(fieldGroup, summaryState, pu);
collection.addGroup( sched.getGroup( "G1", 2 ), fieldGroup.name(), summaryState, pu);
collection.addGroup( sched.getGroup( "G2", 2 ), fieldGroup.name(), summaryState, pu);
BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name());
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G1")->getParent()->name());
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G2")->getParent()->name());
// Add wells to WellCollection
WellCollection wellCollection;
const auto wells = sched.getWellsatEnd();
for (size_t i=0; i<wells.size(); i++) {
collection.addWell(wells[i], summaryState, pu);
}
BOOST_CHECK_EQUAL("G1", collection.findNode("INJ1")->getParent()->name());
BOOST_CHECK_EQUAL("G1", collection.findNode("INJ2")->getParent()->name());
BOOST_CHECK_EQUAL("G2", collection.findNode("PROD1")->getParent()->name());
BOOST_CHECK_EQUAL("G2", collection.findNode("PROD2")->getParent()->name());
}
BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
Parser parser;
std::string scheduleFile("wells_group.data");
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Runspec runspec(deck);
const Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
size_t timestep = 2;
WellCollection collection;
// Add groups to WellCollection
const auto& fieldGroup = sched.getGroup("FIELD", timestep);
collection.addField( fieldGroup, summaryState, pu);
collection.addGroup( sched.getGroup( "G1", timestep ), fieldGroup.name(), summaryState, pu);
collection.addGroup( sched.getGroup( "G2", timestep ), fieldGroup.name(), summaryState, pu);
BOOST_CHECK_EQUAL(1.0, collection.findNode("FIELD")->efficiencyFactor());
BOOST_CHECK_EQUAL(1.0, collection.findNode("G1")->getParent()->efficiencyFactor());
BOOST_CHECK_EQUAL(1.0, collection.findNode("G2")->getParent()->efficiencyFactor());
// Add wells to WellCollection
const auto wells1 = sched.getWells(timestep);
for (size_t i=0; i<wells1.size(); i++) {
collection.addWell(wells1[i], summaryState, pu);
}
// 0.5(inj1) * 0.8(G1)
BOOST_CHECK_CLOSE(0.4, collection.findWellNode("INJ1").getAccumulativeEfficiencyFactor(), 1e-10);
// 0.8(inj2) * 0.8(G1)
BOOST_CHECK_CLOSE(0.64, collection.findWellNode("INJ2").getAccumulativeEfficiencyFactor(), 1e-10);
// 0.5 (prod1) * 1.0 (G2)
BOOST_CHECK_CLOSE(0.5, collection.findWellNode("PROD1").getAccumulativeEfficiencyFactor(), 1e-10);
// 1.0 (prod2) * 1.0 (G2)
BOOST_CHECK_CLOSE(1.0, collection.findWellNode("PROD2").getAccumulativeEfficiencyFactor(), 1e-10);
}
-157
View File
@@ -1,157 +0,0 @@
/*
Copyright 2014 Statoil.
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>
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE WellsModuleTest
#include <boost/test/unit_test.hpp>
#include <opm/core/wells.h>
#include <opm/core/well_controls.h>
#include <iostream>
#include <vector>
#include <memory>
BOOST_AUTO_TEST_CASE(Construction)
{
struct WellControls * ctrls = well_controls_create();
well_controls_set_current( ctrls , 1 );
BOOST_CHECK_EQUAL( 1 , well_controls_get_current( ctrls ));
well_controls_set_current( ctrls , 2 );
BOOST_CHECK_EQUAL( 2 , well_controls_get_current( ctrls ));
{
enum WellControlType type1 = BHP;
enum WellControlType type2 = SURFACE_RATE;
int num_phases = 3;
double dist1[3] = {0 , 1 , 2};
double dist2[3] = {10, 11 , 12};
double target = 77;
double alq = 88;
int vfp = 42;
well_controls_assert_number_of_phases( ctrls , num_phases );
well_controls_add_new( type1 , target , alq , vfp , dist1 , ctrls );
well_controls_add_new( type2 , 2*target , 2*alq , 2*vfp , dist2 , ctrls );
BOOST_CHECK_EQUAL( target , well_controls_iget_target(ctrls , 0 ));
BOOST_CHECK_EQUAL( alq , well_controls_iget_alq(ctrls , 0 ));
BOOST_CHECK_EQUAL( vfp , well_controls_iget_vfp(ctrls , 0 ));
BOOST_CHECK_EQUAL( type1 , well_controls_iget_type(ctrls , 0 ));
BOOST_CHECK_EQUAL( 2*target , well_controls_iget_target(ctrls , 1 ));
BOOST_CHECK_EQUAL( 2*alq , well_controls_iget_alq(ctrls , 1 ));
BOOST_CHECK_EQUAL( 2*vfp , well_controls_iget_vfp(ctrls , 1 ));
BOOST_CHECK_EQUAL( type2 , well_controls_iget_type(ctrls , 1 ));
well_controls_set_current( ctrls , 1 );
BOOST_CHECK_EQUAL( type2 , well_controls_get_current_type( ctrls ));
BOOST_CHECK_EQUAL( well_controls_iget_target( ctrls , 1 ) , well_controls_get_current_target( ctrls ));
{
const double * d1 = well_controls_iget_distr( ctrls , 0 );
const double * d2 = well_controls_iget_distr( ctrls , 1 );
BOOST_CHECK( memcmp(d1 , dist1 , num_phases * sizeof * d1 ) == 0);
BOOST_CHECK( memcmp(d2 , dist2 , num_phases * sizeof * d2 ) == 0);
}
}
well_controls_iset_target( ctrls , 0 , 123);
BOOST_CHECK_EQUAL( 123 , well_controls_iget_target( ctrls , 0 ));
well_controls_iset_target( ctrls , 1 , 456);
BOOST_CHECK_EQUAL( 456 , well_controls_iget_target( ctrls , 1 ));
well_controls_iset_alq( ctrls , 0 , 789);
BOOST_CHECK_EQUAL( 789 , well_controls_iget_alq( ctrls , 0 ));
well_controls_iset_alq( ctrls , 1 , 234);
BOOST_CHECK_EQUAL( 234 , well_controls_iget_alq( ctrls , 1 ));
well_controls_iset_vfp( ctrls , 0 , 567);
BOOST_CHECK_EQUAL( 567 , well_controls_iget_vfp( ctrls , 0 ));
well_controls_iset_vfp( ctrls , 1 , 890);
BOOST_CHECK_EQUAL( 890 , well_controls_iget_vfp( ctrls , 1 ));
well_controls_iset_type( ctrls , 0 , SURFACE_RATE);
BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type( ctrls , 0 ));
well_controls_iset_type( ctrls , 1 , BHP);
BOOST_CHECK_EQUAL( BHP, well_controls_iget_type( ctrls , 1 ));
{
double newDist[3] = {77,78,79};
const double * tmp;
well_controls_iset_distr( ctrls , 0 , newDist );
tmp = well_controls_iget_distr( ctrls , 0);
BOOST_CHECK( memcmp(tmp , newDist , 3 * sizeof * tmp ) == 0);
}
well_controls_destroy( ctrls );
}
BOOST_AUTO_TEST_CASE(OpenClose)
{
struct WellControls * ctrls = well_controls_create();
BOOST_CHECK_EQUAL( true , well_controls_well_is_open(ctrls) );
BOOST_CHECK_EQUAL( false , well_controls_well_is_stopped(ctrls) );
well_controls_open_well( ctrls );
BOOST_CHECK_EQUAL( true , well_controls_well_is_open(ctrls) );
BOOST_CHECK_EQUAL( false , well_controls_well_is_stopped(ctrls) );
well_controls_stop_well( ctrls );
BOOST_CHECK_EQUAL( false , well_controls_well_is_open(ctrls) );
BOOST_CHECK_EQUAL( true , well_controls_well_is_stopped(ctrls) );
well_controls_destroy( ctrls );
}
BOOST_AUTO_TEST_CASE(Clone)
{
std::shared_ptr<WellControls>
ctrls(well_controls_create(),
& well_controls_destroy);
const WellControlType type1 = BHP;
const WellControlType type2 = SURFACE_RATE;
const int num_phases = 3;
const double dist1[] = { 0, 1, 2};
const double dist2[] = {10, 11, 12};
const double target = 77;
const double alq = 88;
const int vfp = 42;
well_controls_assert_number_of_phases(ctrls.get(), num_phases);
well_controls_add_new(type1, target, alq, vfp, dist1, ctrls.get());
well_controls_add_new(type2, 2*target, 2*alq, 2*vfp, dist2, ctrls.get());
std::shared_ptr<WellControls>
c(well_controls_clone(ctrls.get()),
& well_controls_destroy);
BOOST_CHECK(well_controls_equal(ctrls.get(), c.get(), false));
}
-249
View File
@@ -1,249 +0,0 @@
/*
Copyright 2012 SINTEF ICT, Applied Mathematics.
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>
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE WellsModuleTest
#include <boost/test/unit_test.hpp>
#include <opm/core/wells.h>
#include <opm/core/well_controls.h>
#include <iostream>
#include <vector>
#include <memory>
namespace
{
static double invalid_alq = -1e100;
static double invalid_vfp = -2147483647;
} //Namespace
BOOST_AUTO_TEST_CASE(Construction)
{
const int nphases = 2;
const int nwells = 2;
const int nperfs = 2;
std::shared_ptr<Wells> W(create_wells(nphases, nwells, nperfs),
destroy_wells);
if (W) {
int cells[] = { 0, 9 };
double WI = 1.0;
int sat_table_id = -1;
const double ifrac[] = { 1.0, 0.0 };
const bool ok0 = add_well(INJECTOR, 0.0, 1, &ifrac[0], &cells[0],
&WI, &sat_table_id,"INJECTOR", true, W.get());
const double pfrac[] = { 0.0, 0.0 };
const bool ok1 = add_well(PRODUCER, 0.0, 1, &pfrac[0], &cells[1],
&WI, &sat_table_id,"PRODUCER", true, W.get());
if (ok0 && ok1) {
BOOST_CHECK_EQUAL(W->number_of_phases, nphases);
BOOST_CHECK_EQUAL(W->number_of_wells , nwells );
BOOST_CHECK_EQUAL(W->well_connpos[0], 0);
BOOST_CHECK_EQUAL(W->well_connpos[1], 1);
BOOST_CHECK_EQUAL(W->well_connpos[W->number_of_wells], nperfs);
BOOST_CHECK_EQUAL(W->well_cells[W->well_connpos[0]], cells[0]);
BOOST_CHECK_EQUAL(W->well_cells[W->well_connpos[1]], cells[1]);
BOOST_CHECK_EQUAL(W->WI[W->well_connpos[0]], WI);
BOOST_CHECK_EQUAL(W->WI[W->well_connpos[1]], WI);
using std::string;
BOOST_CHECK_EQUAL(string(W->name[0]), string("INJECTOR"));
BOOST_CHECK_EQUAL(string(W->name[1]), string("PRODUCER"));
}
}
}
BOOST_AUTO_TEST_CASE(Controls)
{
const int nphases = 2;
const int nwells = 1;
const int nperfs = 2;
std::shared_ptr<Wells> W(create_wells(nphases, nwells, nperfs),
destroy_wells);
if (W) {
int cells[] = { 0 , 9 };
double WI [] = { 1.0, 1.0 };
const double ifrac[] = { 1.0, 0.0 };
int sat_table_id = -1;
const bool ok = add_well(INJECTOR, 0.0, nperfs, &ifrac[0], &cells[0],
&WI[0], &sat_table_id, "INJECTOR", true, W.get());
if (ok) {
const double distr[] = { 1.0, 0.0 };
const bool ok1 = append_well_controls(BHP, 1,
invalid_alq, invalid_vfp,
&distr[0],
0, W.get());
const bool ok2 = append_well_controls(SURFACE_RATE, 1,
invalid_alq, invalid_vfp,
&distr[0],
0, W.get());
if (ok1 && ok2) {
WellControls* ctrls = W->ctrls[0];
BOOST_CHECK_EQUAL(well_controls_get_num(ctrls) , 2);
BOOST_CHECK_EQUAL(well_controls_get_current(ctrls), -1);
set_current_control(0, 0, W.get());
BOOST_CHECK_EQUAL(well_controls_get_current(ctrls), 0);
set_current_control(0, 1, W.get());
BOOST_CHECK_EQUAL(well_controls_get_current(ctrls), 1);
BOOST_CHECK_EQUAL(well_controls_iget_type(ctrls , 0) , BHP);
BOOST_CHECK_EQUAL(well_controls_iget_type(ctrls , 1) , SURFACE_RATE);
BOOST_CHECK_EQUAL(well_controls_iget_target(ctrls , 0), 1.0);
BOOST_CHECK_EQUAL(well_controls_iget_target(ctrls , 1), 1.0);
}
}
}
}
BOOST_AUTO_TEST_CASE(Copy)
{
const int nphases = 2;
const int nwells = 2;
const int nperfs = 2;
std::shared_ptr<Wells> W1(create_wells(nphases, nwells, nperfs),
destroy_wells);
std::shared_ptr<Wells> W2;
if (W1) {
int cells[] = { 0, 9 };
const double WI = 1.0;
const double ifrac[] = { 1.0, 0.0 };
int sat_table_id = -1;
const bool ok0 = add_well(INJECTOR, 0.0, 1, &ifrac[0], &cells[0],
&WI, &sat_table_id, "INJECTOR", true, W1.get());
const double pfrac[] = { 0.0, 0.0 };
const bool ok1 = add_well(PRODUCER, 0.0, 1, &pfrac[0], &cells[1],
&WI, &sat_table_id, "PRODUCER", true, W1.get());
bool ok = ok0 && ok1;
for (int w = 0; ok && (w < W1->number_of_wells); ++w) {
const double distr[] = { 1.0, 0.0 };
const bool okc1 = append_well_controls(BHP, 1,
invalid_alq, invalid_vfp,
&distr[0], w,
W1.get());
const bool okc2 = append_well_controls(SURFACE_RATE, 1,
invalid_alq, invalid_vfp,
&distr[0], w,
W1.get());
ok = okc1 && okc2;
}
if (ok) {
W2.reset(clone_wells(W1.get()), destroy_wells);
}
}
if (W2) {
BOOST_CHECK_EQUAL(W2->number_of_phases, W1->number_of_phases);
BOOST_CHECK_EQUAL(W2->number_of_wells , W1->number_of_wells );
BOOST_CHECK_EQUAL(W2->well_connpos[0] , W1->well_connpos[0] );
for (int w = 0; w < W1->number_of_wells; ++w) {
using std::string;
BOOST_CHECK_EQUAL(string(W2->name[w]), string(W1->name[w]));
BOOST_CHECK_EQUAL( W2->type[w] , W1->type[w] );
BOOST_CHECK_EQUAL(W2->well_connpos[w + 1],
W1->well_connpos[w + 1]);
for (int j = W1->well_connpos[w];
j < W1->well_connpos[w + 1]; ++j) {
BOOST_CHECK_EQUAL(W2->well_cells[j], W1->well_cells[j]);
BOOST_CHECK_EQUAL(W2->WI [j], W1->WI [j]);
}
BOOST_CHECK(W1->ctrls[w] != 0);
BOOST_CHECK(W2->ctrls[w] != 0);
WellControls* c1 = W1->ctrls[w];
WellControls* c2 = W2->ctrls[w];
BOOST_CHECK_EQUAL(well_controls_get_num(c2) , well_controls_get_num(c1));
BOOST_CHECK_EQUAL(well_controls_get_current(c2) , well_controls_get_current(c1));
for (int c = 0; c < well_controls_get_num(c1); ++c) {
BOOST_CHECK_EQUAL(well_controls_iget_type(c2, c) , well_controls_iget_type(c1 , c));
BOOST_CHECK_EQUAL(well_controls_iget_target(c2, c) , well_controls_iget_target(c1 , c));
{
const double * dist1 = well_controls_iget_distr(c1 , c );
const double * dist2 = well_controls_iget_distr(c2 , c );
for (int p = 0; p < W1->number_of_phases; ++p)
BOOST_CHECK_EQUAL( dist1[p] , dist2[p]);
}
}
BOOST_CHECK( well_controls_equal( c1 , c2 , false) );
}
}
}
BOOST_AUTO_TEST_CASE(Equals_WellsEqual_ReturnsTrue) {
const int nphases = 2;
const int nwells = 2;
const int nperfs = 2;
std::shared_ptr<Wells> W1(create_wells(nphases, nwells, nperfs),
destroy_wells);
std::shared_ptr<Wells> W2(create_wells(nphases, nwells, nperfs),
destroy_wells);
BOOST_CHECK(wells_equal(W1.get(), W2.get() , false));
}
BOOST_AUTO_TEST_CASE(Equals_WellsDiffer_ReturnsFalse) {
const int nphases = 2;
const int nperfs = 2;
std::shared_ptr<Wells> W1(create_wells(nphases, 2, nperfs),
destroy_wells);
std::shared_ptr<Wells> W2(create_wells(nphases, 3, nperfs),
destroy_wells);
BOOST_CHECK(!wells_equal(W1.get(), W2.get() , false ));
}
-143
View File
@@ -1,143 +0,0 @@
/*
Copyright 2014 Statoil.
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>
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE WellsGroupTest
#include <chrono>
#include <memory>
#include <vector>
#include <boost/test/unit_test.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <opm/core/props/phaseUsageFromDeck.hpp>
#include <opm/core/wells/WellsGroup.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(ConstructGroupFromWell) {
std::string scheduleFile("wells_group.data");
Parser parser;
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec);
SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
auto wells = sched.getWellsatEnd();
for (size_t i=0; i<wells.size(); i++) {
const auto& well = wells[i];
std::shared_ptr<WellsGroupInterface> wellsGroup = createWellWellsGroup(well, summaryState, pu);
BOOST_CHECK_EQUAL(well.name(), wellsGroup->name());
if (well.isInjector()) {
const auto controls = well.injectionControls(summaryState);
BOOST_CHECK_EQUAL(controls.surface_rate, wellsGroup->injSpec().surface_flow_max_rate_);
BOOST_CHECK_EQUAL(controls.bhp_limit, wellsGroup->injSpec().BHP_limit_);
BOOST_CHECK_EQUAL(controls.reservoir_rate, wellsGroup->injSpec().reservoir_flow_max_rate_);
BOOST_CHECK_EQUAL(0.0, wellsGroup->prodSpec().guide_rate_);
}
if (well.isProducer()) {
const auto controls = well.productionControls(summaryState);
BOOST_CHECK_EQUAL(controls.resv_rate, wellsGroup->prodSpec().reservoir_flow_max_rate_);
BOOST_CHECK_EQUAL(controls.bhp_limit, wellsGroup->prodSpec().BHP_limit_);
BOOST_CHECK_EQUAL(controls.oil_rate, wellsGroup->prodSpec().oil_max_rate_);
BOOST_CHECK_EQUAL(controls.water_rate, wellsGroup->prodSpec().water_max_rate_);
BOOST_CHECK_EQUAL(0.0, wellsGroup->injSpec().guide_rate_);
}
}
}
BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) {
Parser parser;
std::string scheduleFile("wells_group.data");
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
for( const auto& grp_name : sched.groupNames() ) {
const auto& group = sched.getGroup(grp_name, 2);
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, summaryState, pu);
BOOST_CHECK_EQUAL(group.name(), wellsGroup->name());
if (group.isInjectionGroup()) {
const auto& injection = group.injectionControls(summaryState);
BOOST_CHECK_EQUAL(injection.surface_max_rate, wellsGroup->injSpec().surface_flow_max_rate_);
BOOST_CHECK_EQUAL(injection.resv_max_rate, wellsGroup->injSpec().reservoir_flow_max_rate_);
BOOST_CHECK_EQUAL(injection.target_reinj_fraction, wellsGroup->injSpec().reinjection_fraction_target_);
BOOST_CHECK_EQUAL(injection.target_void_fraction, wellsGroup->injSpec().voidage_replacment_fraction_);
}
if (group.isProductionGroup()) {
const auto& production = group.productionControls(summaryState);
BOOST_CHECK_EQUAL(production.resv_target, wellsGroup->prodSpec().reservoir_flow_max_rate_);
BOOST_CHECK_EQUAL(production.gas_target, wellsGroup->prodSpec().gas_max_rate_);
BOOST_CHECK_EQUAL(production.oil_target, wellsGroup->prodSpec().oil_max_rate_);
BOOST_CHECK_EQUAL(production.water_target, wellsGroup->prodSpec().water_max_rate_);
BOOST_CHECK_EQUAL(production.liquid_target, wellsGroup->prodSpec().liquid_max_rate_);
}
}
}
BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
Parser parser;
std::string scheduleFile("wells_group.data");
Deck deck = parser.parseFile(scheduleFile);
EclipseState eclipseState(deck);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
for( const auto& grp_name : sched.groupNames() ) {
const auto& group = sched.getGroup(grp_name, 2);
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, summaryState, pu);
BOOST_CHECK_EQUAL(group.name(), wellsGroup->name());
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
}
}
-331
View File
@@ -1,331 +0,0 @@
/*
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>
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE WellsManagerTests
#include <boost/test/unit_test.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/core/wells/WellsManager.hpp>
#include <opm/core/wells.h>
#include <opm/core/well_controls.h>
#include <opm/grid/GridManager.hpp>
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, well_controls_get_num(ctrls0)); // The number of controls for the injector == 3??
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));
// The different targets
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));
// Which control is active
BOOST_CHECK_EQUAL(0, well_controls_get_current(ctrls0));
// The phase distribution in the active target
{
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
}
}
// The producer
{
const struct WellControls * ctrls1 = ctrls[1];
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));
// The different targets
BOOST_CHECK_EQUAL(-20000.0 / 86400, well_controls_iget_target(ctrls1, 0));
BOOST_CHECK_EQUAL(1000 * 100000, well_controls_iget_target(ctrls1, 1));
// Which control is active
BOOST_CHECK_EQUAL(0, well_controls_get_current(ctrls1));
// The phase distribution in the active target
{
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
}
}
}
void check_controls_epoch1(struct WellControls ** ctrls) {
// The injector
{
const struct WellControls * ctrls0 = ctrls[0];
BOOST_CHECK_EQUAL(3, well_controls_get_num(ctrls0)); // The number of controls for the injector == 3??
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));
// The different targets
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);
// Which control is active
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
}
}
// The producer
{
const struct WellControls * ctrls1 = ctrls[1];
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));
// The different targets
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);
// Which control is active
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
}
}
}
void check_controls_epoch3(struct WellControls ** ctrls) {
// The new producer
const struct WellControls * ctrls1 = ctrls[1];
// Note: controls include default (1 atm) BHP control.
// and also an ORAT control
BOOST_CHECK_EQUAL(2, well_controls_get_num(ctrls1));
}
BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
const std::string filename = "wells_manager_data.data";
Opm::Parser parser;
Opm::Deck deck = parser.parseFile(filename);
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
{
Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 0, *vanguard.c_grid());
wells_static_check(wellsManager.c_wells());
check_controls_epoch0(wellsManager.c_wells()->ctrls);
}
{
Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 1, *vanguard.c_grid());
wells_static_check(wellsManager.c_wells());
check_controls_epoch1(wellsManager.c_wells()->ctrls);
}
{
Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 3, *vanguard.c_grid());
const Wells* wells = wellsManager.c_wells();
// There is 3 wells in total in the deck at the 3rd schedule step.
// PROD1 is shut and should therefore not be counted.
// The new well is therefore the secound well.
BOOST_CHECK_EQUAL(2, wells->number_of_wells);
BOOST_CHECK_EQUAL(wells->name[0], "INJ1");
BOOST_CHECK_EQUAL(wells->name[1], "NEW");
check_controls_epoch3(wellsManager.c_wells()->ctrls);
}
}
BOOST_AUTO_TEST_CASE(WellsEqual) {
const std::string filename = "wells_manager_data.data";
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
Opm::WellsManager wellsManager0(eclipseState, sched, summaryState, 0, *vanguard.c_grid());
Opm::WellsManager wellsManager1(eclipseState, sched, summaryState, 1, *vanguard.c_grid());
BOOST_CHECK(wells_equal( wellsManager0.c_wells() , wellsManager0.c_wells(),false));
BOOST_CHECK(!wells_equal( wellsManager0.c_wells() , wellsManager1.c_wells(),false));
}
BOOST_AUTO_TEST_CASE(ControlsEqual) {
const std::string filename = "wells_manager_data.data";
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
Opm::WellsManager wellsManager0(eclipseState, sched, summaryState, 0, *vanguard.c_grid());
Opm::WellsManager wellsManager1(eclipseState, sched, summaryState, 1, *vanguard.c_grid());
BOOST_CHECK(well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0] , false));
BOOST_CHECK(well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1] , false));
BOOST_CHECK(well_controls_equal( wellsManager1.c_wells()->ctrls[0] , wellsManager1.c_wells()->ctrls[0] , false));
BOOST_CHECK(well_controls_equal( wellsManager1.c_wells()->ctrls[1] , wellsManager1.c_wells()->ctrls[1] , false));
BOOST_CHECK(!well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[1] , false));
BOOST_CHECK(!well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[0] , false));
BOOST_CHECK(!well_controls_equal( wellsManager1.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0] , false));
BOOST_CHECK(!well_controls_equal( wellsManager1.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1] , false));
}
BOOST_AUTO_TEST_CASE(WellShutOK) {
const std::string filename = "wells_manager_data.data";
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
Opm::WellsManager wellsManager2(eclipseState, sched, summaryState, 2, *vanguard.c_grid());
// Shut wells are not added to the deck. i.e number of wells should be 2-1
BOOST_CHECK(wellsManager2.c_wells()->number_of_wells == 1);
//BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *vanguard.c_grid(), NULL));
}
BOOST_AUTO_TEST_CASE(WellSTOPOK) {
const std::string filename = "wells_manager_data_wellSTOP.data";
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager vanguard(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Opm::Schedule sched(deck, grid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
Opm::WellsManager wellsManager(eclipseState, sched, summaryState, 0, *vanguard.c_grid());
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_stopped(ctrls0)); // The first well is closed
BOOST_CHECK(well_controls_well_is_open(ctrls1)); // The second well is open
}
BOOST_AUTO_TEST_CASE(removeWellWithNoPerforation) {
const std::string filename = "wells_no_perforation.data";
Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck);
Opm::GridManager gridManager(eclipseState.getInputGrid());
const auto& inputGrid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, inputGrid);
const Opm::Runspec runspec (deck);
Opm::Schedule sched(deck, inputGrid, eclipseProperties, runspec);
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(sched.getStartTime()));
const auto eclipseGrid = Opm::UgGridHelpers::createEclipseGrid(*gridManager.c_grid(), inputGrid);
sched.filterConnections(eclipseGrid);
Opm::WellsManager wellsManager0(eclipseState, sched, summaryState, 0, *gridManager.c_grid());
BOOST_CHECK_EQUAL( wellsManager0.c_wells()->number_of_wells, 1);
Opm::WellsManager wellsManager5(eclipseState, sched, summaryState, 5, *gridManager.c_grid());
BOOST_CHECK_EQUAL( wellsManager5.c_wells()->number_of_wells, 1);
}