various updates of unit tests

This commit is contained in:
Jostein Alvestad 2020-09-17 12:10:19 +02:00
parent 2efa272f6e
commit dc97e71350
5 changed files with 12197 additions and 2 deletions

View File

@ -450,6 +450,7 @@ if(ENABLE_ECL_OUTPUT)
tests/SPE1CASE2_RESTART.DATA
tests/SPE1CASE2.X0060
tests/PYACTION.DATA
tests/0A4_GRCTRL_LRAT_LRAT_GGR_BASE_MODEL2_MSW_ALL.DATA
tests/act1.py
tests/MSW.DATA
tests/EXIT_TEST.DATA

File diff suppressed because it is too large Load Diff

View File

@ -371,7 +371,11 @@ TSTEP -- 8
return Opm::Parser{}.parseString(input);
}
Opm::SummaryState sim_state()
Opm::Deck msw_sim(std::string fname) {
return Opm::Parser{}.parseFile(fname);
}
Opm::SummaryState sim_state()
{
auto state = Opm::SummaryState{std::chrono::system_clock::now()};
@ -722,6 +726,66 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data)
}
}
BOOST_AUTO_TEST_CASE (Declared_Well_Data_MSW_well_data)
{
const auto simCase = SimulationCase{msw_sim("0A4_GRCTRL_LRAT_LRAT_GGR_BASE_MODEL2_MSW_ALL.DATA")};
Opm::EclipseState es = simCase.es;
Opm::Schedule sched = simCase.sched;
Opm::Action::State action_state;
const auto rptStep = std::size_t{1};
const auto ih = MockIH {
static_cast<int>(simCase.sched.getWells(rptStep).size())
};
const auto smry = sim_state();
auto awd = Opm::RestartIO::Helpers::AggregateWellData{ih.value};
awd.captureDeclaredWellData(simCase.sched,
simCase.es.getUnits(), rptStep, action_state, smry, ih.value);
// IWEL (PROD1)
{
using Ix = ::Opm::RestartIO::Helpers::VectorItems::IWell::index;
const auto start = 0*ih.niwelz;
const auto& iwell = awd.getIWell();
BOOST_CHECK_EQUAL(iwell[start + Ix::MsWID] , 1); // PROD1 - first MSW well
BOOST_CHECK_EQUAL(iwell[start + Ix::NWseg] , 12); // PROD1 - 12 segments
BOOST_CHECK_EQUAL(iwell[start + Ix::MSW_PlossMod], 1); // PROD1 - HF- => 1
BOOST_CHECK_EQUAL(iwell[start + Ix::MSW_MulPhaseMod] , 1); // PROD1 - HO => 1
}
// IWEL (PROD2)
{
using Ix = ::Opm::RestartIO::Helpers::VectorItems::IWell::index;
const auto start = 1*ih.niwelz;
const auto& iwell = awd.getIWell();
BOOST_CHECK_EQUAL(iwell[start + Ix::MsWID] , 2); // PROD2 - second MSW well
BOOST_CHECK_EQUAL(iwell[start + Ix::NWseg] , 12); // PROD2 - 12 segments
BOOST_CHECK_EQUAL(iwell[start + Ix::MSW_PlossMod], 0); // PROD2 - HFA => 0,
BOOST_CHECK_EQUAL(iwell[start + Ix::MSW_MulPhaseMod] , 1); // PROD1 - HO => 0
}
// IWEL (PROD3)
{
using Ix = ::Opm::RestartIO::Helpers::VectorItems::IWell::index;
const auto start = 2*ih.niwelz;
const auto& iwell = awd.getIWell();
BOOST_CHECK_EQUAL(iwell[start + Ix::MsWID] , 3); // PROD3 - third MSW well
BOOST_CHECK_EQUAL(iwell[start + Ix::NWseg] , 10); // PROD3 - 10 segments
BOOST_CHECK_EQUAL(iwell[start + Ix::MSW_PlossMod], 2); // PROD3 - H-- => 2,
BOOST_CHECK_EQUAL(iwell[start + Ix::MSW_MulPhaseMod] , 1); // PROD3 - HO => 0
}
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step1)

View File

