Properly differentiate between base case and restart case in test

This commit is contained in:
Joakim Hove 2020-01-29 12:40:11 +01:00
parent 1d8ea3c92e
commit a33108dee0
5 changed files with 368 additions and 65 deletions

View File

@ -388,8 +388,9 @@ if(ENABLE_ECL_OUTPUT)
list (APPEND TEST_DATA_FILES list (APPEND TEST_DATA_FILES
tests/expect-wdims.chldg.err.out tests/expect-wdims.chldg.err.out
tests/expect-wdims.err.out tests/expect-wdims.err.out
tests/FIRST_SIM.DATA tests/BASE_SIM.DATA
tests/FIRST_SIM_THPRES.DATA tests/BASE_SIM_THPRES.DATA
tests/RESTART_SIM.DATA
tests/summary_deck.DATA tests/summary_deck.DATA
tests/group_group.DATA tests/group_group.DATA
tests/testblackoilstate3.DATA tests/testblackoilstate3.DATA

128
tests/BASE_SIM.DATA Normal file
View File

@ -0,0 +1,128 @@
RUNSPEC
OIL
GAS
WATER
DISGAS
VAPOIL
UNIFOUT
UNIFIN
DIMENS
10 10 10 /
START -- 0
1 NOV 1979 /
WELLDIMS
-- Item 1: NWMAX (Maximum number of wells in model)
-- Item 2: NCWMAX (Maximum number of connections per well)
-- Item 3: NGMAX (Maximum number of groups in model--excluding FIELD)
-- Item 4: NWGMAX (Maximum number of wells or child groups per group)
-- NWMAX NCWMAX NGMAX NWGMAX
6 3 1 6
/
GRID
DXV
10*0.25 /
DYV
10*0.25 /
DZV
10*0.25 /
TOPS
100*0.25 /
PORO
1000*0.2 /
SOLUTION
SCHEDULE
RPTRST
BASIC=1
/
WELSPECS
'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
'OP_2' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
'OP_2' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 /
'OP_1' 9 9 3 3 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_1' 'OPEN' 'ORAT' 20000 4* 1000 /
/
WCONINJE
'OP_2' 'GAS' 'OPEN' 'RATE' 100 200 400 /
/
DATES -- 1
20 JAN 2011 /
/
WELSPECS
'OP_3' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_3' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_3' 'OPEN' 'ORAT' 20000 4* 1000 /
/
DATES -- 2
15 JUN 2013 /
/
COMPDAT
'OP_2' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
'OP_1' 9 9 7 7 'SHUT' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
DATES -- 3
22 APR 2014 /
/
WELSPECS
'OP_4' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_4' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
'OP_3' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_4' 'OPEN' 'ORAT' 20000 4* 1000 /
/
DATES -- 4
30 AUG 2014 /
/
WELSPECS
'OP_5' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_5' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_5' 'OPEN' 'ORAT' 20000 4* 1000 /
/
DATES -- 5
15 SEP 2014 /
/
WCONPROD
'OP_3' 'SHUT' 'ORAT' 20000 4* 1000 /
/
DATES -- 6
9 OCT 2014 /
/
WELSPECS
'OP_6' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_6' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_6' 'OPEN' 'ORAT' 20000 4* 1000 /
/
TSTEP -- 7
10 /

165
tests/BASE_SIM_THPRES.DATA Normal file
View File

@ -0,0 +1,165 @@
RUNSPEC
EQLOPTS
'THPRES' /
OIL
GAS
WATER
DISGAS
VAPOIL
UNIFOUT
UNIFIN
DIMENS
10 10 10 /
WELLDIMS
-- Item 1: NWMAX (Maximum number of wells in model)
-- Item 2: NCWMAX (Maximum number of connections per well)
-- Item 3: NGMAX (Maximum number of groups in model--excluding FIELD)
-- Item 4: NWGMAX (Maximum number of wells or child groups per group)
-- NWMAX NCWMAX NGMAX NWGMAX
6 3 1 6
/
EQLDIMS
10 /
GRID
DXV
10*0.25 /
DYV
10*0.25 /
DZV
10*0.25 /
TOPS
100*0.25 /
PORO
1000*0.2 /
PROPS
REGIONS
EQLNUM
100*1
100*2
100*3
100*4
100*5
100*6
100*7
100*8
100*9
100*10
/
SOLUTION
THPRES
1 1 0.1 /
1 2 0.2 /
1 3 0.3 /
1 4 0.4 /
1 5 0.5 /
1 6 0.6 /
1 7 0.7 /
1 8 0.8 /
1 9 0.9 /
1 10 1.0 /
-- Default pressures
2 2 /
/
START -- 0
1 NOV 1979 /
SCHEDULE
RPTRST
BASIC=1
/
WELSPECS
'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
'OP_2' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
'OP_2' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 /
'OP_1' 9 9 3 3 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_1' 'OPEN' 'ORAT' 20000 4* 1000 /
/
WCONINJE
'OP_2' 'GAS' 'OPEN' 'RATE' 100 200 400 /
/
DATES -- 1
20 JAN 2011 /
/
WELSPECS
'OP_3' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_3' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_3' 'OPEN' 'ORAT' 20000 4* 1000 /
/
DATES -- 2
15 JUN 2013 /
/
COMPDAT
'OP_2' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
'OP_1' 9 9 7 7 'SHUT' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
DATES -- 3
22 APR 2014 /
/
WELSPECS
'OP_4' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_4' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
'OP_3' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_4' 'OPEN' 'ORAT' 20000 4* 1000 /
/
DATES -- 4
30 AUG 2014 /
/
WELSPECS
'OP_5' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_5' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_5' 'OPEN' 'ORAT' 20000 4* 1000 /
/
DATES -- 5
15 SEP 2014 /
/
WCONPROD
'OP_3' 'SHUT' 'ORAT' 20000 4* 1000 /
/
DATES -- 6
9 OCT 2014 /
/
WELSPECS
'OP_6' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* /
/
COMPDAT
'OP_6' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 /
/
WCONPROD
'OP_6' 'OPEN' 'ORAT' 20000 4* 1000 /
/
TSTEP -- 7
10 /

View File

@ -36,7 +36,7 @@ PORO
SOLUTION SOLUTION
RESTART RESTART
FIRST_SIM 1/ BASE_SIM 1/
SCHEDULE SCHEDULE

View File

@ -332,9 +332,30 @@ Opm::SummaryState sim_state()
return state; return state;
} }
RestartValue first_sim(const EclipseState& es, EclipseIO& eclWriter, SummaryState& st, bool write_double) { struct Setup {
const auto& grid = es.getInputGrid(); Deck deck;
auto num_cells = grid.getNumActive( ); EclipseState es;
const EclipseGrid& grid;
Schedule schedule;
SummaryConfig summary_config;
Setup( const char* path) :
deck( Parser().parseFile( path) ),
es( deck),
grid( es.getInputGrid( ) ),
schedule( deck, es ),
summary_config( deck, schedule, es.getTableManager( ))
{
auto& io_config = es.getIOConfig();
io_config.setEclCompatibleRST(false);
}
};
RestartValue first_sim(const Setup& setup, SummaryState& st, bool write_double) {
EclipseIO eclWriter( setup.es, setup.grid, setup.schedule, setup.summary_config);
auto num_cells = setup.grid.getNumActive( );
auto start_time = TimeStampUTC( TimeStampUTC::YMD{ 1979, 11, 1 } ); auto start_time = TimeStampUTC( TimeStampUTC::YMD{ 1979, 11, 1 } );
auto first_step = TimeStampUTC( TimeStampUTC::YMD{ 2011, 2, 1 } ); // Must be after 2011-01-20 auto first_step = TimeStampUTC( TimeStampUTC::YMD{ 2011, 2, 1 } ); // Must be after 2011-01-20
@ -353,7 +374,8 @@ RestartValue first_sim(const EclipseState& es, EclipseIO& eclWriter, SummaryStat
return restart_value; return restart_value;
} }
RestartValue second_sim(const EclipseIO& writer, SummaryState& summary_state, const std::vector<RestartKey>& solution_keys) { RestartValue second_sim(const Setup& setup, SummaryState& summary_state, const std::vector<RestartKey>& solution_keys) {
EclipseIO writer(setup.es, setup.grid, setup.schedule, setup.summary_config);
return writer.loadRestart( summary_state, solution_keys ); return writer.loadRestart( summary_state, solution_keys );
} }
@ -379,26 +401,6 @@ void compare( const RestartValue& fst,
} }
struct Setup {
Deck deck;
EclipseState es;
const EclipseGrid& grid;
Schedule schedule;
SummaryConfig summary_config;
Setup( const char* path) :
deck( Parser().parseFile( path) ),
es( deck),
grid( es.getInputGrid( ) ),
schedule( deck, es ),
summary_config( deck, schedule, es.getTableManager( ))
{
auto& io_config = es.getIOConfig();
io_config.setEclCompatibleRST(false);
}
};
BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData) { BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData) {
@ -407,28 +409,31 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData) {
{"SGAS" , UnitSystem::measure::identity}, {"SGAS" , UnitSystem::measure::identity},
{"TEMP" , UnitSystem::measure::temperature}}; {"TEMP" , UnitSystem::measure::temperature}};
WorkArea test_area("test_restart"); WorkArea test_area("test_restart");
test_area.copyIn("FIRST_SIM.DATA"); test_area.copyIn("BASE_SIM.DATA");
test_area.copyIn("RESTART_SIM.DATA");
Setup setup("FIRST_SIM.DATA"); Setup base_setup("BASE_SIM.DATA");
EclipseIO eclWriter( setup.es, setup.grid, setup.schedule, setup.summary_config); Setup restart_setup("RESTART_SIM.DATA");
SummaryState st(std::chrono::system_clock::now()); SummaryState st(std::chrono::system_clock::now());
auto state1 = first_sim( setup.es , eclWriter , st, false ); auto state1 = first_sim( base_setup , st, false );
auto state2 = second_sim( eclWriter , st , keys ); auto state2 = second_sim( restart_setup , st , keys );
compare(state1, state2 , keys); compare(state1, state2 , keys);
BOOST_CHECK_THROW( second_sim( eclWriter, st, {{"SOIL", UnitSystem::measure::pressure}} ) , std::runtime_error ); BOOST_CHECK_THROW( second_sim( restart_setup, st, {{"SOIL", UnitSystem::measure::pressure}} ) , std::runtime_error );
BOOST_CHECK_THROW( second_sim( eclWriter, st, {{"SOIL", UnitSystem::measure::pressure, true}}) , std::runtime_error ); BOOST_CHECK_THROW( second_sim( restart_setup, st, {{"SOIL", UnitSystem::measure::pressure, true}}) , std::runtime_error );
} }
BOOST_AUTO_TEST_CASE(ECL_FORMATTED) { BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
namespace OS = ::Opm::EclIO::OutputStream; namespace OS = ::Opm::EclIO::OutputStream;
Setup setup("FIRST_SIM.DATA");
WorkArea test_area("test_Restart"); WorkArea test_area("test_Restart");
auto& io_config = setup.es.getIOConfig(); test_area.copyIn("BASE_SIM.DATA");
Setup base_setup("BASE_SIM.DATA");
auto& io_config = base_setup.es.getIOConfig();
{ {
auto num_cells = setup.grid.getNumActive( ); auto num_cells = base_setup.grid.getNumActive( );
auto cells = mkSolution( num_cells ); auto cells = mkSolution( num_cells );
auto wells = mkWells(); auto wells = mkWells();
auto sumState = sim_state(); auto sumState = sim_state();
@ -450,9 +455,9 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
RestartIO::save(rstFile, seqnum, RestartIO::save(rstFile, seqnum,
100, 100,
restart_value, restart_value,
setup.es, base_setup.es,
setup.grid, base_setup.grid,
setup.schedule, base_setup.schedule,
sumState, sumState,
true); true);
} }
@ -478,9 +483,9 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
RestartIO::save(rstFile, seqnum, RestartIO::save(rstFile, seqnum,
100, 100,
restart_value, restart_value,
setup.es, base_setup.es,
setup.grid, base_setup.grid,
setup.schedule, base_setup.schedule,
sumState, sumState,
true); true);
} }
@ -534,13 +539,14 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData_double) {
RestartKey("SGAS", UnitSystem::measure::identity)}; RestartKey("SGAS", UnitSystem::measure::identity)};
WorkArea test_area("test_Restart"); WorkArea test_area("test_Restart");
test_area.copyIn("FIRST_SIM.DATA"); test_area.copyIn("RESTART_SIM.DATA");
Setup setup("FIRST_SIM.DATA"); test_area.copyIn("BASE_SIM.DATA");
EclipseIO eclWriter( setup.es, setup.grid, setup.schedule, setup.summary_config); Setup base_setup("BASE_SIM.DATA");
Setup restart_setup("RESTART_SIM.DATA");
SummaryState st(std::chrono::system_clock::now()); SummaryState st(std::chrono::system_clock::now());
auto state1 = first_sim( setup.es , eclWriter , st, true); auto state1 = first_sim( base_setup , st, true);
auto state2 = second_sim( eclWriter ,st, solution_keys ); auto state2 = second_sim( restart_setup, st, solution_keys );
compare_equal( state1 , state2 , solution_keys); compare_equal( state1 , state2 , solution_keys);
} }
@ -549,8 +555,9 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) {
namespace OS = ::Opm::EclIO::OutputStream; namespace OS = ::Opm::EclIO::OutputStream;
WorkArea test_area("test_Restart"); WorkArea test_area("test_Restart");
test_area.copyIn("FIRST_SIM.DATA"); test_area.copyIn("BASE_SIM.DATA");
Setup setup("FIRST_SIM.DATA"); test_area.copyIn("RESTART_SIM.DATA");
Setup setup("BASE_SIM.DATA");
{ {
auto num_cells = setup.grid.getNumActive( ) + 1; auto num_cells = setup.grid.getNumActive( ) + 1;
auto cells = mkSolution( num_cells ); auto cells = mkSolution( num_cells );
@ -576,7 +583,7 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) {
BOOST_AUTO_TEST_CASE(ExtraData_KEYS) { BOOST_AUTO_TEST_CASE(ExtraData_KEYS) {
Setup setup("FIRST_SIM.DATA"); Setup setup("BASE_SIM.DATA");
auto num_cells = setup.grid.getNumActive( ); auto num_cells = setup.grid.getNumActive( );
auto cells = mkSolution( num_cells ); auto cells = mkSolution( num_cells );
auto wells = mkWells(); auto wells = mkWells();
@ -599,8 +606,9 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) {
namespace OS = ::Opm::EclIO::OutputStream; namespace OS = ::Opm::EclIO::OutputStream;
WorkArea test_area("test_Restart"); WorkArea test_area("test_Restart");
test_area.copyIn("FIRST_SIM.DATA"); test_area.copyIn("BASE_SIM.DATA");
Setup setup("FIRST_SIM.DATA"); test_area.copyIn("RESTART_SIM.DATA");
Setup setup("BASE_SIM.DATA");
{ {
auto num_cells = setup.grid.getNumActive( ); auto num_cells = setup.grid.getNumActive( );
auto cells = mkSolution( num_cells ); auto cells = mkSolution( num_cells );
@ -676,10 +684,10 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) {
namespace OS = ::Opm::EclIO::OutputStream; namespace OS = ::Opm::EclIO::OutputStream;
WorkArea test_area("test_Restart_THPRES"); WorkArea test_area("test_Restart_THPRES");
test_area.copyIn("FIRST_SIM_THPRES.DATA"); test_area.copyIn("BASE_SIM_THPRES.DATA");
Setup setup("FIRST_SIM_THPRES.DATA"); Setup base_setup("BASE_SIM_THPRES.DATA");
{ {
auto num_cells = setup.grid.getNumActive( ); auto num_cells = base_setup.grid.getNumActive( );
auto cells = mkSolution( num_cells ); auto cells = mkSolution( num_cells );
auto wells = mkWells(); auto wells = mkWells();
const auto outputDir = test_area.currentWorkingDirectory(); const auto outputDir = test_area.currentWorkingDirectory();
@ -714,14 +722,14 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) {
BOOST_CHECK_THROW( RestartIO::save(rstFile, seqnum, BOOST_CHECK_THROW( RestartIO::save(rstFile, seqnum,
100, 100,
restart_value, restart_value,
setup.es, base_setup.es,
setup.grid, base_setup.grid,
setup.schedule, base_setup.schedule,
sumState), sumState),
std::runtime_error); std::runtime_error);
} }
int num_regions = setup.es.getTableManager().getEqldims().getNumEquilRegions(); int num_regions = base_setup.es.getTableManager().getEqldims().getNumEquilRegions();
std::vector<double> thpres(num_regions * num_regions, 78); std::vector<double> thpres(num_regions * num_regions, 78);
restart_value2.addExtra("THRESHPR", UnitSystem::measure::pressure, thpres); restart_value2.addExtra("THRESHPR", UnitSystem::measure::pressure, thpres);
restart_value2.addExtra("EXTRA", UnitSystem::measure::pressure, thpres); restart_value2.addExtra("EXTRA", UnitSystem::measure::pressure, thpres);
@ -736,9 +744,9 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) {
RestartIO::save(rstFile, seqnum, RestartIO::save(rstFile, seqnum,
100, 100,
restart_value2, restart_value2,
setup.es, base_setup.es,
setup.grid, base_setup.grid,
setup.schedule, sumState); base_setup.schedule, sumState);
} }
{ {
@ -772,8 +780,9 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) {
BOOST_AUTO_TEST_CASE(Restore_Cumulatives) BOOST_AUTO_TEST_CASE(Restore_Cumulatives)
{ {
WorkArea wa{"test_Restart"}; WorkArea wa{"test_Restart"};
wa.copyIn("FIRST_SIM.DATA"); wa.copyIn("BASE_SIM.DATA");
Setup setup("FIRST_SIM.DATA"); wa.copyIn("RESTART_SIM.DATA");
Setup setup("BASE_SIM.DATA");
// Write fully ECLIPSE compatible output. This also saves cumulatives. // Write fully ECLIPSE compatible output. This also saves cumulatives.
setup.es.getIOConfig().setEclCompatibleRST(true); setup.es.getIOConfig().setEclCompatibleRST(true);