2018-10-09 10:42:37 -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/>.
|
|
|
|
*/
|
|
|
|
|
2019-10-11 01:16:22 -05:00
|
|
|
#define BOOST_TEST_MODULE MSIM_BASIC
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
|
|
|
#include <opm/msim/msim.hpp>
|
|
|
|
|
2018-10-09 10:42:37 -05:00
|
|
|
#include <stdexcept>
|
|
|
|
#include <iostream>
|
|
|
|
|
2020-02-12 02:12:29 -06:00
|
|
|
#include <opm/common/utility/FileSystem.hpp>
|
2018-11-15 07:31:41 -06:00
|
|
|
|
2020-03-26 09:31:21 -05:00
|
|
|
#include <opm/parser/eclipse/Python/Python.hpp>
|
2019-10-11 01:16:22 -05:00
|
|
|
#include <opm/io/eclipse/ERst.hpp>
|
|
|
|
#include <opm/io/eclipse/ESmry.hpp>
|
2018-10-09 10:42:37 -05:00
|
|
|
|
2018-11-15 07:31:41 -06:00
|
|
|
#include <opm/output/data/Wells.hpp>
|
2019-01-22 02:21:24 -06:00
|
|
|
#include <opm/output/eclipse/EclipseIO.hpp>
|
2018-11-15 07:31:41 -06:00
|
|
|
#include <opm/parser/eclipse/Units/Units.hpp>
|
2019-01-22 02:21:24 -06:00
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
2018-10-09 10:42:37 -05:00
|
|
|
|
2019-10-11 01:16:22 -05:00
|
|
|
#include <tests/WorkArea.cpp>
|
|
|
|
|
2018-10-09 10:42:37 -05:00
|
|
|
using namespace Opm;
|
|
|
|
|
2019-10-11 01:16:22 -05:00
|
|
|
namespace {
|
2018-10-09 10:42:37 -05:00
|
|
|
|
2019-06-13 07:38:26 -05:00
|
|
|
double prod_opr(const EclipseState& es, const Schedule& /* sched */, const SummaryState&, const data::Solution& /* sol */, size_t /* report_step */, double seconds_elapsed) {
|
2018-11-15 07:31:41 -06:00
|
|
|
const auto& units = es.getUnits();
|
|
|
|
return -units.to_si(UnitSystem::measure::rate, seconds_elapsed);
|
|
|
|
}
|
|
|
|
|
2019-04-12 06:26:33 -05:00
|
|
|
void pressure(const EclipseState& es, const Schedule& /* sched */, data::Solution& sol, size_t /* report_step */, double seconds_elapsed) {
|
2018-11-15 07:31:41 -06:00
|
|
|
const auto& grid = es.getInputGrid();
|
|
|
|
const auto& units = es.getUnits();
|
|
|
|
if (!sol.has("PRESSURE"))
|
|
|
|
sol.insert("PRESSURE", UnitSystem::measure::pressure, std::vector<double>(grid.getNumActive()), data::TargetType::RESTART_SOLUTION);
|
|
|
|
|
|
|
|
auto& data = sol.data("PRESSURE");
|
|
|
|
std::fill(data.begin(), data.end(), units.to_si(UnitSystem::measure::pressure, seconds_elapsed));
|
|
|
|
}
|
|
|
|
|
2020-02-12 02:12:29 -06:00
|
|
|
bool is_file(const Opm::filesystem::path& name)
|
2019-10-11 01:16:22 -05:00
|
|
|
{
|
2020-02-12 02:12:29 -06:00
|
|
|
return Opm::filesystem::exists(name)
|
|
|
|
&& Opm::filesystem::is_regular_file(name);
|
2019-10-11 01:16:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-11-15 07:31:41 -06:00
|
|
|
|
2018-10-09 10:42:37 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(RUN) {
|
2019-01-22 02:21:24 -06:00
|
|
|
Parser parser;
|
2020-03-31 03:26:55 -05:00
|
|
|
auto python = std::make_shared<Python>();
|
2019-01-22 02:21:24 -06:00
|
|
|
Deck deck = parser.parseFile("SPE1CASE1.DATA");
|
|
|
|
EclipseState state(deck);
|
2020-03-26 09:31:21 -05:00
|
|
|
Schedule schedule(deck, state, python);
|
2019-01-22 02:21:24 -06:00
|
|
|
SummaryConfig summary_config(deck, schedule, state.getTableManager());
|
|
|
|
msim msim(state);
|
|
|
|
|
2018-11-15 07:31:41 -06:00
|
|
|
msim.well_rate("PROD", data::Rates::opt::oil, prod_opr);
|
2020-03-30 06:39:42 -05:00
|
|
|
msim.well_rate("RFT", data::Rates::opt::oil, prod_opr);
|
2018-11-15 07:31:41 -06:00
|
|
|
msim.solution("PRESSURE", pressure);
|
2018-10-09 10:42:37 -05:00
|
|
|
{
|
2019-10-11 01:16:22 -05:00
|
|
|
const WorkArea work_area("test_msim");
|
2019-01-22 02:21:24 -06:00
|
|
|
EclipseIO io(state, state.getInputGrid(), schedule, summary_config);
|
|
|
|
|
2019-06-13 07:38:26 -05:00
|
|
|
msim.run(schedule, io, false);
|
2018-10-09 10:42:37 -05:00
|
|
|
|
2020-04-01 03:30:10 -05:00
|
|
|
for (const auto& fname : {"SPE1CASE1.INIT", "SPE1CASE1.UNRST", "SPE1CASE1.EGRID", "SPE1CASE1.SMSPEC", "SPE1CASE1.UNSMRY", "SPE1CASE1.RSM"})
|
2019-10-11 01:16:22 -05:00
|
|
|
BOOST_CHECK( is_file( fname ));
|
2018-10-09 10:42:37 -05:00
|
|
|
|
2018-11-15 07:31:41 -06:00
|
|
|
{
|
2019-10-11 01:16:22 -05:00
|
|
|
const auto smry = EclIO::ESmry("SPE1CASE1");
|
|
|
|
const auto& time = smry.get("TIME");
|
|
|
|
const auto& press = smry.get("WOPR:PROD");
|
|
|
|
|
|
|
|
for (auto nstep = time.size(), time_index=0*nstep; time_index < nstep; time_index++) {
|
|
|
|
double seconds_elapsed = time[time_index] * 86400;
|
|
|
|
BOOST_CHECK_CLOSE(seconds_elapsed, press[time_index], 1e-3);
|
2018-11-15 07:31:41 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-10-11 01:16:22 -05:00
|
|
|
auto rst = EclIO::ERst("SPE1CASE1.UNRST");
|
|
|
|
|
|
|
|
for (const auto& step : rst.listOfReportStepNumbers()) {
|
2019-11-03 12:34:25 -06:00
|
|
|
const auto& dh = rst.getRst<double>("DOUBHEAD", step, 0);
|
|
|
|
const auto& press = rst.getRst<float>("PRESSURE", step, 0);
|
2019-10-11 01:16:22 -05:00
|
|
|
|
|
|
|
// DOUBHEAD[0] is elapsed time in days since start of simulation.
|
|
|
|
BOOST_CHECK_CLOSE( press[0], dh[0] * 86400, 1e-3 );
|
2018-11-15 07:31:41 -06:00
|
|
|
}
|
2020-03-30 06:39:42 -05:00
|
|
|
|
|
|
|
const int report_step = 50;
|
|
|
|
const auto& rst_state = Opm::RestartIO::RstState::load(rst, report_step);
|
|
|
|
Schedule sched_rst(deck, state, python, &rst_state);
|
|
|
|
const auto& rft_well = sched_rst.getWell("RFT", report_step);
|
|
|
|
BOOST_CHECK(rft_well.getStatus() == Well::Status::SHUT);
|
2018-11-15 07:31:41 -06:00
|
|
|
}
|
2018-10-09 10:42:37 -05:00
|
|
|
}
|
|
|
|
}
|