Merge pull request #2427 from bska/connection-cumulatives-restart

Save/Restore Connection Level Cumulatives to/from Restart
This commit is contained in:
Bård Skaflestad 2021-10-20 17:04:23 +02:00 committed by GitHub
commit e7d528e1d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 247 additions and 100 deletions

View File

@ -67,13 +67,25 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
WaterRate = 1, // Surface flow rate (water) WaterRate = 1, // Surface flow rate (water)
GasRate = 2, // Surface Flow rate (gas) GasRate = 2, // Surface Flow rate (gas)
OilPrTotal = 3, // Total cumulative oil production
WatPrTotal = 4, // Total cumulative water production
GasPrTotal = 5, // Total cumulative gas production
OilInjTotal = 6, // Total cumulative oil injection
WatInjTotal = 7, // Total cumulative water injection
GasInjTotal = 8, // Total cumulative gas injection
GORatio = 10, // Producing gas/oil ratio
OilRate_Copy = 17, // Surface flow rate (oil) OilRate_Copy = 17, // Surface flow rate (oil)
WaterRate_Copy = 18, // Surface flow rate (water) WaterRate_Copy = 18, // Surface flow rate (water)
GasRate_Copy = 19, // Surface Flow rate (gas) GasRate_Copy = 19, // Surface Flow rate (gas)
Pressure = 34, // Connection pressure value Pressure = 34, // Connection pressure value
ResVRate = 49, // Reservoir voidage rate ResVRate = 49, // Reservoir voidage rate
VoidPrTotal = 50, // Total cumulative reservoir voidage volume production
VoidInjTotal = 51, // Total cumulative reservoir voidage volume injection
}; };
} // XConn } // XConn
}}}} // Opm::RestartIO::Helpers::VectorItems }}}} // Opm::RestartIO::Helpers::VectorItems

View File

@ -202,6 +202,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
VoidPrTotal = 21, // Well's total cumulative reservoir VoidPrTotal = 21, // Well's total cumulative reservoir
// voidage production // voidage production
OilInjTotal = 22, // Well's total cumulative oil injection
WatInjTotal = 23, // Well's total cumulative water injection WatInjTotal = 23, // Well's total cumulative water injection
GasInjTotal = 24, // Well's total cumulative gas injection GasInjTotal = 24, // Well's total cumulative gas injection
VoidInjTotal = 25, // Well's total cumulative reservoir volume injection VoidInjTotal = 25, // Well's total cumulative reservoir volume injection

View File

