further corrections of unit tests and code clean up

This commit is contained in:
Jostein Alvestad 2020-06-09 23:48:55 +02:00
parent 862b7b7591
commit fea794ee17
7 changed files with 36 additions and 14 deletions

View File

@ -14,6 +14,7 @@
#include <opm/output/data/Solution.hpp>
#include <opm/output/data/Wells.hpp>
#include <opm/parser/eclipse/Deck/UDAValue.hpp>
namespace Opm {
@ -31,6 +32,8 @@ public:
msim(const EclipseState& state);
const UDAValue uda_val;
void well_rate(const std::string& well, data::Rates::opt rate, std::function<well_rate_function> func);
void solution(const std::string& field, std::function<solution_function> func);
void run(Schedule& schedule, EclipseIO& io, bool report_only);

View File

@ -54,6 +54,9 @@ public:
double getSI() const;
bool zero() const;
//constant - epsilon limit ~= 0.
const double epsilonLimit = 1.E-20;
template<typename T>
bool is() const;

View File

@ -641,7 +641,9 @@ namespace {
const auto& wname = well.name();
const auto wPKey = "WBHP:" + wname;
const auto& wRatesIt = wr.find(wname);
bool haveWellRes = wRatesIt != wr.end();
//
//Do not calculate well segment rates for shut wells
bool haveWellRes = (well.getStatus() != Opm::Well::Status::SHUT) ? (wRatesIt != wr.end()) : false;
const auto volFromLengthUnitConv = units.from_si(M::length, units.from_si(M::length, units.from_si(M::length, 1.)));
const auto areaFromLengthUnitConv = units.from_si(M::length, units.from_si(M::length, 1.));
//

View File

@ -43,7 +43,7 @@ namespace UDA {
// We do not handle negative rates.
// If negative rates occur a very small positive value is used to avoid 0.0
// since 0.0 means default which is no rate limit (a large positive value)
output_value = std::max(1.0e-20, output_value);
output_value = std::max(value.epsilonLimit, output_value);
return value.get_dim().convertRawToSi(output_value);
}
@ -69,7 +69,7 @@ double eval_group_uda(const UDAValue& value, const std::string& group, const Sum
// We do not handle negative rates.
// If negative rates occur a very small positive value is used to avoid 0.0
// since 0.0 means default which is no rate limit (a large positive value)
output_value = std::max(1.0e-20, output_value);
output_value = std::max(value.epsilonLimit, output_value);
return value.get_dim().convertRawToSi(output_value);
}

View File

@ -343,6 +343,8 @@ BOOST_AUTO_TEST_CASE(UDA) {
#include "uda.include"
test_data td( uda_deck );
msim sim(td.state);
const auto eps_lim = msim::uda_val.epsilonLimit;
EclipseIO io(td.state, td.state.getInputGrid(), td.schedule, td.summary_config);
sim.well_rate("P1", data::Rates::opt::wat, prod_wpr_P1);
@ -368,8 +370,10 @@ BOOST_AUTO_TEST_CASE(UDA) {
std::string wwpr_key = std::string("WWPR:") + well;
wwpr_sum += ecl_sum_get_general_var(ecl_sum, prev_tstep, wwpr_key.c_str());
}
wwpr_sum = 0.90 * wwpr_sum;
wwpr_sum = std::max(eps_lim, wwpr_sum);
}
BOOST_CHECK_CLOSE( 0.90 * wwpr_sum, ecl_sum_get_general_var(ecl_sum, ecl_sum_iget_report_end(ecl_sum, report_step), "WWIR:INJ"), 1e-3);
BOOST_CHECK_CLOSE( wwpr_sum, ecl_sum_get_general_var(ecl_sum, ecl_sum_iget_report_end(ecl_sum, report_step), "WWIR:INJ"), 1e-3);
}
}
}

View File

