Merge pull request #1615 from joakim-hove/connection-testing

Connection testing
This commit is contained in:
Joakim Hove 2020-03-23 13:00:06 +01:00 committed by GitHub
commit f88d382172
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -471,21 +471,22 @@ END
}
Opm::data::WellRates wr()
Opm::data::WellRates
wr(const Opm::Schedule& sched)
{
using o = ::Opm::data::Rates::opt;
auto xw = ::Opm::data::WellRates {};
{
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;
double qo = 5.;
double qw = 4.;
double qg = 50.;
{
const auto& well = sched.getWell("PROD", 0);
const auto& connections = well.getConnections();
for (int i = 0; i < 5; i++) {
xw["PROD"].connections.emplace_back();
auto& c = xw["PROD"].connections.back();
@ -494,38 +495,43 @@ END
.set(o::oil, qo * (float(i) + 1.))
.set(o::gas, qg * (float(i) + 1.));
c.pressure = 215.;
c.index = connections[i].global_index();
}
auto seg = Opm::data::Segment {};
for (std::size_t i = 1; i < 5; i++) {
xw["PROD"].segments.insert(std::pair<std::size_t, Opm::data::Segment>(i, seg));
}
}
{
const auto& well = sched.getWell("WINJ", 0);
const auto& connections = well.getConnections();
xw["WINJ"].bhp = 234.0;
xw["WINJ"].rates.set(o::wat, 5.0);
xw["WINJ"].rates.set(o::oil, 0.0);
xw["WINJ"].rates.set(o::gas, 0.0);
qw = 7.;
for (int i = 0; i < 5; i++) {
for (int i = 0; i < 4; i++) {
xw["WINJ"].connections.emplace_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.)).set(o::oil, 0.).set(o::gas, 0.);
c.pressure = 218.;
c.index = connections[i].global_index();
}
}
}
return xw;
}
}
} // namespace
struct SimulationCase
{
struct SimulationCase {
explicit SimulationCase(const Opm::Deck& deck)
: es(deck)
, grid(deck)
, sched(deck, es)
{}
{
}
// Order requirement: 'es' must be declared/initialised before 'sched'.
Opm::EclipseState es;
@ -558,20 +564,13 @@ BOOST_AUTO_TEST_CASE (Declared_Connection_Data)
// Report Step 1: 2115-01-01 --> 2015-01-03
const auto rptStep = std::size_t {1};
const auto ih = MockIH {
static_cast<int>(simCase.sched.getWells(rptStep).size())
};
const auto ih = MockIH {static_cast<int>(simCase.sched.getWells(rptStep).size())};
BOOST_CHECK_EQUAL(ih.nwells, MockIH::Sz {2});
const Opm::data::WellRates wrc = wr();
const Opm::data::WellRates wrc = wr(simCase.sched);
auto amconn = Opm::RestartIO::Helpers::AggregateConnectionData {ih.value};
amconn.captureDeclaredConnData(simCase.sched,
simCase.grid,
simCase.es.getUnits(),
wrc,
rptStep
);
amconn.captureDeclaredConnData(simCase.sched, simCase.grid, simCase.es.getUnits(), wrc, rptStep);
// ICONN (PROD)
{
@ -639,7 +638,6 @@ BOOST_AUTO_TEST_CASE (Declared_Connection_Data)
BOOST_CHECK_EQUAL(iConn[start + Ix::ComplNum], 4); // WINJ-connection 4, Complum number
BOOST_CHECK_EQUAL(iConn[start + Ix::ConnDir], 1); // WINJ-connection 4, Connection direction
BOOST_CHECK_EQUAL(iConn[start + Ix::Segment], 0); // WINJ-connection 4, Segment ID for direction
}
// SCONN (PROD) + (WINJ)
@ -654,8 +652,10 @@ BOOST_AUTO_TEST_CASE (Declared_Connection_Data)
BOOST_CHECK_CLOSE(sconn[i0 + Ix::Diameter], 0.20, 1.0e-5); // PROD - conn 1 : diameter
BOOST_CHECK_CLOSE(sconn[i0 + Ix::EffectiveKH], 1581.13879, 1.0e-5); // PROD - conn 1 : effective kh-product
BOOST_CHECK_CLOSE(sconn[i0 + Ix::item12], 2.55826545, 1.0e-5); // PROD - conn 1 : Transmissibility factor
BOOST_CHECK_CLOSE(sconn[i0 + Ix::SegDistEnd ], 130. , 1.0e-5); // PROD - conn 1 : Distance to end of connection in segment
BOOST_CHECK_CLOSE(sconn[i0 + Ix::SegDistStart], 30. , 1.0e-5); // PROD - conn 1 : Distance to start of connection in segment
BOOST_CHECK_CLOSE(
sconn[i0 + Ix::SegDistEnd], 130., 1.0e-5); // PROD - conn 1 : Distance to end of connection in segment
BOOST_CHECK_CLOSE(
sconn[i0 + Ix::SegDistStart], 30., 1.0e-5); // PROD - conn 1 : Distance to start of connection in segment
// Well no 2 - WINJ well
connNo = 3;
@ -665,8 +665,10 @@ BOOST_AUTO_TEST_CASE (Declared_Connection_Data)
BOOST_CHECK_CLOSE(sconn[i0 + Ix::Diameter], 0.20, 1.0e-5); // WINJ - conn 3 : diameter
BOOST_CHECK_CLOSE(sconn[i0 + Ix::EffectiveKH], 1581.13879, 1.0e-5); // WINJ - conn 3 : effective kh-product
BOOST_CHECK_CLOSE(sconn[i0 + Ix::item12], 2.55826545, 1.0e-5); // WINJ - conn 3 : Transmissibility factor
BOOST_CHECK_CLOSE(sconn[i0 + Ix::SegDistEnd ], 0. , 1.0e-5); // WINJ - conn 3 : Distance to end of connection in segment
BOOST_CHECK_CLOSE(sconn[i0 + Ix::SegDistStart], 0. , 1.0e-5); // WINJ - conn 3 : Distance to start of connection in segment
BOOST_CHECK_CLOSE(
sconn[i0 + Ix::SegDistEnd], 0., 1.0e-5); // WINJ - conn 3 : Distance to end of connection in segment
BOOST_CHECK_CLOSE(
sconn[i0 + Ix::SegDistStart], 0., 1.0e-5); // WINJ - conn 3 : Distance to start of connection in segment
connNo = 4;
i0 = ih.ncwmax * ih.nsconz + (connNo - 1) * ih.nsconz;
@ -675,10 +677,10 @@ BOOST_AUTO_TEST_CASE (Declared_Connection_Data)
BOOST_CHECK_CLOSE(sconn[i0 + Ix::Diameter], 0.20, 1.0e-5); // WINJ - conn 4 : diameter
BOOST_CHECK_CLOSE(sconn[i0 + Ix::EffectiveKH], 1581.13879, 1.0e-5); // WINJ - conn 4 : effective kh-product
BOOST_CHECK_CLOSE(sconn[i0 + Ix::item12], 2.55826545, 1.0e-5); // WINJ - conn 4 : Transmissibility factor
BOOST_CHECK_CLOSE(sconn[i0 + Ix::SegDistEnd ], 0. , 1.0e-5); // WINJ - conn 4 : Distance to end of connection in segment
BOOST_CHECK_CLOSE(sconn[i0 + Ix::SegDistStart], 0. , 1.0e-5); // WINJ - conn 4 : Distance to start of connection in segment
BOOST_CHECK_CLOSE(
sconn[i0 + Ix::SegDistEnd], 0., 1.0e-5); // WINJ - conn 4 : Distance to end of connection in segment
BOOST_CHECK_CLOSE(
sconn[i0 + Ix::SegDistStart], 0., 1.0e-5); // WINJ - conn 4 : Distance to start of connection in segment
}
// XCONN (PROD) + (WINJ)
@ -691,25 +693,37 @@ BOOST_AUTO_TEST_CASE (Declared_Connection_Data)
// PROD well
int connNo = 1;
auto i0 = (connNo - 1) * ih.nxconz;
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilRate ], -units.from_si(M::liquid_surface_rate,5.*(float(connNo))) , 1.0e-5); // PROD - conn 1 : Surface oil rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate], -units.from_si(M::liquid_surface_rate,4.*(float(connNo))) , 1.0e-5); // PROD - conn 1 : Surface water rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasRate ], -units.from_si(M::gas_surface_rate, 50.*(float(connNo))) , 1.0e-5); // PROD - conn 1 : Surface gas rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure ], units.from_si(M::pressure, 215.) , 1.0e-5); // PROD - conn 1 : Connection pressure
BOOST_CHECK_CLOSE(xconn[i0 + Ix::OilRate],
-units.from_si(M::liquid_surface_rate, 5. * (float(connNo))),
1.0e-5); // PROD - conn 1 : Surface oil rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate],
-units.from_si(M::liquid_surface_rate, 4. * (float(connNo))),
1.0e-5); // PROD - conn 1 : Surface water rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::GasRate],
-units.from_si(M::gas_surface_rate, 50. * (float(connNo))),
1.0e-5); // PROD - conn 1 : Surface gas rate
BOOST_CHECK_CLOSE(
xconn[i0 + Ix::Pressure], units.from_si(M::pressure, 215.), 1.0e-5); // PROD - conn 1 : Connection pressure
BOOST_CHECK_CLOSE(xconn[i0 + Ix::ResVRate], 0., 1.0e-5); // PROD - conn 1 : Reservoir volume rate
// WINJ well
connNo = 3;
i0 = ih.ncwmax * ih.nxconz + (connNo - 1) * ih.nxconz;
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate], -units.from_si(M::liquid_surface_rate,7.*(float(connNo))) , 1.0e-5); // WINJ - conn 3 : Surface water rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure ], units.from_si(M::pressure, 218.) , 1.0e-5); // WINJ - conn 3 : Connection pressure
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate],
-units.from_si(M::liquid_surface_rate, 7. * (float(connNo))),
1.0e-5); // WINJ - conn 3 : Surface water rate
BOOST_CHECK_CLOSE(
xconn[i0 + Ix::Pressure], units.from_si(M::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
connNo = 4;
i0 = ih.ncwmax * ih.nxconz + (connNo - 1) * ih.nxconz;
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate], -units.from_si(M::liquid_surface_rate,7.*(float(connNo))) , 1.0e-5); // WINJ - conn 3 : Surface water rate
BOOST_CHECK_CLOSE(xconn[i0 + Ix::Pressure ], units.from_si(M::pressure, 218.) , 1.0e-5); // WINJ - conn 3 : Connection pressure
BOOST_CHECK_CLOSE(xconn[i0 + Ix::WaterRate],
-units.from_si(M::liquid_surface_rate, 7. * (float(connNo))),
1.0e-5); // WINJ - conn 3 : Surface water rate
BOOST_CHECK_CLOSE(
xconn[i0 + Ix::Pressure], units.from_si(M::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
}
}
@ -718,7 +732,7 @@ BOOST_AUTO_TEST_CASE(InactiveCell) {
auto simCase = SimulationCase{first_sim()};
const auto rptStep = std::size_t{1};
const auto ih = MockIH {static_cast<int>(simCase.sched.getWells(rptStep).size())};
const Opm::data::WellRates wrc = wr();
const Opm::data::WellRates wrc = wr(simCase.sched);
auto conn0 = Opm::RestartIO::Helpers::AggregateConnectionData{ih.value};
conn0.captureDeclaredConnData(simCase.sched,
simCase.grid,