2018-10-08 17:22:18 -05:00
|
|
|
/*
|
|
|
|
Copyright 2018 Equinor 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/>.
|
|
|
|
*/
|
|
|
|
|
2021-10-15 07:14:20 -05:00
|
|
|
#include <algorithm>
|
2018-10-08 17:22:18 -05:00
|
|
|
#include <config.h>
|
2021-09-27 05:00:39 -05:00
|
|
|
#include <functional>
|
2021-10-15 07:14:20 -05:00
|
|
|
#include <vector>
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
#define BOOST_TEST_MODULE WellStateFIBOTest
|
|
|
|
|
2020-11-30 09:52:12 -06:00
|
|
|
#include "MpiFixture.hpp"
|
2021-05-12 16:20:40 -05:00
|
|
|
#include <opm/common/ErrorMacros.hpp>
|
2021-04-28 03:22:29 -05:00
|
|
|
#include <opm/simulators/wells/GlobalWellInfo.hpp>
|
2021-05-12 16:20:40 -05:00
|
|
|
#include <opm/simulators/wells/ParallelWellInfo.hpp>
|
2021-05-20 06:32:18 -05:00
|
|
|
#include <opm/simulators/wells/WellState.hpp>
|
2021-08-03 13:05:14 -05:00
|
|
|
#include <opm/simulators/wells/SingleWellState.hpp>
|
2021-05-30 11:35:32 -05:00
|
|
|
#include <opm/simulators/wells/SegmentState.hpp>
|
2021-05-05 03:27:51 -05:00
|
|
|
#include <opm/simulators/wells/WellContainer.hpp>
|
2021-06-04 06:53:13 -05:00
|
|
|
#include <opm/simulators/wells/PerfData.hpp>
|
2021-12-14 01:30:15 -06:00
|
|
|
#include <opm/input/eclipse/Python/Python.hpp>
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
2021-12-14 01:30:15 -06:00
|
|
|
#include <opm/input/eclipse/Deck/Deck.hpp>
|
|
|
|
#include <opm/input/eclipse/Parser/Parser.hpp>
|
|
|
|
#include <opm/input/eclipse/Parser/ParseContext.hpp>
|
|
|
|
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
|
|
|
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
|
|
|
|
#include <opm/input/eclipse/Units/Units.hpp>
|
2021-02-25 13:46:51 -06:00
|
|
|
#include <opm/common/utility/TimeService.hpp>
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2019-11-25 03:34:50 -06:00
|
|
|
#include <opm/grid/GridHelpers.hpp>
|
|
|
|
|
2018-10-08 17:22:18 -05:00
|
|
|
#include <opm/core/props/BlackoilPhases.hpp>
|
|
|
|
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
|
|
|
|
|
|
|
#include <opm/grid/GridManager.hpp>
|
|
|
|
|
2019-09-19 17:49:40 -05:00
|
|
|
#include <chrono>
|
2018-10-08 17:22:18 -05:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
|
2020-11-30 09:52:12 -06:00
|
|
|
BOOST_GLOBAL_FIXTURE(MPIFixture);
|
|
|
|
|
2018-10-08 17:22:18 -05:00
|
|
|
struct Setup
|
|
|
|
{
|
|
|
|
Setup(const std::string& filename)
|
|
|
|
: Setup(Opm::Parser{}.parseFile(filename))
|
|
|
|
{}
|
|
|
|
|
|
|
|
Setup(const Opm::Deck& deck)
|
|
|
|
: es (deck)
|
|
|
|
, pu (Opm::phaseUsageFromDeck(es))
|
|
|
|
, grid (es.getInputGrid())
|
2020-03-31 03:40:03 -05:00
|
|
|
, python( std::make_shared<Opm::Python>() )
|
2020-03-25 14:21:28 -05:00
|
|
|
, sched(deck, es, python)
|
2021-02-25 13:46:51 -06:00
|
|
|
, st(Opm::TimeService::from_time_t(sched.getStartTime()))
|
2019-10-23 02:09:45 -05:00
|
|
|
{
|
|
|
|
initWellPerfData();
|
|
|
|
}
|
|
|
|
|
|
|
|
void initWellPerfData()
|
|
|
|
{
|
|
|
|
const auto& wells = sched.getWells(0);
|
|
|
|
const auto& cartDims = Opm::UgGridHelpers::cartDims(*grid.c_grid());
|
|
|
|
const int* compressed_to_cartesian = Opm::UgGridHelpers::globalCell(*grid.c_grid());
|
|
|
|
std::vector<int> cartesian_to_compressed(cartDims[0] * cartDims[1] * cartDims[2], -1);
|
|
|
|
for (int ii = 0; ii < Opm::UgGridHelpers::numCells(*grid.c_grid()); ++ii) {
|
|
|
|
cartesian_to_compressed[compressed_to_cartesian[ii]] = ii;
|
|
|
|
}
|
|
|
|
well_perf_data.resize(wells.size());
|
|
|
|
int well_index = 0;
|
|
|
|
for (const auto& well : wells) {
|
|
|
|
well_perf_data[well_index].clear();
|
|
|
|
well_perf_data[well_index].reserve(well.getConnections().size());
|
|
|
|
for (const auto& completion : well.getConnections()) {
|
|
|
|
if (completion.state() == Opm::Connection::State::OPEN) {
|
|
|
|
const int i = completion.getI();
|
|
|
|
const int j = completion.getJ();
|
|
|
|
const int k = completion.getK();
|
|
|
|
const int cart_grid_indx = i + cartDims[0] * (j + cartDims[1] * k);
|
|
|
|
const int active_index = cartesian_to_compressed[cart_grid_indx];
|
|
|
|
if (active_index < 0) {
|
|
|
|
const std::string msg
|
|
|
|
= ("Cell with i,j,k indices " + std::to_string(i) + " " + std::to_string(j) + " "
|
|
|
|
+ std::to_string(k) + " not found in grid (well = " + well.name() + ").");
|
|
|
|
OPM_THROW(std::runtime_error, msg);
|
|
|
|
} else {
|
|
|
|
Opm::PerforationData pd;
|
|
|
|
pd.cell_index = active_index;
|
2020-03-31 09:43:21 -05:00
|
|
|
pd.connection_transmissibility_factor = completion.CF();
|
2019-10-23 02:09:45 -05:00
|
|
|
pd.satnum_id = completion.satTableId();
|
|
|
|
well_perf_data[well_index].push_back(pd);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (completion.state() != Opm::Connection::State::SHUT) {
|
|
|
|
OPM_THROW(std::runtime_error,
|
|
|
|
"Completion state: " << Opm::Connection::State2String(completion.state()) << " not handled");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++well_index;
|
|
|
|
}
|
|
|
|
}
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
Opm::EclipseState es;
|
|
|
|
Opm::PhaseUsage pu;
|
|
|
|
Opm::GridManager grid;
|
2020-03-31 03:40:03 -05:00
|
|
|
std::shared_ptr<Opm::Python> python;
|
2018-10-08 17:22:18 -05:00
|
|
|
Opm::Schedule sched;
|
2019-05-29 00:44:23 -05:00
|
|
|
Opm::SummaryState st;
|
2019-10-23 02:09:45 -05:00
|
|
|
std::vector<std::vector<Opm::PerforationData>> well_perf_data;
|
2018-10-08 17:22:18 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace {
|
2021-05-20 06:32:18 -05:00
|
|
|
Opm::WellState
|
2020-11-30 09:52:12 -06:00
|
|
|
buildWellState(const Setup& setup, const std::size_t timeStep,
|
|
|
|
std::vector<Opm::ParallelWellInfo>& pinfos)
|
2018-10-08 17:22:18 -05:00
|
|
|
{
|
2021-05-20 06:32:18 -05:00
|
|
|
auto state = Opm::WellState{setup.pu};
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
const auto cpress =
|
|
|
|
std::vector<double>(setup.grid.c_grid()->number_of_cells,
|
|
|
|
100.0*Opm::unit::barsa);
|
|
|
|
|
2020-11-27 11:22:23 -06:00
|
|
|
auto wells = setup.sched.getWells(timeStep);
|
2020-11-30 09:52:12 -06:00
|
|
|
pinfos.resize(wells.size());
|
2021-09-27 05:00:39 -05:00
|
|
|
std::vector<std::reference_wrapper<Opm::ParallelWellInfo>> ppinfos;
|
2020-11-27 11:22:23 -06:00
|
|
|
auto pw = pinfos.begin();
|
|
|
|
|
|
|
|
for (const auto& well : wells)
|
|
|
|
{
|
|
|
|
*pw = {well.name()};
|
2021-09-27 05:00:39 -05:00
|
|
|
ppinfos.push_back(std::ref(*pw));
|
2020-11-30 09:52:12 -06:00
|
|
|
pw->communicateFirstPerforation(true);
|
2020-11-27 11:22:23 -06:00
|
|
|
++pw;
|
|
|
|
}
|
|
|
|
|
2019-10-23 02:09:45 -05:00
|
|
|
state.init(cpress, setup.sched,
|
2020-11-27 11:22:23 -06:00
|
|
|
wells, ppinfos,
|
2021-04-28 03:22:29 -05:00
|
|
|
timeStep, nullptr, setup.well_perf_data, setup.st);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2019-10-23 02:09:45 -05:00
|
|
|
state.initWellStateMSWell(setup.sched.getWells(timeStep),
|
2021-04-25 13:47:31 -05:00
|
|
|
nullptr);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2018-10-15 12:47:31 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
void setSegPress(const std::vector<Opm::Well>& wells,
|
2021-05-20 06:32:18 -05:00
|
|
|
Opm::WellState& wstate)
|
2018-10-08 17:22:18 -05:00
|
|
|
{
|
|
|
|
const auto nWell = wells.size();
|
|
|
|
|
|
|
|
|
|
|
|
for (auto wellID = 0*nWell; wellID < nWell; ++wellID) {
|
2019-05-02 05:51:25 -05:00
|
|
|
const auto& well = wells[wellID];
|
|
|
|
if (! well.isMultiSegment()) {
|
2018-10-08 17:22:18 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-05-31 09:01:56 -05:00
|
|
|
const auto pressTop = 100.0 * wellID;
|
2021-08-05 05:55:18 -05:00
|
|
|
auto& ws = wstate.well(wellID);
|
|
|
|
auto& segments = ws.segments;
|
2021-06-01 03:24:18 -05:00
|
|
|
segments.pressure[0] = pressTop;
|
2021-05-31 09:01:56 -05:00
|
|
|
|
2019-05-02 05:51:25 -05:00
|
|
|
const auto& segSet = well.getSegments();
|
2018-10-15 12:52:54 -05:00
|
|
|
const auto nSeg = segSet.size();
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
for (auto segID = 0*nSeg + 1; segID < nSeg; ++segID) {
|
2018-10-15 12:52:54 -05:00
|
|
|
// One-based numbering scheme for segments.
|
|
|
|
const auto segNo = segSet[segID].segmentNumber();
|
2021-06-01 03:24:18 -05:00
|
|
|
segments.pressure[segNo - 1] = pressTop + 1.0*(segNo - 1);
|
2018-10-08 17:22:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 12:47:31 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
void setSegRates(const std::vector<Opm::Well>& wells,
|
2018-10-08 17:22:18 -05:00
|
|
|
const Opm::PhaseUsage& pu,
|
2021-05-20 06:32:18 -05:00
|
|
|
Opm::WellState& wstate)
|
2018-10-08 17:22:18 -05:00
|
|
|
{
|
|
|
|
const auto wat = pu.phase_used[Opm::BlackoilPhases::Aqua];
|
|
|
|
const auto iw = wat ? pu.phase_pos[Opm::BlackoilPhases::Aqua] : -1;
|
|
|
|
|
|
|
|
const auto oil = pu.phase_used[Opm::BlackoilPhases::Liquid];
|
|
|
|
const auto io = oil ? pu.phase_pos[Opm::BlackoilPhases::Liquid] : -1;
|
|
|
|
|
|
|
|
const auto gas = pu.phase_used[Opm::BlackoilPhases::Vapour];
|
|
|
|
const auto ig = gas ? pu.phase_pos[Opm::BlackoilPhases::Vapour] : -1;
|
|
|
|
|
|
|
|
const auto np = wstate.numPhases();
|
|
|
|
|
|
|
|
const auto nWell = wells.size();
|
|
|
|
|
|
|
|
|
|
|
|
for (auto wellID = 0*nWell; wellID < nWell; ++wellID) {
|
2019-05-02 05:51:25 -05:00
|
|
|
const auto& well = wells[wellID];
|
2021-05-31 09:01:56 -05:00
|
|
|
if (! well.isMultiSegment()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-10-15 12:52:54 -05:00
|
|
|
const auto rateTop = 1000.0 * wellID;
|
2021-08-05 05:55:18 -05:00
|
|
|
auto& ws = wstate.well(wellID);
|
|
|
|
auto& segments = ws.segments;
|
2021-06-01 04:34:11 -05:00
|
|
|
auto& segRates = segments.rates;
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2021-05-26 10:38:09 -05:00
|
|
|
if (wat) { segRates[iw] = rateTop; }
|
|
|
|
if (oil) { segRates[io] = rateTop; }
|
|
|
|
if (gas) { segRates[ig] = rateTop; }
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2019-05-02 05:51:25 -05:00
|
|
|
const auto& segSet = well.getSegments();
|
2018-10-15 12:52:54 -05:00
|
|
|
const auto nSeg = segSet.size();
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
for (auto segID = 0*nSeg + 1; segID < nSeg; ++segID) {
|
2018-10-15 12:52:54 -05:00
|
|
|
// One-based numbering scheme for segments.
|
|
|
|
const auto segNo = segSet[segID].segmentNumber();
|
|
|
|
|
2021-05-26 10:38:09 -05:00
|
|
|
auto* rates = &segRates[(segNo - 1) * np];
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2018-10-15 12:52:54 -05:00
|
|
|
if (wat) { rates[iw] = rateTop + 100.0*(segNo - 1); }
|
|
|
|
if (oil) { rates[io] = rateTop + 200.0*(segNo - 1); }
|
|
|
|
if (gas) { rates[ig] = rateTop + 400.0*(segNo - 1); }
|
2018-10-08 17:22:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // Anonymous
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(Segment)
|
|
|
|
|
2018-10-15 12:47:31 -05:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
2018-10-08 17:22:18 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(Linearisation)
|
|
|
|
{
|
|
|
|
const Setup setup{ "msw.data" };
|
|
|
|
const auto tstep = std::size_t{0};
|
|
|
|
|
2020-11-30 09:52:12 -06:00
|
|
|
std::vector<Opm::ParallelWellInfo> pinfos;
|
|
|
|
const auto wstate = buildWellState(setup, tstep, pinfos);
|
2021-08-05 05:55:18 -05:00
|
|
|
const auto& ws = wstate.well("PROD01");
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2021-08-05 05:55:18 -05:00
|
|
|
BOOST_CHECK_EQUAL(ws.segments.size(), 6);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
const auto& wells = setup.sched.getWellsatEnd();
|
2018-10-08 17:22:18 -05:00
|
|
|
BOOST_CHECK_EQUAL(wells.size(), 2);
|
|
|
|
}
|
|
|
|
|
2018-10-15 12:47:31 -05:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
2018-10-08 17:22:18 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(Pressure)
|
|
|
|
{
|
|
|
|
const Setup setup{ "msw.data" };
|
|
|
|
const auto tstep = std::size_t{0};
|
|
|
|
|
2020-11-30 09:52:12 -06:00
|
|
|
std::vector<Opm::ParallelWellInfo> pinfos;
|
|
|
|
auto wstate = buildWellState(setup, tstep, pinfos);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
const auto& wells = setup.sched.getWells(tstep);
|
2019-05-02 05:51:25 -05:00
|
|
|
const auto prod01_first = wells[0].name() == "PROD01";
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2019-06-26 05:53:30 -05:00
|
|
|
setSegPress(wells, wstate);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2021-04-25 13:47:31 -05:00
|
|
|
const auto rpt = wstate.report(setup.grid.c_grid()->global_cell, [](const int){return false;});
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
const auto expect_nSeg = 6;
|
|
|
|
const auto& xw = rpt.at("PROD01");
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(xw.segments.size(), expect_nSeg);
|
|
|
|
|
|
|
|
const auto pressTop = prod01_first ? 0.0 : 100.0;
|
|
|
|
|
|
|
|
for (auto segID = 0; segID < expect_nSeg; ++segID) {
|
|
|
|
const auto& xseg = xw.segments.at(segID + 1);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(xseg.segNumber, segID + 1);
|
2020-04-16 17:36:13 -05:00
|
|
|
const auto pres_idx = Opm::data::SegmentPressures::Value::Pressure;
|
|
|
|
BOOST_CHECK_CLOSE(xseg.pressures[pres_idx], pressTop + 1.0*segID, 1.0e-10);
|
2018-10-08 17:22:18 -05:00
|
|
|
}
|
|
|
|
}
|
2021-06-04 07:12:54 -05:00
|
|
|
|
2021-08-06 06:14:00 -05:00
|
|
|
const auto& ws = wstate.well("PROD01");
|
|
|
|
const auto& perf_data = ws.perf_data;
|
2021-06-05 01:21:48 -05:00
|
|
|
(void) perf_data;
|
2018-10-08 17:22:18 -05:00
|
|
|
}
|
|
|
|
|
2018-10-15 12:47:31 -05:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
2018-10-08 17:22:18 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(Rates)
|
|
|
|
{
|
|
|
|
const Setup setup{ "msw.data" };
|
|
|
|
const auto tstep = std::size_t{0};
|
|
|
|
|
2020-11-30 09:52:12 -06:00
|
|
|
std::vector<Opm::ParallelWellInfo> pinfos;
|
|
|
|
auto wstate = buildWellState(setup, tstep, pinfos);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
const auto wells = setup.sched.getWells(tstep);
|
2019-05-02 05:51:25 -05:00
|
|
|
const auto prod01_first = wells[0].name() == "PROD01";
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
const auto& pu = setup.pu;
|
|
|
|
|
2021-04-25 13:47:31 -05:00
|
|
|
setSegRates(wells, pu, wstate);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2021-04-25 13:47:31 -05:00
|
|
|
const auto rpt = wstate.report(setup.grid.c_grid()->global_cell, [](const int){return false;});
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
const auto wat = pu.phase_used[Opm::BlackoilPhases::Aqua];
|
|
|
|
const auto oil = pu.phase_used[Opm::BlackoilPhases::Liquid];
|
|
|
|
const auto gas = pu.phase_used[Opm::BlackoilPhases::Vapour];
|
|
|
|
|
|
|
|
BOOST_CHECK(wat && oil && gas);
|
|
|
|
|
|
|
|
{
|
|
|
|
const auto expect_nSeg = 6;
|
|
|
|
const auto& xw = rpt.at("PROD01");
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(xw.segments.size(), expect_nSeg);
|
|
|
|
|
|
|
|
const auto rateTop = prod01_first ? 0.0 : 1000.0;
|
|
|
|
|
2018-10-15 12:52:54 -05:00
|
|
|
for (auto segNum = 1; segNum <= expect_nSeg; ++segNum) {
|
|
|
|
const auto& xseg = xw.segments.at(segNum);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
2018-10-15 12:52:54 -05:00
|
|
|
BOOST_CHECK_EQUAL(xseg.segNumber, segNum);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
BOOST_CHECK_CLOSE(xseg.rates.get(Opm::data::Rates::opt::wat),
|
2018-10-15 12:52:54 -05:00
|
|
|
rateTop + 100.0*(segNum - 1), 1.0e-10);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
BOOST_CHECK_CLOSE(xseg.rates.get(Opm::data::Rates::opt::oil),
|
2018-10-15 12:52:54 -05:00
|
|
|
rateTop + 200.0*(segNum - 1), 1.0e-10);
|
2018-10-08 17:22:18 -05:00
|
|
|
|
|
|
|
BOOST_CHECK_CLOSE(xseg.rates.get(Opm::data::Rates::opt::gas),
|
2018-10-15 12:52:54 -05:00
|
|
|
rateTop + 400.0*(segNum - 1), 1.0e-10);
|
2018-10-08 17:22:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-12 07:45:50 -06:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(STOP_well)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
This test verifies that the perforation pressures is correctly initialized
|
|
|
|
also for wells in the STOP state.
|
|
|
|
*/
|
|
|
|
const Setup setup{ "wells_manager_data_wellSTOP.data" };
|
2020-11-30 09:52:12 -06:00
|
|
|
|
|
|
|
std::vector<Opm::ParallelWellInfo> pinfos;
|
|
|
|
auto wstate = buildWellState(setup, 0, pinfos);
|
2021-05-20 09:16:12 -05:00
|
|
|
for (std::size_t well_index = 0; well_index < setup.sched.numWells(0); well_index++) {
|
2021-08-06 06:14:00 -05:00
|
|
|
const auto& ws = wstate.well(well_index);
|
|
|
|
const auto& perf_data = ws.perf_data;
|
2021-06-05 01:52:18 -05:00
|
|
|
for (const auto& p : perf_data.pressure)
|
2021-05-20 09:16:12 -05:00
|
|
|
BOOST_CHECK(p > 0);
|
|
|
|
}
|
2019-11-12 07:45:50 -06:00
|
|
|
}
|
|
|
|
|
2021-04-28 03:22:29 -05:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
2021-05-20 09:16:12 -05:00
|
|
|
//BOOST_AUTO_TEST_CASE(GlobalWellInfo_TEST) {
|
|
|
|
// const Setup setup{ "msw.data" };
|
|
|
|
// std::vector<Opm::Well> local_wells = { setup.sched.getWell("PROD01", 1) };
|
|
|
|
// Opm::GlobalWellInfo gwi(setup.sched, 1, local_wells);
|
|
|
|
// Opm::WellContainer<Opm::Well::Status> status({{"PROD01", Opm::Well::Status::OPEN}});
|
|
|
|
//
|
|
|
|
// BOOST_CHECK(!gwi.in_injecting_group("INJE01"));
|
|
|
|
// BOOST_CHECK(!gwi.in_injecting_group("PROD01"));
|
|
|
|
// BOOST_CHECK(!gwi.in_producing_group("INJE01"));
|
|
|
|
// BOOST_CHECK(!gwi.in_producing_group("PROD01"));
|
|
|
|
//
|
|
|
|
// BOOST_CHECK_EQUAL( gwi.well_name(0), "INJE01");
|
|
|
|
// BOOST_CHECK_EQUAL( gwi.well_name(1), "PROD01");
|
|
|
|
// BOOST_CHECK_EQUAL( gwi.well_index("PROD01"), 1);
|
|
|
|
//
|
|
|
|
// BOOST_CHECK_THROW( gwi.update_group( {}, {}, {} ), std::exception);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Opm::WellContainer<Opm::Well::InjectorCMode> inj_cmode({{"PROD01", Opm::Well::InjectorCMode::CMODE_UNDEFINED}});
|
|
|
|
// {
|
|
|
|
// Opm::WellContainer<Opm::Well::ProducerCMode> prod_cmode({{"PROD01", Opm::Well::ProducerCMode::GRUP}});
|
|
|
|
// gwi.update_group(status, inj_cmode, prod_cmode);
|
|
|
|
// }
|
|
|
|
// BOOST_CHECK(!gwi.in_producing_group("INJE01"));
|
|
|
|
// BOOST_CHECK(gwi.in_producing_group("PROD01"));
|
|
|
|
//
|
|
|
|
// {
|
|
|
|
// Opm::WellContainer<Opm::Well::ProducerCMode> prod_cmode(
|
|
|
|
// {{"PROD01", Opm::Well::ProducerCMode::CMODE_UNDEFINED}});
|
|
|
|
// gwi.update_group(status, inj_cmode, prod_cmode);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// {
|
|
|
|
// Opm::WellContainer<Opm::Well::ProducerCMode> prod_cmode({{"PROD01", Opm::Well::ProducerCMode::GRUP}});
|
|
|
|
// gwi.update_group(status, inj_cmode, prod_cmode);
|
|
|
|
// }
|
|
|
|
// BOOST_CHECK(!gwi.in_producing_group("INJE01"));
|
|
|
|
// BOOST_CHECK(gwi.in_producing_group("PROD01"));
|
|
|
|
//
|
|
|
|
// {
|
|
|
|
// Opm::WellContainer<Opm::Well::ProducerCMode> prod_cmode({{"PROD01", Opm::Well::ProducerCMode::NONE}});
|
|
|
|
// gwi.update_group(status, inj_cmode, prod_cmode);
|
|
|
|
// }
|
|
|
|
// BOOST_CHECK(!gwi.in_producing_group("INJE01"));
|
|
|
|
// BOOST_CHECK(!gwi.in_producing_group("PROD01"));
|
|
|
|
//}
|
2021-04-28 03:22:29 -05:00
|
|
|
|
2021-05-05 03:27:51 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(TESTWellContainer) {
|
|
|
|
Opm::WellContainer<int> wc;
|
|
|
|
BOOST_CHECK_EQUAL(wc.size(), 0);
|
2021-04-28 03:22:29 -05:00
|
|
|
|
2021-05-05 03:27:51 -05:00
|
|
|
wc.add("W1", 1);
|
|
|
|
wc.add("W2", 2);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(wc.size(), 2);
|
|
|
|
|
|
|
|
BOOST_CHECK_THROW(wc.add("W1", 1), std::exception);
|
|
|
|
|
|
|
|
BOOST_CHECK_THROW(wc[10], std::exception);
|
|
|
|
BOOST_CHECK_EQUAL(wc[0], 1);
|
|
|
|
BOOST_CHECK_EQUAL(wc[1], 2);
|
|
|
|
|
|
|
|
BOOST_CHECK_THROW(wc["INVALID_WELL"], std::exception);
|
|
|
|
BOOST_CHECK_EQUAL(wc["W1"], 1);
|
|
|
|
BOOST_CHECK_EQUAL(wc["W2"], 2);
|
2021-07-26 05:06:45 -05:00
|
|
|
BOOST_CHECK_EQUAL(wc.well_name(0), "W1");
|
|
|
|
BOOST_CHECK_EQUAL(wc.well_name(1), "W2");
|
|
|
|
BOOST_CHECK_THROW(wc.well_name(10), std::exception);
|
|
|
|
|
2021-10-15 07:14:20 -05:00
|
|
|
const auto& wells = wc.wells();
|
|
|
|
std::vector<std::string> expected = {"W1", "W2"};
|
|
|
|
BOOST_CHECK( std::is_permutation( wells.begin(), wells.end(), expected.begin(), expected.end()) );
|
2021-05-05 03:27:51 -05:00
|
|
|
|
|
|
|
Opm::WellContainer<int> wc2;
|
|
|
|
wc2.copy_welldata(wc);
|
|
|
|
BOOST_CHECK_EQUAL(wc2.size() , 0);
|
|
|
|
|
|
|
|
wc2.add("W1", 100);
|
|
|
|
BOOST_CHECK_EQUAL(wc2["W1"], 100);
|
|
|
|
wc2.copy_welldata(wc);
|
|
|
|
BOOST_CHECK_EQUAL(wc2["W1"], 1);
|
|
|
|
|
|
|
|
Opm::WellContainer<int> wc3;
|
|
|
|
wc3.add("W2", 100);
|
|
|
|
wc3.copy_welldata(wc);
|
|
|
|
BOOST_CHECK_EQUAL(wc3["W2"], 2);
|
|
|
|
BOOST_CHECK_EQUAL(wc3[0], 2);
|
|
|
|
|
|
|
|
wc3["W2"] = 200;
|
|
|
|
wc3.add("W3", 300);
|
|
|
|
wc3.copy_welldata(wc);
|
|
|
|
BOOST_CHECK_EQUAL(wc3["W2"], 2);
|
|
|
|
BOOST_CHECK_EQUAL(wc3[0], 2);
|
|
|
|
BOOST_CHECK_EQUAL(wc3["W3"], 300);
|
|
|
|
BOOST_CHECK_EQUAL(wc3[1], 300);
|
|
|
|
|
|
|
|
BOOST_CHECK_THROW(wc3.copy_welldata(wc, "W1"), std::exception);
|
|
|
|
BOOST_CHECK_THROW(wc3.copy_welldata(wc, "W3"), std::exception);
|
|
|
|
|
|
|
|
wc.clear();
|
|
|
|
BOOST_CHECK_EQUAL(wc.size(), 0);
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(wc3.has("W2"));
|
|
|
|
BOOST_CHECK(!wc3.has("NO_SUCH_WELL"));
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<int> vec_copy(wc3.begin(), wc3.end());
|
|
|
|
BOOST_CHECK_EQUAL(vec_copy.size(), wc3.size());
|
|
|
|
for (std::size_t i = 0; i < wc3.size(); i++)
|
|
|
|
BOOST_CHECK_EQUAL(vec_copy[i], wc3[i]);
|
2021-05-12 00:15:34 -05:00
|
|
|
|
|
|
|
|
|
|
|
Opm::WellContainer<int> wci({{"W1", 1}, {"W2", 2}, {"W3", 3}});
|
|
|
|
BOOST_CHECK_EQUAL(wci.size(), 3);
|
|
|
|
BOOST_CHECK(wci.has("W1"));
|
|
|
|
BOOST_CHECK_EQUAL(wci[1], 2);
|
|
|
|
BOOST_CHECK_EQUAL(wci["W3"], 3);
|
2021-05-21 13:48:31 -05:00
|
|
|
|
|
|
|
auto w3 = wci.well_index("W3");
|
|
|
|
BOOST_CHECK(w3.has_value());
|
|
|
|
BOOST_CHECK_EQUAL(w3.value(), 2);
|
|
|
|
|
|
|
|
auto wx = wci.well_index("WX");
|
|
|
|
BOOST_CHECK(!wx.has_value());
|
2021-05-05 03:27:51 -05:00
|
|
|
}
|
2021-04-28 03:22:29 -05:00
|
|
|
|
2021-05-30 11:35:32 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(TESTSegmentState) {
|
|
|
|
const Setup setup{ "msw.data" };
|
|
|
|
const auto& well = setup.sched.getWell("PROD01", 0);
|
|
|
|
const auto& segments = well.getSegments();
|
|
|
|
Opm::SegmentState ss1(3, segments);
|
|
|
|
Opm::SegmentState ss2;
|
|
|
|
|
|
|
|
|
|
|
|
ss1.pressure_drop_hydrostatic[0] = 1;
|
|
|
|
ss1.pressure_drop_friction[0] = 2;
|
|
|
|
ss1.pressure_drop_accel[0] = 3;
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(ss1.pressure_drop(0), 6);
|
|
|
|
}
|
|
|
|
|
2021-05-30 12:39:26 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(TESTSegmentState2) {
|
|
|
|
const Setup setup{ "msw.data" };
|
|
|
|
std::vector<Opm::ParallelWellInfo> pinfo;
|
|
|
|
const auto wstate = buildWellState(setup, 0, pinfo);
|
|
|
|
const auto& well = setup.sched.getWell("PROD01", 0);
|
2021-08-05 05:55:18 -05:00
|
|
|
const auto& ws = wstate.well("PROD01");
|
2021-05-30 12:39:26 -05:00
|
|
|
|
2021-08-05 05:55:18 -05:00
|
|
|
auto segments = ws.segments;
|
2021-05-30 12:39:26 -05:00
|
|
|
BOOST_CHECK_EQUAL(segments.pressure.size(), well.getSegments().size());
|
|
|
|
|
|
|
|
segments.pressure_drop_friction[0] = 1;
|
|
|
|
segments.pressure_drop_accel[0] = 2;
|
|
|
|
segments.pressure_drop_hydrostatic[0] = 4;
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(segments.pressure_drop(0), 7);
|
2021-06-01 04:21:56 -05:00
|
|
|
|
|
|
|
|
|
|
|
for (std::size_t i=0; i < segments.pressure.size(); i++)
|
|
|
|
segments.pressure[i] = (i + 1);
|
|
|
|
|
|
|
|
const double bhp = 2.0;
|
|
|
|
segments.scale_pressure(bhp);
|
|
|
|
|
|
|
|
for (std::size_t i=0; i < segments.pressure.size(); i++)
|
2022-03-10 15:19:12 -06:00
|
|
|
BOOST_CHECK_EQUAL(segments.pressure[i], 1.+(i+1));
|
2021-06-01 08:43:45 -05:00
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL( segments.size(), well.getSegments().size() );
|
2021-05-30 12:39:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-04 06:53:13 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(TESTPerfData) {
|
2021-10-31 09:59:41 -05:00
|
|
|
Opm::PerfData pd1(3, 100, true, 3);
|
|
|
|
Opm::PerfData pd2(3, 100, true, 3);
|
|
|
|
Opm::PerfData pd3(2, 100, true, 3);
|
|
|
|
Opm::PerfData pd4(3, 100, false, 3);
|
2021-06-05 01:52:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
for (std::size_t i = 0; i < 3; i++) {
|
|
|
|
pd1.pressure[i] = i+1;
|
|
|
|
pd2.pressure[i] = 10*(i+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_CHECK(pd1.try_assign(pd2));
|
|
|
|
for (std::size_t i = 0; i < 3; i++) {
|
|
|
|
BOOST_CHECK(pd2.pressure[i] == 10*(i+1));
|
|
|
|
BOOST_CHECK(pd1.pressure[i] == 10*(i+1));
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_CHECK(!pd1.try_assign(pd3));
|
|
|
|
for (std::size_t i = 0; i < 3; i++) {
|
|
|
|
BOOST_CHECK(pd1.pressure[i] == 10*(i+1));
|
|
|
|
}
|
2021-06-14 01:55:03 -05:00
|
|
|
|
|
|
|
BOOST_CHECK(!pd1.try_assign(pd4));
|
2021-06-04 06:53:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-03 13:05:14 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(TestSingleWellState) {
|
2021-09-27 03:00:37 -05:00
|
|
|
Opm::ParallelWellInfo pinfo;
|
2021-10-31 04:03:21 -05:00
|
|
|
std::vector<Opm::PerforationData> connections = {{0,1,1,0},{1,1,1,1},{2,1,1,2}};
|
2021-10-31 09:59:41 -05:00
|
|
|
Opm::PhaseUsage pu;
|
|
|
|
|
|
|
|
// This is totally bonkers, but the pu needs a complete deck to initialize properly
|
|
|
|
pu.num_phases = 3;
|
|
|
|
|
|
|
|
Opm::SingleWellState ws1("W1", pinfo, true, 100, connections, pu, 1);
|
|
|
|
Opm::SingleWellState ws2("W2", pinfo, true, 100, connections, pu, 2);
|
|
|
|
Opm::SingleWellState ws3("W3", pinfo, false, 100, connections, pu, 3);
|
2021-08-03 13:05:14 -05:00
|
|
|
|
|
|
|
ws1.bhp = 100;
|
|
|
|
ws1.thp = 200;
|
|
|
|
|
|
|
|
ws2.init_timestep(ws1);
|
|
|
|
BOOST_CHECK_EQUAL(ws2.bhp, ws1.bhp);
|
|
|
|
BOOST_CHECK_EQUAL(ws2.thp, ws1.thp);
|
2021-08-03 14:11:09 -05:00
|
|
|
|
|
|
|
ws3.bhp = ws1.bhp * 2;
|
|
|
|
ws3.thp = ws1.thp * 2;
|
|
|
|
ws3.init_timestep(ws1);
|
|
|
|
BOOST_CHECK(ws3.bhp != ws1.bhp);
|
|
|
|
BOOST_CHECK(ws3.thp != ws1.thp);
|
2021-08-03 13:05:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-31 13:29:02 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(TestPU) {
|
|
|
|
Opm::PhaseUsage pu({Opm::BlackoilPhases::Polymer, Opm::BlackoilPhases::Solvent, Opm::BlackoilPhases::Aqua, Opm::BlackoilPhases::ZFraction});
|
|
|
|
|
|
|
|
BOOST_CHECK(pu.phase_used[Opm::BlackoilPhases::Aqua]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Aqua], 0);
|
|
|
|
BOOST_CHECK(pu.phase_used[Opm::BlackoilPhases::Solvent]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Solvent], 1);
|
|
|
|
BOOST_CHECK(pu.phase_used[Opm::BlackoilPhases::Polymer]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Polymer], 2);
|
|
|
|
BOOST_CHECK(pu.phase_used[Opm::BlackoilPhases::ZFraction]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::ZFraction], 3);
|
|
|
|
|
|
|
|
BOOST_CHECK(!pu.phase_used[Opm::BlackoilPhases::Liquid]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Liquid], -1);
|
|
|
|
BOOST_CHECK(!pu.phase_used[Opm::BlackoilPhases::Energy]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Energy], -1);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(pu.num_phases, 1); // Only Aqua counts as a phase.
|
|
|
|
BOOST_CHECK(pu.has_polymer);
|
|
|
|
BOOST_CHECK(pu.has_solvent);
|
|
|
|
BOOST_CHECK(pu.has_zFraction);
|
|
|
|
|
|
|
|
BOOST_CHECK(!pu.has_energy);
|
|
|
|
BOOST_CHECK(!pu.has_polymermw);
|
|
|
|
BOOST_CHECK(!pu.has_foam);
|
|
|
|
BOOST_CHECK(!pu.has_brine);
|
|
|
|
}
|
2021-08-03 13:05:14 -05:00
|
|
|
|
2021-04-28 03:22:29 -05:00
|
|
|
|
2018-10-08 17:22:18 -05:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|