added unit tests to InteHead and DoubHead for NETBALAN
This commit is contained in:
parent
60d57f06b7
commit
6b7875765d
@ -501,6 +501,7 @@ if(ENABLE_ECL_OUTPUT)
|
||||
tests/UDQ_ACTIONX.DATA
|
||||
tests/UDQ_ACTIONX_RESTART.DATA
|
||||
tests/UDQ_TEST_WCONPROD_IUAD-2.DATA
|
||||
tests/5_NETWORK_MODEL5_STDW_NETBAL_PACK.DATA
|
||||
tests/9_4C_WINJ_GINJ_UDQ_MSW-UDARATE_TEST_PACK.DATA
|
||||
tests/UDQ_ACTIONX_TEST1.DATA
|
||||
tests/UDQ_ACTIONX_TEST1_U.DATA
|
||||
|
@ -43,12 +43,12 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
||||
XxxMBE = 18,
|
||||
XxxLCV = 19,
|
||||
XxxWFL = 20,
|
||||
Netbalan_1 = 51,
|
||||
Netbalan_2 = 53,
|
||||
Netbalan_4 = 50,
|
||||
Netbalan_6 = 63,
|
||||
Netbalan_7 = 64,
|
||||
Netbalan_8 = 66,
|
||||
Netbalan_1 = 51, // balancingInterval
|
||||
Netbalan_2 = 53, // convTolNodPres
|
||||
Netbalan_4 = 50, // convTolTHPCalc
|
||||
Netbalan_6 = 63, // targBranchBalError
|
||||
Netbalan_7 = 64, // maxBranchBalError
|
||||
Netbalan_8 = 66, // minTimeStepSize
|
||||
TrgDPR = 82,
|
||||
TfDiff = 83,
|
||||
DdpLim = 84,
|
||||
|
@ -42,6 +42,7 @@ namespace Opm { namespace RestartIO { namespace Helpers {
|
||||
std::vector<double>
|
||||
createDoubHead(const EclipseState& es,
|
||||
const Schedule& sched,
|
||||
const std::size_t report_step,
|
||||
const std::size_t lookup_step,
|
||||
const double simTime,
|
||||
const double nextTimeStep);
|
||||
|
@ -72,7 +72,7 @@ enum class CalcMode {
|
||||
|
||||
private:
|
||||
CalcMode calc_mode{CalcMode::None};
|
||||
std::optional<double> calc_interval;
|
||||
double calc_interval;
|
||||
double ptol;
|
||||
std::size_t m_pressure_max_iter;
|
||||
|
||||
|
@ -124,23 +124,37 @@ namespace {
|
||||
|
||||
Opm::RestartIO::DoubHEAD::NetBalanceDims
|
||||
getNetworkBalanceDims(const Opm::Schedule& sched,
|
||||
const std::size_t lookup_step)
|
||||
const Opm::UnitSystem& units,
|
||||
const std::size_t report_step)
|
||||
{
|
||||
const double balancingInterval = sched[lookup_step].network_balance().interval();
|
||||
const double convTolNodPres = sched[lookup_step].network_balance().pressure_tolerance();
|
||||
const double convTolTHPCalc = sched[lookup_step].network_balance().thp_tolerance();
|
||||
const double targBranchBalError = sched[lookup_step].network_balance().target_balance_error();
|
||||
const double maxBranchBalError = sched[lookup_step].network_balance().max_balance_error();
|
||||
const double minTimeStepSize = sched[lookup_step].network_balance().min_tstep();
|
||||
using M = ::Opm::UnitSystem::measure;
|
||||
double balancingInterval = 0.;
|
||||
double convTolNodPres = 0.;
|
||||
double convTolTHPCalc = 0.01;
|
||||
double targBranchBalError = 1.E+20;
|
||||
double maxBranchBalError = 1.E+20;
|
||||
double minTimeStepSize = 0.;
|
||||
|
||||
return {
|
||||
balancingInterval,
|
||||
convTolNodPres,
|
||||
convTolTHPCalc,
|
||||
targBranchBalError,
|
||||
maxBranchBalError,
|
||||
minTimeStepSize
|
||||
};
|
||||
if (report_step > 0) {
|
||||
if (sched[report_step].network().active()) {
|
||||
const auto lookup_step = report_step - 1;
|
||||
balancingInterval = units.from_si(M::time, sched[lookup_step].network_balance().interval());
|
||||
convTolNodPres = units.from_si(M::pressure, sched[lookup_step].network_balance().pressure_tolerance());
|
||||
convTolTHPCalc = sched[lookup_step].network_balance().thp_tolerance();
|
||||
targBranchBalError = units.from_si(M::pressure, sched[lookup_step].network_balance().target_balance_error());
|
||||
maxBranchBalError = units.from_si(M::pressure, sched[lookup_step].network_balance().max_balance_error());
|
||||
minTimeStepSize = units.from_si(M::time, sched[lookup_step].network_balance().min_tstep());
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
balancingInterval,
|
||||
convTolNodPres,
|
||||
convTolTHPCalc,
|
||||
targBranchBalError,
|
||||
maxBranchBalError,
|
||||
minTimeStepSize
|
||||
};
|
||||
}
|
||||
} // Anonymous
|
||||
|
||||
@ -152,6 +166,7 @@ std::vector<double>
|
||||
Opm::RestartIO::Helpers::
|
||||
createDoubHead(const EclipseState& es,
|
||||
const Schedule& sched,
|
||||
const std::size_t report_step,
|
||||
const std::size_t lookup_step,
|
||||
const double simTime,
|
||||
const double nextTimeStep)
|
||||
@ -167,7 +182,7 @@ createDoubHead(const EclipseState& es,
|
||||
.udq_param(rspec.udqParams())
|
||||
.guide_rate_param(computeGuideRate(sched, lookup_step))
|
||||
.lift_opt_param(computeLiftOptParam(sched, usys, lookup_step))
|
||||
.netBalDimensions(getNetworkBalanceDims(sched, lookup_step))
|
||||
.netBalDimensions(getNetworkBalanceDims(sched, usys, report_step))
|
||||
;
|
||||
|
||||
if (nextTimeStep > 0.0) {
|
||||
|
@ -244,7 +244,7 @@ namespace {
|
||||
rstFile.write("LOGIHEAD", Helpers::createLogiHead(es));
|
||||
|
||||
// write DOUBHEAD to restart file
|
||||
const auto dh = Helpers::createDoubHead(es, schedule, sim_step,
|
||||
const auto dh = Helpers::createDoubHead(es, schedule, report_step, sim_step,
|
||||
simTime, next_step_size);
|
||||
rstFile.write("DOUBHEAD", dh);
|
||||
|
||||
|
@ -300,7 +300,7 @@ namespace {
|
||||
|
||||
{
|
||||
const auto dh = ::Opm::RestartIO::Helpers::
|
||||
createDoubHead(es, sched, 0, 0.0, 0.0);
|
||||
createDoubHead(es, sched, 0, 0, 0.0, 0.0);
|
||||
|
||||
initFile.write("DOUBHEAD", dh);
|
||||
}
|
||||
|
@ -31,12 +31,14 @@ Balance::Balance(const Tuning& tuning, const DeckKeyword& keyword) {
|
||||
const auto& record = keyword[0];
|
||||
double interval = record.getItem<NB::TIME_INTERVAL>().getSIDouble(0);
|
||||
|
||||
if (interval < 0)
|
||||
if (interval < 0) {
|
||||
this->calc_mode = CalcMode::NUPCOL;
|
||||
|
||||
else if (interval == 0)
|
||||
this->calc_interval = 0.;
|
||||
}
|
||||
else if (interval == 0) {
|
||||
this->calc_mode = CalcMode::TimeStepStart;
|
||||
|
||||
this->calc_interval = interval;
|
||||
}
|
||||
else {
|
||||
this->calc_mode = CalcMode::TimeInterval;
|
||||
this->calc_interval = interval;
|
||||
@ -62,7 +64,7 @@ Balance::CalcMode Balance::mode() const {
|
||||
}
|
||||
|
||||
double Balance::interval() const {
|
||||
return this->calc_interval.value();
|
||||
return this->calc_interval;
|
||||
}
|
||||
|
||||
double Balance::pressure_tolerance() const {
|
||||
@ -95,6 +97,7 @@ double Balance::min_tstep() const {
|
||||
|
||||
Balance Balance::serializeObject() {
|
||||
Balance balance;
|
||||
balance.calc_interval = 0.;
|
||||
balance.calc_mode = Balance::CalcMode::NUPCOL;
|
||||
balance.m_min_tstep = 123;
|
||||
balance.ptol = 0.25;
|
||||
|
53531
tests/5_NETWORK_MODEL5_STDW_NETBAL_PACK.DATA
Normal file
53531
tests/5_NETWORK_MODEL5_STDW_NETBAL_PACK.DATA
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
||||
DX
|
||||
300*1000 /
|
@ -1,2 +0,0 @@
|
||||
DY
|
||||
300*1000 /
|
@ -1,2 +0,0 @@
|
||||
DZ
|
||||
100*20 100*30 100*50 /
|
@ -1,8 +0,0 @@
|
||||
INCLUDE
|
||||
'include/dx.grdecl' /
|
||||
|
||||
INCLUDE
|
||||
'include/dy.grdecl' /
|
||||
|
||||
INCLUDE
|
||||
'include/dz.grdecl' /
|
@ -1,3 +0,0 @@
|
||||
PORO
|
||||
300*0.3 /
|
||||
|
@ -1,12 +0,0 @@
|
||||
PERMX
|
||||
100*500 100*50 100*200 /
|
||||
|
||||
PERMY
|
||||
100*500 100*50 100*200 /
|
||||
|
||||
PERMZ
|
||||
100*500 100*50 100*200 /
|
||||
|
||||
INCLUDE
|
||||
'include/poro.grdecl' /
|
||||
|
@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(Declared_Actionx_data)
|
||||
|
||||
// set dummy value for next_step_size
|
||||
const double next_step_size = 0.1;
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, rptStep, secs_elapsed, next_step_size);
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, rptStep+1, rptStep, secs_elapsed, next_step_size);
|
||||
|
||||
const auto& lh = Opm::RestartIO::Helpers::createLogiHead(es);
|
||||
|
||||
|
@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE (Declared_UDQ_data)
|
||||
|
||||
//set dummy value for next_step_size
|
||||
const double next_step_size= 0.1;
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, rptStep,
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, rptStep+1, rptStep,
|
||||
secs_elapsed, next_step_size);
|
||||
|
||||
const auto& lh = Opm::RestartIO::Helpers::createLogiHead(es);
|
||||
@ -922,7 +922,7 @@ BOOST_AUTO_TEST_CASE (Declared_UDQ_data_2)
|
||||
|
||||
//set dummy value for next_step_size
|
||||
double next_step_size= 0.1;
|
||||
auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, simStep,
|
||||
auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, simStep+1, simStep,
|
||||
secs_elapsed, next_step_size);
|
||||
|
||||
auto lh = Opm::RestartIO::Helpers::createLogiHead(es);
|
||||
@ -949,7 +949,7 @@ BOOST_AUTO_TEST_CASE (Declared_UDQ_data_2)
|
||||
|
||||
//set dummy value for next_step_size
|
||||
next_step_size= 0.1;
|
||||
dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, simStep,
|
||||
dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, simStep+1, simStep,
|
||||
secs_elapsed, next_step_size);
|
||||
|
||||
lh = Opm::RestartIO::Helpers::createLogiHead(es);
|
||||
|
@ -782,7 +782,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data)
|
||||
createInteHead(simCase.es, simCase.es.getInputGrid(), simCase.sched, secs_elapsed,
|
||||
rptStep, rptStep, rptStep);
|
||||
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(simCase.es, simCase.sched, rptStep,
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(simCase.es, simCase.sched, rptStep+1, rptStep,
|
||||
secs_elapsed, next_step_size);
|
||||
|
||||
const auto& lh = Opm::RestartIO::Helpers::createLogiHead(simCase.es);
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <opm/output/eclipse/DoubHEAD.hpp>
|
||||
#include <opm/output/eclipse/VectorItems/doubhead.hpp>
|
||||
#include <opm/output/eclipse/WriteRestartHelpers.hpp>
|
||||
|
||||
#include <opm/output/eclipse/InteHEAD.hpp>
|
||||
|
||||
@ -169,5 +170,44 @@ BOOST_AUTO_TEST_CASE(Wsegiter)
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Netbalan)
|
||||
{
|
||||
const auto simCase = SimulationCase{first_sim("5_NETWORK_MODEL5_STDW_NETBAL_PACK.DATA")};
|
||||
|
||||
Opm::EclipseState es = simCase.es;
|
||||
Opm::EclipseGrid grid = simCase.grid;
|
||||
|
||||
Opm::Schedule sched = simCase.sched;
|
||||
const auto& start_time = sched.getStartTime();
|
||||
|
||||
const auto& usys = es.getDeckUnitSystem();
|
||||
const auto tconv = getTimeConv(usys);
|
||||
|
||||
double simTime = start_time + 2.E09;
|
||||
const double next_step_size = 0.2;
|
||||
|
||||
const std::size_t report_step = 1;
|
||||
const std::size_t lookup_step = report_step - 1;
|
||||
|
||||
const auto ih = Opm::RestartIO::Helpers::
|
||||
createInteHead(es, grid, sched, simTime,
|
||||
report_step, // Should really be number of timesteps
|
||||
report_step, lookup_step);
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, report_step, lookup_step,
|
||||
simTime, next_step_size);
|
||||
|
||||
const auto& v = dh.data();
|
||||
|
||||
namespace VI = Opm::RestartIO::Helpers::VectorItems;
|
||||
|
||||
BOOST_CHECK_EQUAL(v[VI::doubhead::Netbalan_1], 2.345);
|
||||
BOOST_CHECK_EQUAL(v[VI::doubhead::Netbalan_2], 0.033);
|
||||
BOOST_CHECK_EQUAL(v[VI::doubhead::Netbalan_4], 0.1);
|
||||
BOOST_CHECK_EQUAL(v[VI::doubhead::Netbalan_6], 1.E+19);
|
||||
BOOST_CHECK_EQUAL(v[VI::doubhead::Netbalan_7], 1.E+18);
|
||||
BOOST_CHECK_EQUAL(v[VI::doubhead::Netbalan_8], 0.15);
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
@ -24,12 +24,12 @@
|
||||
#include <opm/output/eclipse/InteHEAD.hpp>
|
||||
|
||||
#include <opm/output/eclipse/VectorItems/intehead.hpp>
|
||||
#include <opm/output/eclipse/WriteRestartHelpers.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include <opm/io/eclipse/rst/header.hpp>
|
||||
|
||||
@ -75,8 +75,33 @@ std::vector<double> elapsedTime(const Opm::Schedule& sched)
|
||||
BOOST_CHECK_EQUAL(tp.second , 0);
|
||||
BOOST_CHECK_EQUAL(tp.microseconds, 0);
|
||||
}
|
||||
|
||||
Opm::Deck first_sim(std::string fname) {
|
||||
return Opm::Parser{}.parseFile(fname);
|
||||
}
|
||||
|
||||
} // Anonymous
|
||||
|
||||
|
||||
//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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Member_Functions)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Dimensions_Individual)
|
||||
@ -696,4 +721,36 @@ BOOST_AUTO_TEST_CASE(TestHeader) {
|
||||
BOOST_CHECK_EQUAL(header.ngroup, ngroup);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Netbalan)
|
||||
{
|
||||
const auto simCase = SimulationCase{first_sim("5_NETWORK_MODEL5_STDW_NETBAL_PACK.DATA")};
|
||||
|
||||
Opm::EclipseState es = simCase.es;
|
||||
Opm::EclipseGrid grid = simCase.grid;
|
||||
|
||||
Opm::Schedule sched = simCase.sched;
|
||||
const auto& start_time = sched.getStartTime();
|
||||
double simTime = start_time + 2.E09;
|
||||
|
||||
const std::size_t report_step = 1;
|
||||
const std::size_t lookup_step = report_step - 1;
|
||||
|
||||
const auto ih = Opm::RestartIO::Helpers::
|
||||
createInteHead(es, grid, sched, simTime,
|
||||
report_step, // Should really be number of timesteps
|
||||
report_step, lookup_step);
|
||||
|
||||
|
||||
const auto& v = ih.data();
|
||||
|
||||
namespace VI = Opm::RestartIO::Helpers::VectorItems;
|
||||
|
||||
BOOST_CHECK_EQUAL(v[VI::intehead::NETBALAN_3], 13);
|
||||
BOOST_CHECK_EQUAL(v[VI::intehead::NETBALAN_5], 14);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // Transfer_Protocol
|
||||
|
@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(liftGasOptimzation_data)
|
||||
|
||||
// set dummy value for next_step_size
|
||||
const double next_step_size = 0.1;
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, simStep, secs_elapsed, next_step_size);
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, simStep+1, simStep, secs_elapsed, next_step_size);
|
||||
|
||||
auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih);
|
||||
wellData.captureDeclaredWellData(sched, es.getUnits(), simStep, action_state, {}, st, ih);
|
||||
|
@ -231,6 +231,7 @@ BOOST_AUTO_TEST_CASE(group_test) {
|
||||
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(simCase.es,
|
||||
simCase.sched,
|
||||
sim_step+1,
|
||||
sim_step,
|
||||
0, 0);
|
||||
|
||||
@ -285,6 +286,7 @@ BOOST_AUTO_TEST_CASE(State_test) {
|
||||
|
||||
const auto dh = Opm::RestartIO::Helpers::createDoubHead(simCase.es,
|
||||
simCase.sched,
|
||||
sim_step+1,
|
||||
sim_step,
|
||||
0, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user