@ -20,8 +20,11 @@
#define BOOST_TEST_MODULE DoubHEAD_Vector
#include <boost/test/unit_test.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/parser/eclipse/Python/Python.hpp>
#include <opm/output/eclipse/DoubHEAD.hpp>
#include <opm/output/eclipse/VectorItems/doubhead.hpp>
#include <opm/output/eclipse/InteHEAD.hpp>
@ -29,6 +32,8 @@
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <chrono>
#include <ctime>
@ -37,6 +42,32 @@
#include <ratio>
#include <vector>
namespace {
Opm::Deck first_sim(std::string fname) {
return Opm::Parser{}.parseFile(fname);
}
}
//int main(int argc, char* argv[])
struct SimulationCase
{
explicit SimulationCase(const Opm::Deck& deck)
: es { deck }
, grid { deck }
, python{ std::make_shared<Opm::Python>() }
, sched{ deck, es, python }
{}
// Order requirement: 'es' must be declared/initialised before 'sched'.
Opm::EclipseState es;
Opm::EclipseGrid grid;
std::shared_ptr<Opm::Python> python;
Opm::Schedule sched;
};
namespace {
using Day = std::chrono::duration<double,
std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>
@ -66,6 +97,28 @@ namespace {
{
return { start, elapsed };
}
double getTimeConv(const ::Opm::UnitSystem& us)
{
switch (us.getType()) {
case ::Opm::UnitSystem::UnitType::UNIT_TYPE_METRIC:
return static_cast<double>(Opm::Metric::Time);
case ::Opm::UnitSystem::UnitType::UNIT_TYPE_FIELD:
return static_cast<double>(Opm::Field::Time);
case ::Opm::UnitSystem::UnitType::UNIT_TYPE_LAB:
return static_cast<double>(Opm::Lab::Time);
case ::Opm::UnitSystem::UnitType::UNIT_TYPE_PVT_M:
return static_cast<double>(Opm::PVT_M::Time);
case ::Opm::UnitSystem::UnitType::UNIT_TYPE_INPUT:
throw std::invalid_argument {
"Cannot Run Simulation With Non-Standard Units"
};
}
}
} // Anonymous
BOOST_AUTO_TEST_SUITE(Member_Functions)
@ -91,4 +144,31 @@ BOOST_AUTO_TEST_CASE(Time_Stamp)
BOOST_CHECK_CLOSE(v[162 - 1], 736200.0, 1.0e-10);
}
BOOST_AUTO_TEST_CASE(Wsegiter)
{
const auto simCase = SimulationCase{first_sim("0A4_GRCTRL_LRAT_LRAT_GGR_BASE_MODEL2_MSW_ALL.DATA")};
Opm::EclipseState es = simCase.es;
Opm::Schedule sched = simCase.sched;
const auto& usys = es.getDeckUnitSystem();
const auto tconv = getTimeConv(usys);
const std::size_t lookup_step = 1;
const auto tuning_data = sched.getTuning(lookup_step);
const auto dh = Opm::RestartIO::DoubHEAD{}
.tuningParameters(sched.getTuning(lookup_step), tconv);
const auto& v = dh.data();
namespace VI = Opm::RestartIO::Helpers::VectorItems;
BOOST_CHECK_EQUAL(v[VI::WsegRedFac], 0.3);
BOOST_CHECK_EQUAL(v[VI::WsegIncFac], 2.0);
}
BOOST_AUTO_TEST_SUITE_END()

View File

@ -343,10 +343,11 @@ BOOST_AUTO_TEST_CASE(Tuning_param)
const auto litmin = 20;
const auto mxwsit = 8;
const auto mxwpit = 6;
const auto wseg_max_restart = 49;
const auto ih = Opm::RestartIO::InteHEAD{}
.tuningParam({
newtmx, newtmn, litmax, litmin, mxwsit, mxwpit
newtmx, newtmn, litmax, litmin, mxwsit, mxwpit, wseg_max_restart
});
const auto& v = ih.data();
@ -357,6 +358,7 @@ BOOST_AUTO_TEST_CASE(Tuning_param)
BOOST_CHECK_EQUAL(v[VI::intehead::LITMIN], litmin);
BOOST_CHECK_EQUAL(v[VI::intehead::MXWSIT], mxwsit);
BOOST_CHECK_EQUAL(v[VI::intehead::MXWPIT], mxwpit);
BOOST_CHECK_EQUAL(v[VI::intehead::WSEGITR_IT2], wseg_max_restart);
}
BOOST_AUTO_TEST_CASE(Various_Parameters)