@ -38,6 +38,8 @@
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include <fmt/format.h>
namespace VI = Opm::RestartIO::Helpers::VectorItems; namespace VI = Opm::RestartIO::Helpers::VectorItems;
// ##################################################################### // #####################################################################
@ -61,23 +63,28 @@ namespace {
const Opm::data::Well* wellRes, const Opm::data::Well* wellRes,
ConnOp&& connOp) ConnOp&& connOp)
{ {
const auto& wellName = well.name();
const auto wellID = well.seqIndex();
const auto isProd = well.isProducer();
std::size_t connID = 0; std::size_t connID = 0;
for (const auto* connPtr : well.getConnections().output(grid)) { for (const auto* connPtr : well.getConnections().output(grid)) {
const auto* dynConnRes = (wellRes == nullptr) const auto* dynConnRes = (wellRes == nullptr)
? nullptr : wellRes->find_connection(connPtr->global_index()); ? nullptr : wellRes->find_connection(connPtr->global_index());
connOp(well, *connPtr, connID, connPtr->global_index(), dynConnRes); connOp(wellName, wellID, isProd, *connPtr, connID,
connPtr->global_index(), dynConnRes);
++connID; ++connID;
} }
} }
template <class ConnOp> template <class ConnOp>
void wellConnectionLoop(const Opm::Schedule& sched, void wellConnectionLoop(const Opm::Schedule& sched,
const std::size_t sim_step, const std::size_t sim_step,
const Opm::EclipseGrid& grid, const Opm::EclipseGrid& grid,
const Opm::data::Wells& xw, const Opm::data::Wells& xw,
ConnOp&& connOp) ConnOp&& connOp)
{ {
for (const auto& wname : sched.wellNames(sim_step)) { for (const auto& wname : sched.wellNames(sim_step)) {
const auto well_iter = xw.find(wname); const auto well_iter = xw.find(wname);
@ -234,60 +241,60 @@ namespace {
} }
template <class XConnArray> template <class XConnArray>
void dynamicContrib(const Opm::Well& well, void dynamicContrib(const std::string& well_name,
const std::size_t& global_index, const bool is_producer,
const std::size_t global_index,
const Opm::SummaryState& summary_state, const Opm::SummaryState& summary_state,
const Opm::data::Connection& x, XConnArray& xConn)
const Opm::UnitSystem& units,
XConnArray& xConn)
{ {
using M = ::Opm::UnitSystem::measure;
using Ix = ::Opm::RestartIO::Helpers::VectorItems::XConn::index; using Ix = ::Opm::RestartIO::Helpers::VectorItems::XConn::index;
using R = ::Opm::data::Rates::opt;
const auto& wname = well.name();
xConn[Ix::Pressure] = summary_state.get_conn_var(wname, "CPR", global_index + 1); auto get = [global_index, &well_name, &summary_state]
(const std::string& var)
{
return summary_state
.get_conn_var(well_name, var, global_index + 1, 0.0);
};
// Note flow rate sign. Treat production rates as positive. auto connRate = [is_producer, &get](const char phase) -> double
const auto& Q = x.rates; {
if (well.isProducer()) { const auto var =
if (summary_state.has_conn_var(wname, "COPR", global_index + 1)) fmt::format("C{}{}R", phase, is_producer ? 'P' : 'I');
xConn[Ix::OilRate] = summary_state.get_conn_var(wname, "COPR", global_index + 1);
if (summary_state.has_conn_var(wname, "CWPR", global_index + 1)) const auto val = get(var);
xConn[Ix::WaterRate] = summary_state.get_conn_var(wname, "CWPR", global_index + 1);
if (summary_state.has_conn_var(wname, "CGPR", global_index + 1)) // Note: Production rates are positive but injection rates
xConn[Ix::GasRate] = summary_state.get_conn_var(wname, "CGPR", global_index + 1); // are reported as negative values in XCON.
} else { return is_producer ? val : -val;
if (summary_state.has_conn_var(wname, "COIR", global_index + 1)) };
xConn[Ix::OilRate] = -summary_state.get_conn_var(wname, "COIR", global_index + 1);
if (summary_state.has_conn_var(wname, "CWIR", global_index + 1)) auto connTotal = [&get](const char phase, const char direction)
xConn[Ix::WaterRate] = -summary_state.get_conn_var(wname, "CWIR", global_index + 1); {
return get(fmt::format("C{}{}T", phase, direction));
};
xConn[Ix::Pressure] = get("CPR");
xConn[Ix::OilRate] = connRate('O');
xConn[Ix::WaterRate] = connRate('W');
xConn[Ix::GasRate] = connRate('G');
xConn[Ix::ResVRate] = connRate('V');
xConn[Ix::OilPrTotal] = connTotal('O', 'P');
xConn[Ix::WatPrTotal] = connTotal('W', 'P');
xConn[Ix::GasPrTotal] = connTotal('G', 'P');
xConn[Ix::VoidPrTotal] = connTotal('V', 'P');
xConn[Ix::OilInjTotal] = connTotal('O', 'I');
xConn[Ix::WatInjTotal] = connTotal('W', 'I');
xConn[Ix::GasInjTotal] = connTotal('G', 'I');
xConn[Ix::VoidInjTotal] = connTotal('V', 'I');
xConn[Ix::GORatio] = get("CGOR");
if (summary_state.has_conn_var(wname, "CGIR", global_index + 1))
xConn[Ix::GasRate] = -summary_state.get_conn_var(wname, "CGIR", global_index + 1);
}
xConn[Ix::OilRate_Copy] = xConn[Ix::OilRate]; xConn[Ix::OilRate_Copy] = xConn[Ix::OilRate];
xConn[Ix::GasRate_Copy] = xConn[Ix::GasRate]; xConn[Ix::GasRate_Copy] = xConn[Ix::GasRate];
xConn[Ix::WaterRate_Copy] = xConn[Ix::WaterRate]; xConn[Ix::WaterRate_Copy] = xConn[Ix::WaterRate];
xConn[Ix::ResVRate] = 0.0;
if (Q.has(R::reservoir_oil)) {
xConn[Ix::ResVRate] -=
units.from_si(M::rate, Q.get(R::reservoir_oil));
}
if (Q.has(R::reservoir_water)) {
xConn[Ix::ResVRate] -=
units.from_si(M::rate, Q.get(R::reservoir_water));
}
if (Q.has(R::reservoir_gas)) {
xConn[Ix::ResVRate] -=
units.from_si(M::rate, Q.get(R::reservoir_gas));
}
} }
} // XConn } // XConn
} // Anonymous } // Anonymous
@ -311,13 +318,14 @@ captureDeclaredConnData(const Schedule& sched,
const std::size_t sim_step) const std::size_t sim_step)
{ {
wellConnectionLoop(sched, sim_step, grid, xw, [&units, &summary_state, this] wellConnectionLoop(sched, sim_step, grid, xw, [&units, &summary_state, this]
(const Well& well, (const std::string& wellName,
const std::size_t wellID,
const bool is_producer,
const Connection& conn, const Connection& conn,
const std::size_t connID, const std::size_t connID,
const std::size_t global_index, const std::size_t global_index,
const data::Connection* dynConnRes) -> void const data::Connection* dynConnRes) -> void
{ {
const auto wellID = well.seqIndex();
auto ic = this->iConn_(wellID, connID); auto ic = this->iConn_(wellID, connID);
auto sc = this->sConn_(wellID, connID); auto sc = this->sConn_(wellID, connID);
@ -327,10 +335,12 @@ captureDeclaredConnData(const Schedule& sched,
if (dynConnRes != nullptr) { if (dynConnRes != nullptr) {
// Simulator provides dynamic connection results such as flow // Simulator provides dynamic connection results such as flow
// rates and PI-adjusted transmissibility factors. // rates and PI-adjusted transmissibility factors.
auto xc = this->xConn_(wellID, connID);
SConn::dynamicContrib(*dynConnRes, units, sc); SConn::dynamicContrib(*dynConnRes, units, sc);
XConn::dynamicContrib(well, global_index, summary_state, *dynConnRes, units, xc);
} }
auto xc = this->xConn_(wellID, connID);
XConn::dynamicContrib(wellName, is_producer,
global_index, summary_state, xc);
}); });
} }

View File

@ -868,6 +868,23 @@ namespace {
return wells; return wells;
} }
template <typename AssignCumulative>
void restoreConnCumulatives(const WellVectors::Window<double>& xcon,
AssignCumulative&& asgn)
{
asgn("COPT", xcon[VI::XConn::index::OilPrTotal]);
asgn("COIT", xcon[VI::XConn::index::OilInjTotal]);
asgn("CGPT", xcon[VI::XConn::index::GasPrTotal]);
asgn("CGIT", xcon[VI::XConn::index::GasInjTotal]);
asgn("CWPT", xcon[VI::XConn::index::WatPrTotal]);
asgn("CWIT", xcon[VI::XConn::index::WatInjTotal]);
asgn("CVPT", xcon[VI::XConn::index::VoidPrTotal]);
asgn("CVIT", xcon[VI::XConn::index::VoidInjTotal]);
}
void restoreConnRates(const WellVectors::Window<double>& xcon, void restoreConnRates(const WellVectors::Window<double>& xcon,
const Opm::UnitSystem& usys, const Opm::UnitSystem& usys,
const bool oil, const bool oil,
@ -912,6 +929,7 @@ namespace {
const Opm::UnitSystem& usys, const Opm::UnitSystem& usys,
const Opm::Phases& phases, const Opm::Phases& phases,
const WellVectors& wellData, const WellVectors& wellData,
Opm::SummaryState& smry,
Opm::data::Well& xw) Opm::data::Well& xw)
{ {
using M = ::Opm::UnitSystem::measure; using M = ::Opm::UnitSystem::measure;
@ -945,6 +963,7 @@ namespace {
return; return;
} }
const auto& wname = well.name();
for (auto rstConnID = 0*nConn; rstConnID < nConn; ++rstConnID) { for (auto rstConnID = 0*nConn; rstConnID < nConn; ++rstConnID) {
const auto icon = wellData.icon(wellID, rstConnID); const auto icon = wellData.icon(wellID, rstConnID);
@ -952,10 +971,18 @@ namespace {
const auto j = icon[VI::IConn::index::CellJ] - 1; const auto j = icon[VI::IConn::index::CellJ] - 1;
const auto k = icon[VI::IConn::index::CellK] - 1; const auto k = icon[VI::IConn::index::CellK] - 1;
auto* xc = xw.find_connection(grid.getGlobalIndex(i, j, k)); const auto globCell = grid.getGlobalIndex(i, j, k);
const auto xcon = wellData.xcon(wellID, rstConnID);
restoreConnCumulatives(xcon, [globCell, &wname, &smry]
(const std::string& vector, const double value)
{
smry.update_conn_var(wname, vector, globCell + 1, value);
});
auto* xc = xw.find_connection(globCell);
if (xc == nullptr) { continue; } if (xc == nullptr) { continue; }
const auto xcon = wellData.xcon(wellID, rstConnID);
restoreConnRates(xcon, usys, oil, gas, wat, *xc); restoreConnRates(xcon, usys, oil, gas, wat, *xc);
xc->pressure = usys.to_si(M::pressure, xcon[Ix::Pressure]); xc->pressure = usys.to_si(M::pressure, xcon[Ix::Pressure]);
@ -1095,7 +1122,8 @@ namespace {
const Opm::UnitSystem& usys, const Opm::UnitSystem& usys,
const Opm::Phases& phases, const Opm::Phases& phases,
const WellVectors& wellData, const WellVectors& wellData,
const SegmentVectors& segData) const SegmentVectors& segData,
Opm::SummaryState& smry)
{ {
if (! wellData.hasDefinedWellValues()) { if (! wellData.hasDefinedWellValues()) {
// Result set does not provide well information. // Result set does not provide well information.
@ -1171,9 +1199,11 @@ namespace {
xw.thp = usys.to_si(M::pressure, xwel[VI::XWell::index::TubHeadPr]); xw.thp = usys.to_si(M::pressure, xwel[VI::XWell::index::TubHeadPr]);
xw.temperature = 0.0; xw.temperature = 0.0;
// 4) Restore connection flow rates (xw.connections[i].rates) // 4) Restore connection flow rates (xw.connections[i].rates),
// and pressure values (xw.connections[i].pressure). // cumulatives (Cx{P,I}T), and pressure values
restoreConnResults(well, wellID, grid, usys, phases, wellData, xw); // (xw.connections[i].pressure).
restoreConnResults(well, wellID, grid, usys,
phases, wellData, smry, xw);
// 5) Restore well's active/current control // 5) Restore well's active/current control
restoreCurrentControl(wellID, wellData, xw); restoreCurrentControl(wellID, wellData, xw);
@ -1202,6 +1232,7 @@ namespace {
restore_wells_ecl(const ::Opm::EclipseState& es, restore_wells_ecl(const ::Opm::EclipseState& es,
const ::Opm::EclipseGrid& grid, const ::Opm::EclipseGrid& grid,
const ::Opm::Schedule& schedule, const ::Opm::Schedule& schedule,
Opm::SummaryState& smry,
std::shared_ptr<Opm::EclIO::RestartFileView> rst_view) std::shared_ptr<Opm::EclIO::RestartFileView> rst_view)
{ {
auto soln = ::Opm::data::Wells{}; auto soln = ::Opm::data::Wells{};
@ -1222,7 +1253,7 @@ namespace {
soln[well.name()] = soln[well.name()] =
restore_well(well, wellID, grid, units, restore_well(well, wellID, grid, units,
phases, wellData, segData); phases, wellData, segData, smry);
} }
return soln; return soln;
@ -1588,7 +1619,7 @@ namespace Opm { namespace RestartIO {
auto xw = rst_view->hasKeyword<double>("OPM_XWEL") auto xw = rst_view->hasKeyword<double>("OPM_XWEL")
? restore_wells_opm(es, grid, schedule, *rst_view) ? restore_wells_opm(es, grid, schedule, *rst_view)
: restore_wells_ecl(es, grid, schedule, rst_view); : restore_wells_ecl(es, grid, schedule, summary_state, rst_view);
auto xgrp_nwrk = restore_grp_nwrk(schedule, es.getUnits(), rst_view); auto xgrp_nwrk = restore_grp_nwrk(schedule, es.getUnits(), rst_view);

View File

@ -178,10 +178,21 @@ namespace {
{"COPR", Opm::EclIO::SummaryNode::Type::Rate}, {"COPR", Opm::EclIO::SummaryNode::Type::Rate},
{"CWPR", Opm::EclIO::SummaryNode::Type::Rate}, {"CWPR", Opm::EclIO::SummaryNode::Type::Rate},
{"CGPR", Opm::EclIO::SummaryNode::Type::Rate}, {"CGPR", Opm::EclIO::SummaryNode::Type::Rate},
{"CVPR", Opm::EclIO::SummaryNode::Type::Rate},
{"COPT", Opm::EclIO::SummaryNode::Type::Total},
{"CWPT", Opm::EclIO::SummaryNode::Type::Total},
{"CGPT", Opm::EclIO::SummaryNode::Type::Total},
{"CVPT", Opm::EclIO::SummaryNode::Type::Total},
{"COIR", Opm::EclIO::SummaryNode::Type::Rate}, {"COIR", Opm::EclIO::SummaryNode::Type::Rate},
{"CWIR", Opm::EclIO::SummaryNode::Type::Rate}, {"CWIR", Opm::EclIO::SummaryNode::Type::Rate},
{"CGIR", Opm::EclIO::SummaryNode::Type::Rate}, {"CGIR", Opm::EclIO::SummaryNode::Type::Rate},
{"CPR", Opm::EclIO::SummaryNode::Type::Pressure} {"CVIR", Opm::EclIO::SummaryNode::Type::Rate},
{"COIT", Opm::EclIO::SummaryNode::Type::Total},
{"CWIT", Opm::EclIO::SummaryNode::Type::Total},
{"CGIT", Opm::EclIO::SummaryNode::Type::Total},
{"CVIT", Opm::EclIO::SummaryNode::Type::Total},
{"CPR", Opm::EclIO::SummaryNode::Type::Pressure},
{"CGOR", Opm::EclIO::SummaryNode::Type::Ratio},
}; };
using Cat = Opm::EclIO::SummaryNode::Category; using Cat = Opm::EclIO::SummaryNode::Category;

View File

@ -17,22 +17,21 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>. along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define BOOST_TEST_MODULE Aggregate_Connection_Data #define BOOST_TEST_MODULE Aggregate_Connection_Data
#include <opm/output/eclipse/AggregateMSWData.hpp>
#include <opm/output/eclipse/AggregateConnectionData.hpp> #include <opm/output/eclipse/AggregateConnectionData.hpp>
#include <opm/output/eclipse/VectorItems/connection.hpp>
#include <opm/io/eclipse/rst/header.hpp>
#include <opm/io/eclipse/rst/connection.hpp>
#include <opm/parser/eclipse/Python/Python.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <opm/output/eclipse/AggregateMSWData.hpp>
#include <opm/output/eclipse/AggregateWellData.hpp> #include <opm/output/eclipse/AggregateWellData.hpp>
#include <opm/output/eclipse/VectorItems/connection.hpp>
#include <opm/output/eclipse/VectorItems/intehead.hpp> #include <opm/output/eclipse/VectorItems/intehead.hpp>
#include <opm/output/eclipse/VectorItems/well.hpp> #include <opm/output/eclipse/VectorItems/well.hpp>
#include <opm/io/eclipse/rst/connection.hpp>
#include <opm/io/eclipse/rst/header.hpp>
#include <opm/output/data/Wells.hpp> #include <opm/output/data/Wells.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp> #include <opm/parser/eclipse/Deck/Deck.hpp>
@ -40,14 +39,15 @@
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp> #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/Python/Python.hpp>
#include <opm/common/utility/TimeService.hpp> #include <opm/common/utility/TimeService.hpp>
#include <cstddef>
#include <exception> #include <exception>
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <iostream>
#include <cstddef>
struct MockIH struct MockIH
{ {
@ -482,20 +482,22 @@ END
{ {
xw["PROD"].rates.set(o::wat, 1.0).set(o::oil, 2.0).set(o::gas, 3.0); xw["PROD"].rates.set(o::wat, 1.0).set(o::oil, 2.0).set(o::gas, 3.0);
xw["PROD"].bhp = 213.0; xw["PROD"].bhp = 213.0;
double qo = 5.;
double qw = 4.; const double qv = 12.34;
double qg = 50.;
{ {
const double qw = 4.0;
const double qo = 5.0;
const double qg = 50.0;
const auto& well = sched.getWell("PROD", 0); const auto& well = sched.getWell("PROD", 0);
const auto& connections = well.getConnections(); const auto& connections = well.getConnections();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
xw["PROD"].connections.emplace_back(); auto& c = xw["PROD"].connections.emplace_back();
auto& c = xw["PROD"].connections.back();
c.rates.set(o::wat, qw * (float(i) + 1.)) c.rates.set(o::wat, qw * (float(i) + 1.0))
.set(o::oil, qo * (float(i) + 1.)) .set(o::oil, qo * (float(i) + 1.0))
.set(o::gas, qg * (float(i) + 1.)); .set(o::gas, qg * (float(i) + 1.0));
c.pressure = 215.; c.pressure = 215.0;
c.index = connections[i].global_index(); c.index = connections[i].global_index();
c.trans_factor = connections[i].CF(); c.trans_factor = connections[i].CF();
@ -503,7 +505,16 @@ END
sum_state.update_conn_var("PROD", "CWPR", global_index + 1, qw * (i + 1)); sum_state.update_conn_var("PROD", "CWPR", global_index + 1, qw * (i + 1));
sum_state.update_conn_var("PROD", "COPR", global_index + 1, qo * (i + 1)); sum_state.update_conn_var("PROD", "COPR", global_index + 1, qo * (i + 1));
sum_state.update_conn_var("PROD", "CGPR", global_index + 1, qg * (i + 1)); sum_state.update_conn_var("PROD", "CGPR", global_index + 1, qg * (i + 1));
sum_state.update_conn_var("PROD", "CPR", global_index + 1, 215); sum_state.update_conn_var("PROD", "CVPR", global_index + 1, qv * (i + 1));
sum_state.update_conn_var("PROD", "COPT", global_index + 1, qo * (i + 1) * 2.0);
sum_state.update_conn_var("PROD", "CWPT", global_index + 1, qw * (i + 1) * 2.0);
sum_state.update_conn_var("PROD", "CGPT", global_index + 1, qg * (i + 1) * 2.0);
sum_state.update_conn_var("PROD", "CVPT", global_index + 1, qv * (i + 1) * 2.0);
sum_state.update_conn_var("PROD", "CGOR", global_index + 1, qg / qo);
sum_state.update_conn_var("PROD", "CPR", global_index + 1, 215.0);
} }
auto seg = Opm::data::Segment {}; auto seg = Opm::data::Segment {};
@ -520,13 +531,14 @@ END
xw["WINJ"].rates.set(o::wat, 5.0); xw["WINJ"].rates.set(o::wat, 5.0);
xw["WINJ"].rates.set(o::oil, 0.0); xw["WINJ"].rates.set(o::oil, 0.0);
xw["WINJ"].rates.set(o::gas, 0.0); xw["WINJ"].rates.set(o::gas, 0.0);
qw = 7.;
const double qw = 7.0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
xw["WINJ"].connections.emplace_back(); xw["WINJ"].connections.emplace_back();
auto& c = xw["WINJ"].connections.back(); auto& c = xw["WINJ"].connections.back();
c.rates.set(o::wat, qw * (float(i) + 1.)).set(o::oil, 0.).set(o::gas, 0.); c.rates.set(o::wat, qw * (float(i) + 1.0)).set(o::oil, 0.0).set(o::gas, 0.0);
c.pressure = 218.; c.pressure = 218.0;
c.index = connections[i].global_index(); c.index = connections[i].global_index();
c.trans_factor = connections[i].CF(); c.trans_factor = connections[i].CF();
@ -534,7 +546,14 @@ END
sum_state.update_conn_var("WINJ", "CWIR", global_index+ 1, qw*(i + 1)); sum_state.update_conn_var("WINJ", "CWIR", global_index+ 1, qw*(i + 1));
sum_state.update_conn_var("WINJ", "COIR", global_index+ 1, 0.0); sum_state.update_conn_var("WINJ", "COIR", global_index+ 1, 0.0);
sum_state.update_conn_var("WINJ", "CGIR", global_index+ 1, 0.0); sum_state.update_conn_var("WINJ", "CGIR", global_index+ 1, 0.0);
sum_state.update_conn_var("WINJ", "CPR", global_index + 1, 218); sum_state.update_conn_var("WINJ", "CVIR", global_index+ 1, qv*(i + 1));
sum_state.update_conn_var("WINJ", "COIT", global_index + 1, 543.21 * (i + 1));
sum_state.update_conn_var("WINJ", "CWIT", global_index + 1, qw * (i + 1) * 2.0);
sum_state.update_conn_var("WINJ", "CGIT", global_index + 1, 9876.54 * (i + 1));
sum_state.update_conn_var("WINJ", "CVIT", global_index + 1, qv * (i + 1) * 2.0);
sum_state.update_conn_var("WINJ", "CPR", global_index + 1, 218.0);
} }
} }
} }
@ -706,34 +725,84 @@ BOOST_AUTO_TEST_CASE(Declared_Connection_Data)
// PROD well // PROD well
int connNo = 1; int connNo = 1;
auto i0 = (connNo - 1) * ih.nxconz; auto i0 = (connNo - 1) * ih.nxconz;
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilRate], BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilRate], 5.0 * (float(connNo)),
5. * (float(connNo)),
1.0e-5); // PROD - conn 1 : Surface oil rate 1.0e-5); // PROD - conn 1 : Surface oil rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate], BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate], 4.0 * (float(connNo)),
4. * (float(connNo)),
1.0e-5); // PROD - conn 1 : Surface water rate 1.0e-5); // PROD - conn 1 : Surface water rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasRate], BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasRate], 50.0 * (float(connNo)),
50. * (float(connNo)),
1.0e-5); // PROD - conn 1 : Surface gas rate 1.0e-5); // PROD - conn 1 : Surface gas rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure], 215., 1.0e-5); // PROD - conn 1 : Connection pressure BOOST_CHECK_CLOSE(xconn[i0 + Ix::ResVRate],
BOOST_CHECK_CLOSE(xconn[i0 + Ix::ResVRate], 0., 1.0e-5); // PROD - conn 1 : Reservoir volume rate 12.34 * static_cast<float>(connNo),
1.0e-5); // PROD - conn 1 : Reservoir volume rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilPrTotal],
5.0 * static_cast<float>(connNo) * 2.0,
1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WatPrTotal],
4.0 * static_cast<float>(connNo) * 2.0,
1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasPrTotal],
50.0 * static_cast<float>(connNo) * 2.0,
1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::VoidPrTotal],
12.34 * static_cast<float>(connNo) * 2.0,
1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GORatio],
50.0 / 5.0,
1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilInjTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WatInjTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasInjTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::VoidInjTotal], 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure], 215.0, 1.0e-5); // PROD - conn 1 : Connection pressure
// WINJ well // WINJ well
connNo = 3; connNo = 3;
i0 = ih.ncwmax * ih.nxconz + (connNo - 1) * ih.nxconz; i0 = ih.ncwmax * ih.nxconz + (connNo - 1) * ih.nxconz;
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate], BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate],
-7. * (float(connNo)), -7.0 * (float(connNo)),
1.0e-5); // WINJ - conn 3 : Surface water rate 1.0e-5); // WINJ - conn 3 : Surface water rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure], 218., 1.0e-5); // WINJ - conn 3 : Connection pressure BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure], 218., 1.0e-5); // WINJ - conn 3 : Connection pressure
BOOST_CHECK_CLOSE(xconn[i0 + Ix::ResVRate], 0., 1.0e-5); // WINJ - conn 3 : Reservoir volume rate BOOST_CHECK_CLOSE(xconn[i0 + Ix::ResVRate],
-12.34 * static_cast<float>(connNo),
1.0e-5); // WINJ - conn 3 : Reservoir volume rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilPrTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WatPrTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasPrTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::VoidPrTotal], 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GORatio], 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilInjTotal] , 543.21 * connNo, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WatInjTotal] , 7.0 * connNo * 2.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasInjTotal] , 9876.54 * connNo, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::VoidInjTotal], 12.34 * connNo * 2.0, 1.0e-5);
connNo = 4; connNo = 4;
i0 = ih.ncwmax * ih.nxconz + (connNo - 1) * ih.nxconz; i0 = ih.ncwmax * ih.nxconz + (connNo - 1) * ih.nxconz;
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate], BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate],
-7. * (float(connNo)), -7.0 * (float(connNo)),
1.0e-5); // WINJ - conn 3 : Surface water rate 1.0e-5); // WINJ - conn 3 : Surface water rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure], 218., 1.0e-5); // WINJ - conn 3 : Connection pressure BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure], 218., 1.0e-5); // WINJ - conn 3 : Connection pressure
BOOST_CHECK_CLOSE(xconn[i0 + Ix::ResVRate], 0., 1.0e-5); // WINJ - conn 3 : Reservoir volume rate BOOST_CHECK_CLOSE(xconn[i0 + Ix::ResVRate],
-12.34 * static_cast<float>(connNo),
1.0e-5); // WINJ - conn 3 : Reservoir volume rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilPrTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WatPrTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasPrTotal] , 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::VoidPrTotal], 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GORatio], 0.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilInjTotal] , 543.21 * connNo, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WatInjTotal] , 7.0 * connNo * 2.0, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasInjTotal] , 9876.54 * connNo, 1.0e-5);
BOOST_CHECK_CLOSE(xconn[i0 + Ix::VoidInjTotal], 12.34 * connNo * 2.0, 1.0e-5);
} }
} }