@ -1059,6 +1059,7 @@ BOOST_AUTO_TEST_CASE(WELL_POD) {
const auto rptStep = std::size_t{2};
const auto sim_step = rptStep - 1;
Opm::SummaryState sumState(std::chrono::system_clock::now());
const auto xw = well_rates_1();
const auto ih = Opm::RestartIO::Helpers::createInteHead(simCase.es,
simCase.grid,
@ -1070,10 +1071,10 @@ BOOST_AUTO_TEST_CASE(WELL_POD) {
auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih);
wellData.captureDeclaredWellData(simCase.sched, units, sim_step, sumState, ih);
wellData.captureDynamicWellData(simCase.sched, sim_step, {} , sumState);
wellData.captureDynamicWellData(simCase.sched, sim_step, xw , sumState);
auto connectionData = Opm::RestartIO::Helpers::AggregateConnectionData(ih);
connectionData.captureDeclaredConnData(simCase.sched, simCase.grid, units, {} , sim_step);
connectionData.captureDeclaredConnData(simCase.sched, simCase.grid, units, xw , sim_step);
const auto& iwel = wellData.getIWell();
const auto& swel = wellData.getSWell();

25
tests/test_Summary.cpp Normal file → Executable file
View File

@ -89,7 +89,7 @@ static const int day = 24 * 60 * 60;
This is quite misleading, because the values prepared in the test
input deck are NOT used.
*/
static data::Wells result_wells() {
static data::Wells result_wells(const bool w3_injector = true) {
/* populate with the following pattern:
*
* Wells are named W_1, W_2 etc, i.e. wells are 1 indexed.
@ -259,8 +259,13 @@ static data::Wells result_wells() {
well2.current_control.prod = ::Opm::Well::ProducerCMode::ORAT;
data::Well well3 { rates3, 2.1 * ps, 2.2 * ps, 2.3 * ps, 3, { {well3_comp1} }, SegRes{}, Ctrl{} };
well3.current_control.isProducer = false;
well3.current_control.inj = ::Opm::Well::InjectorCMode::BHP;
well3.current_control.isProducer = !w3_injector;
if (! well3.current_control.isProducer) { // W_3 is injector
well3.current_control.inj = ::Opm::Well::InjectorCMode::BHP;
}
else {
well3.current_control.prod = ::Opm::Well::ProducerCMode::BHP;
}
data::Well well6 { rates6, 2.1 * ps, 2.2 * ps, 2.3 * ps, 3, { {well6_comp1} }, SegRes{}, Ctrl{} };
well6.current_control.isProducer = false;
@ -385,14 +390,14 @@ struct setup {
/*-----------------------------------------------------------------*/
setup(std::string fname, const std::string& path = "summary_deck.DATA") :
setup(std::string fname, const std::string& path = "summary_deck.DATA", const bool w3_injector = true) :
deck( Parser().parseFile( path) ),
es( deck ),
grid( es.getInputGrid() ),
python( std::make_shared<Python>() ),
schedule( deck, es, python),
config( deck, schedule, es.getTableManager()),
wells( result_wells() ),
wells( result_wells(w3_injector) ),
groups( result_groups() ),
name( toupper(std::move(fname)) ),
ta( "summary_test" )
@ -1605,7 +1610,8 @@ BOOST_AUTO_TEST_CASE(READ_WRITE_WELLDATA) {
//
BOOST_AUTO_TEST_CASE(efficiency_factor) {
setup cfg( "test_efficiency_factor", "SUMMARY_EFF_FAC.DATA" );
// W_3 is a producer in SUMMARY_EFF_FAC.DATA
setup cfg( "test_efficiency_factor", "SUMMARY_EFF_FAC.DATA", false );
out::Summary writer( cfg.es, cfg.config, cfg.grid, cfg.schedule, cfg.name );
SummaryState st(std::chrono::system_clock::now());
@ -1861,10 +1867,13 @@ namespace {
auto calculateRestartVectorsEffFac()
-> decltype(calculateRestartVectors({"test.Restart.EffFac",
"SUMMARY_EFF_FAC.DATA"}))
"SUMMARY_EFF_FAC.DATA", false}))
{
// W_3 is a producer in SUMMARY_EFF_FAC.DATA
const auto w3_injector = false;
return calculateRestartVectors({
"test.Restart.EffFac", "SUMMARY_EFF_FAC.DATA"
"test.Restart.EffFac", "SUMMARY_EFF_FAC.DATA", w3_injector
});
}