2017-08-22 10:14:52 -05:00
|
|
|
/*
|
|
|
|
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
|
|
|
Copyright 2017 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 BOOST_TEST_MODULE WellModelTest
|
|
|
|
|
|
|
|
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
|
|
|
|
2021-12-14 01:30:15 -06:00
|
|
|
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
|
|
|
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
|
2024-05-06 07:02:39 -05:00
|
|
|
|
2021-12-14 01:30:15 -06:00
|
|
|
#include <opm/input/eclipse/Python/Python.hpp>
|
2017-08-22 10:14:52 -05:00
|
|
|
|
2024-05-06 07:02:39 -05:00
|
|
|
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
|
|
|
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
|
|
|
|
#include <opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp>
|
|
|
|
#include <opm/input/eclipse/Schedule/UDQ/UDQParams.hpp>
|
|
|
|
#include <opm/input/eclipse/Schedule/Well/WellConnections.hpp>
|
|
|
|
|
2019-10-04 06:20:57 -05:00
|
|
|
#include <opm/grid/GridManager.hpp>
|
2024-05-06 07:02:39 -05:00
|
|
|
|
2021-12-14 01:30:15 -06:00
|
|
|
#include <opm/input/eclipse/Units/Units.hpp>
|
2021-02-25 13:46:51 -06:00
|
|
|
#include <opm/common/utility/TimeService.hpp>
|
2017-08-22 10:14:52 -05:00
|
|
|
|
|
|
|
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
|
2018-11-14 07:52:01 -06:00
|
|
|
#include <opm/grid/GridHelpers.hpp>
|
2024-01-31 07:14:50 -06:00
|
|
|
#include <opm/simulators/flow/FlowMain.hpp>
|
2024-01-31 07:14:50 -06:00
|
|
|
#include <opm/simulators/flow/BlackoilModel.hpp>
|
2024-09-11 07:25:34 -05:00
|
|
|
#include <opm/simulators/flow/FlowProblemBlackoil.hpp>
|
2017-08-22 10:14:52 -05:00
|
|
|
|
2019-09-16 03:58:20 -05:00
|
|
|
#include <opm/models/utils/start.hh>
|
2017-08-22 10:14:52 -05:00
|
|
|
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/wells/StandardWell.hpp>
|
|
|
|
#include <opm/simulators/wells/BlackoilWellModel.hpp>
|
2017-08-22 10:14:52 -05:00
|
|
|
|
2024-05-06 07:02:39 -05:00
|
|
|
#include <opm/input/eclipse/Deck/Deck.hpp>
|
|
|
|
#include <opm/input/eclipse/Parser/Parser.hpp>
|
|
|
|
|
2018-06-21 05:14:17 -05:00
|
|
|
#if HAVE_DUNE_FEM
|
|
|
|
#include <dune/fem/misc/mpimanager.hh>
|
|
|
|
#else
|
|
|
|
#include <dune/common/parallel/mpihelper.hh>
|
|
|
|
#endif
|
2017-08-22 10:14:52 -05:00
|
|
|
|
2024-05-06 07:02:39 -05:00
|
|
|
#include <memory>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <vector>
|
2019-06-20 03:15:51 -05:00
|
|
|
|
2024-02-06 07:47:31 -06:00
|
|
|
using StandardWell = Opm::StandardWell<Opm::Properties::TTag::FlowProblem>;
|
2017-08-22 10:14:52 -05:00
|
|
|
|
|
|
|
struct SetupTest {
|
|
|
|
|
|
|
|
using Grid = UnstructuredGrid;
|
|
|
|
|
2024-05-06 07:02:39 -05:00
|
|
|
SetupTest()
|
2017-08-22 10:14:52 -05:00
|
|
|
{
|
2024-05-06 07:02:39 -05:00
|
|
|
const auto deck = Opm::Parser{}.parseFile("TESTWELLMODEL.DATA");
|
|
|
|
this->ecl_state = std::make_unique<const Opm::EclipseState>(deck);
|
|
|
|
|
|
|
|
const Opm::TableManager table(deck);
|
|
|
|
const Opm::Runspec runspec(deck);
|
|
|
|
|
|
|
|
this->schedule = std::make_unique<const Opm::Schedule>
|
|
|
|
(deck, *this->ecl_state, std::make_shared<Opm::Python>());
|
|
|
|
|
|
|
|
this->summaryState = std::make_unique<Opm::SummaryState>
|
|
|
|
(Opm::TimeService::from_time_t(schedule->getStartTime()),
|
|
|
|
this->ecl_state->runspec().udqParams().undefinedValue());
|
|
|
|
|
2017-08-22 10:14:52 -05:00
|
|
|
current_timestep = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<const Opm::EclipseState> ecl_state;
|
2020-03-31 03:40:03 -05:00
|
|
|
std::shared_ptr<Opm::Python> python;
|
2017-10-29 15:06:19 -05:00
|
|
|
std::unique_ptr<const Opm::Schedule> schedule;
|
2019-09-19 17:49:40 -05:00
|
|
|
std::unique_ptr<Opm::SummaryState> summaryState;
|
2024-02-20 07:37:48 -06:00
|
|
|
std::vector<std::vector<Opm::PerforationData<double>>> well_perf_data;
|
2017-08-22 10:14:52 -05:00
|
|
|
int current_timestep;
|
|
|
|
};
|
|
|
|
|
2018-06-21 05:14:17 -05:00
|
|
|
struct GlobalFixture {
|
|
|
|
GlobalFixture()
|
|
|
|
{
|
|
|
|
int argcDummy = 1;
|
|
|
|
const char *tmp[] = {"test_wellmodel"};
|
|
|
|
char **argvDummy = const_cast<char**>(tmp);
|
|
|
|
|
|
|
|
// MPI setup.
|
|
|
|
#if HAVE_DUNE_FEM
|
|
|
|
Dune::Fem::MPIManager::initialize(argcDummy, argvDummy);
|
|
|
|
#else
|
|
|
|
Dune::MPIHelper::instance(argcDummy, argvDummy);
|
|
|
|
#endif
|
|
|
|
|
2024-02-06 07:47:31 -06:00
|
|
|
Opm::FlowMain<Opm::Properties::TTag::FlowProblem>::setupParameters_(argcDummy, argvDummy, Dune::MPIHelper::getCommunication());
|
2018-06-21 05:14:17 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
BOOST_GLOBAL_FIXTURE(GlobalFixture);
|
2017-08-22 10:14:52 -05:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(TestStandardWellInput) {
|
2017-11-30 09:31:48 -06:00
|
|
|
const SetupTest setup_test;
|
2019-11-13 16:16:11 -06:00
|
|
|
const auto& wells_ecl = setup_test.schedule->getWells(setup_test.current_timestep);
|
2017-08-22 10:14:52 -05:00
|
|
|
BOOST_CHECK_EQUAL( wells_ecl.size(), 2);
|
2019-11-13 16:16:11 -06:00
|
|
|
const Opm::Well& well = wells_ecl[1];
|
2024-08-14 07:46:53 -05:00
|
|
|
const Opm::BlackoilModelParameters<double> param;
|
2017-11-22 07:39:42 -06:00
|
|
|
|
|
|
|
// For the conversion between the surface volume rate and resrevoir voidage rate
|
2018-07-27 05:54:02 -05:00
|
|
|
typedef Opm::BlackOilFluidSystem<double> FluidSystem;
|
2017-11-22 07:39:42 -06:00
|
|
|
using RateConverterType = Opm::RateConverter::
|
|
|
|
SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
|
|
|
|
// Compute reservoir volumes for RESV controls.
|
|
|
|
Opm::PhaseUsage phaseUsage;
|
|
|
|
std::unique_ptr<RateConverterType> rateConverter;
|
|
|
|
// Compute reservoir volumes for RESV controls.
|
|
|
|
rateConverter.reset(new RateConverterType (phaseUsage,
|
|
|
|
std::vector<int>(10, 0)));
|
|
|
|
|
2024-02-20 07:37:48 -06:00
|
|
|
Opm::PerforationData<double> dummy;
|
|
|
|
std::vector<Opm::PerforationData<double>> pdata(well.getConnections().size(), dummy);
|
2021-04-28 10:19:28 -05:00
|
|
|
for (auto c = 0*pdata.size(); c < pdata.size(); ++c) {
|
|
|
|
pdata[c].ecl_index = c;
|
|
|
|
}
|
|
|
|
|
2024-02-20 08:35:13 -06:00
|
|
|
Opm::ParallelWellInfo<double> pinfo{well.name()};
|
2017-11-30 09:31:48 -06:00
|
|
|
|
2021-06-06 01:58:41 -05:00
|
|
|
BOOST_CHECK_THROW( StandardWell( well, pinfo, -1, param, *rateConverter, 0, 3, 3, 0, pdata), std::invalid_argument);
|
2017-08-22 10:14:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(TestBehavoir) {
|
2017-11-30 09:31:48 -06:00
|
|
|
const SetupTest setup_test;
|
2019-11-13 16:16:11 -06:00
|
|
|
const auto& wells_ecl = setup_test.schedule->getWells(setup_test.current_timestep);
|
2017-08-22 10:14:52 -05:00
|
|
|
const int current_timestep = setup_test.current_timestep;
|
|
|
|
std::vector<std::unique_ptr<const StandardWell> > wells;
|
|
|
|
|
|
|
|
{
|
2019-10-23 02:09:45 -05:00
|
|
|
const int nw = wells_ecl.size();
|
2024-08-14 07:46:53 -05:00
|
|
|
const Opm::BlackoilModelParameters<double> param;
|
2017-08-22 10:14:52 -05:00
|
|
|
|
|
|
|
for (int w = 0; w < nw; ++w) {
|
2017-11-22 07:39:42 -06:00
|
|
|
// For the conversion between the surface volume rate and resrevoir voidage rate
|
2024-08-14 07:46:53 -05:00
|
|
|
using FluidSystem = Opm::BlackOilFluidSystem<double>;
|
2017-11-22 07:39:42 -06:00
|
|
|
using RateConverterType = Opm::RateConverter::
|
|
|
|
SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
|
|
|
|
// Compute reservoir volumes for RESV controls.
|
2017-11-30 09:31:48 -06:00
|
|
|
// TODO: not sure why for this class the initlizer list does not work
|
|
|
|
// otherwise we should make a meaningful const PhaseUsage here.
|
2017-11-22 07:39:42 -06:00
|
|
|
Opm::PhaseUsage phaseUsage;
|
|
|
|
std::unique_ptr<RateConverterType> rateConverter;
|
|
|
|
// Compute reservoir volumes for RESV controls.
|
|
|
|
rateConverter.reset(new RateConverterType (phaseUsage,
|
|
|
|
std::vector<int>(10, 0)));
|
2024-02-20 07:37:48 -06:00
|
|
|
Opm::PerforationData<double> dummy;
|
|
|
|
std::vector<Opm::PerforationData<double>> pdata(wells_ecl[w].getConnections().size(), dummy);
|
2021-04-28 10:19:28 -05:00
|
|
|
for (auto c = 0*pdata.size(); c < pdata.size(); ++c) {
|
|
|
|
pdata[c].ecl_index = c;
|
|
|
|
}
|
|
|
|
|
2024-02-20 08:35:13 -06:00
|
|
|
Opm::ParallelWellInfo<double> pinfo{wells_ecl[w].name()};
|
2021-06-06 01:58:41 -05:00
|
|
|
wells.emplace_back(new StandardWell(wells_ecl[w], pinfo, current_timestep, param, *rateConverter, 0, 3, 3, w, pdata) );
|
2017-08-22 10:14:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// first well, it is a production well from the deck
|
|
|
|
{
|
|
|
|
const auto& well = wells[0];
|
|
|
|
BOOST_CHECK_EQUAL(well->name(), "PROD1");
|
2019-10-23 02:09:45 -05:00
|
|
|
BOOST_CHECK(well->isProducer());
|
2021-09-06 05:47:21 -05:00
|
|
|
BOOST_CHECK(StandardWell::Indices::numEq == 3);
|
2019-03-25 06:52:34 -05:00
|
|
|
BOOST_CHECK(well->numStaticWellEq== 4);
|
2017-08-22 10:14:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// second well, it is the injection well from the deck
|
|
|
|
{
|
|
|
|
const auto& well = wells[1];
|
|
|
|
BOOST_CHECK_EQUAL(well->name(), "INJE1");
|
2019-10-23 02:09:45 -05:00
|
|
|
BOOST_CHECK(well->isInjector());
|
2021-09-06 05:47:21 -05:00
|
|
|
BOOST_CHECK(StandardWell::Indices::numEq == 3);
|
2019-08-07 07:13:11 -05:00
|
|
|
BOOST_CHECK(well->numStaticWellEq== 4);
|
2017-08-22 10:14:52 -05:00
|
|
|
}
|
|
|
|
}
|