View File

@ -234,10 +234,24 @@ Opm::SummaryState sim_state(const Opm::Schedule& sched)
state.update_conn_var(well.name(), "COIR", connection.global_index() + 1, 222); state.update_conn_var(well.name(), "COIR", connection.global_index() + 1, 222);
state.update_conn_var(well.name(), "CGIR", connection.global_index() + 1, 333); state.update_conn_var(well.name(), "CGIR", connection.global_index() + 1, 333);
state.update_conn_var(well.name(), "CWIR", connection.global_index() + 1, 444); state.update_conn_var(well.name(), "CWIR", connection.global_index() + 1, 444);
state.update_conn_var(well.name(), "CVIR", connection.global_index() + 1, 555);
state.update_conn_var(well.name(), "COIT", connection.global_index() + 1, 222 * 2.0);
state.update_conn_var(well.name(), "CGIT", connection.global_index() + 1, 333 * 2.0);
state.update_conn_var(well.name(), "CWIT", connection.global_index() + 1, 444 * 2.0);
state.update_conn_var(well.name(), "CWIT", connection.global_index() + 1, 555 * 2.0);
} else { } else {
state.update_conn_var(well.name(), "COPR", connection.global_index() + 1, 555); state.update_conn_var(well.name(), "COPR", connection.global_index() + 1, 666);
state.update_conn_var(well.name(), "CGPR", connection.global_index() + 1, 666); state.update_conn_var(well.name(), "CGPR", connection.global_index() + 1, 777);
state.update_conn_var(well.name(), "CWPR", connection.global_index() + 1, 777); state.update_conn_var(well.name(), "CWPR", connection.global_index() + 1, 888);
state.update_conn_var(well.name(), "CVPR", connection.global_index() + 1, 999);
state.update_conn_var(well.name(), "CGOR", connection.global_index() + 1, 777.0 / 666.0);
state.update_conn_var(well.name(), "COPT", connection.global_index() + 1, 555 * 2.0);
state.update_conn_var(well.name(), "CGPT", connection.global_index() + 1, 666 * 2.0);
state.update_conn_var(well.name(), "CWPT", connection.global_index() + 1, 777 * 2.0);
state.update_conn_var(well.name(), "CVPT", connection.global_index() + 1, 999 * 2.0);
} }
} }
} }
@ -917,7 +931,6 @@ BOOST_AUTO_TEST_CASE(Restore_Cumulatives)
setup.es, setup.grid, setup.schedule, setup.es, setup.grid, setup.schedule,
/* extra_keys = */ {}); /* extra_keys = */ {});
// Verify that the restored summary state has all of its requisite // Verify that the restored summary state has all of its requisite
// cumulative summary vectors. // cumulative summary vectors.