Merge pull request #1522 from bska/output-preferred-phase

Restart File: Output Well's Preferred Phase
This commit is contained in:
Bård Skaflestad 2020-11-20 00:59:33 +01:00 committed by GitHub
commit f190387431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 36 deletions

View File

@ -69,8 +69,8 @@ struct RstWell {
int well_status;
int active_control;
int vfp_table;
int pred_requested_control;
bool allow_xflow;
int preferred_phase;
int hist_requested_control;
int msw_index;
int completion_ordering;

View File

@ -39,8 +39,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
Status = 10, // Well status
VFPTab = 11, // ID (one-based) of well's current VFP table.
PredReqWCtrl = 15, // Well's requested control mode from
// simulation deck (WCONINJE, WCONPROD).
PreferredPhase = 15, // Well's preferred phase (from WELSPECS)
item18 = 17, // Unknown
XFlow = 22,
@ -111,6 +110,13 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
// COMPDAT keyword.
};
enum Preferred_Phase : int {
Oil = 1,
Water = 2,
Gas = 3,
Liquid = 4,
};
enum PLossMod : int {
HFA = 0, // Components of pressure loss in MSW model for well (WELSEGS item 6)
// Hydrostatic, Friction, Acceleration

View File

@ -64,8 +64,8 @@ RstWell::RstWell(const ::Opm::UnitSystem& unit_system,
well_status( iwel[VI::IWell::Status]),
active_control( iwel[VI::IWell::ActWCtrl]),
vfp_table( iwel[VI::IWell::VFPTab]),
pred_requested_control( iwel[VI::IWell::PredReqWCtrl]),
allow_xflow( iwel[VI::IWell::XFlow] == 1),
preferred_phase( iwel[VI::IWell::PreferredPhase]),
hist_requested_control( iwel[VI::IWell::HistReqWCtrl]),
msw_index( iwel[VI::IWell::MsWID]),
completion_ordering( iwel[VI::IWell::CompOrd]),

View File

@ -27,18 +27,20 @@
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <algorithm>
#include <cassert>
@ -228,28 +230,40 @@ namespace {
}
}
int preferredPhase(const Opm::Well& well)
{
using PhaseVal = VI::IWell::Value::Preferred_Phase;
switch (well.getPreferredPhase()) {
case Opm::Phase::OIL: return PhaseVal::Oil;
case Opm::Phase::GAS: return PhaseVal::Gas;
case Opm::Phase::WATER: return PhaseVal::Water;
// Should have LIQUID here too...
default:
throw std::invalid_argument {
"Unsupported Preferred Phase '" +
std::to_string(static_cast<int>(well.getPreferredPhase()))
+ '\''
};
}
}
template <typename IWellArray>
void setCurrentControl(const Opm::Well& well,
const int curr,
IWellArray& iWell)
void setHistoryControlMode(const Opm::Well& well,
const int curr,
IWellArray& iWell)
{
using Ix = VI::IWell::index;
iWell[VI::IWell::index::HistReqWCtrl] =
well.predictionMode() ? 0 : curr;
}
iWell[Ix::ActWCtrl] = curr;
if (well.predictionMode()) {
// Well in prediction mode (WCONPROD, WCONINJE). Assign
// requested control mode for prediction.
iWell[Ix::PredReqWCtrl] = curr;
iWell[Ix::HistReqWCtrl] = 0;
}
else {
// Well controlled by observed rates/BHP (WCONHIST,
// WCONINJH). Assign requested control mode for history.
iWell[Ix::PredReqWCtrl] = 0; // Possibly =1 instead.
iWell[Ix::HistReqWCtrl] = curr;
}
template <typename IWellArray>
void setCurrentControl(const int curr,
IWellArray& iWell)
{
iWell[VI::IWell::index::ActWCtrl] = curr;
}
template <class IWellArray>
@ -264,6 +278,7 @@ namespace {
iWell[Ix::IHead] = well.getHeadI() + 1;
iWell[Ix::JHead] = well.getHeadJ() + 1;
iWell[Ix::Status] = wellStatus(well.getStatus());
// Connections
{
const auto& conn = well.getConnections();
@ -292,6 +307,8 @@ namespace {
iWell[Ix::VFPTab] = wellVFPTab(well, st);
iWell[Ix::XFlow] = well.getAllowCrossFlow() ? 1 : 0;
iWell[Ix::PreferredPhase] = preferredPhase(well);
// The following items aren't fully characterised yet, but
// needed for restart of M2. Will need further refinement.
iWell[Ix::item18] = -100;
@ -306,7 +323,8 @@ namespace {
//
// Observe that the setupCurrentContro() function is called again
// for open wells in the dynamicContrib() function.
setCurrentControl(well, eclipseControlMode(well, st), iWell);
setCurrentControl(eclipseControlMode(well, st), iWell);
setHistoryControlMode(well, eclipseControlMode(well, st), iWell);
// Multi-segmented well information
iWell[Ix::MsWID] = 0; // MS Well ID (0 or 1..#MS wells)
@ -366,7 +384,7 @@ namespace {
using Value = VI::IWell::Value::Status;
if (wellControlDefined(xw)) {
setCurrentControl(well, ctrlMode(well, xw), iWell);
setCurrentControl(ctrlMode(well, xw), iWell);
}
const auto any_flowing_conn =

View File

@ -145,7 +145,7 @@ Well::Well(const RestartIO::RstWell& rst_well,
guide_rate(def_guide_rate),
efficiency_factor(rst_well.efficiency_factor),
solvent_fraction(def_solvent_fraction),
prediction_mode(rst_well.pred_requested_control != 0),
prediction_mode(rst_well.hist_requested_control == 0),
econ_limits(std::make_shared<WellEconProductionLimits>()),
foam_properties(std::make_shared<WellFoamProperties>()),
polymer_properties(std::make_shared<WellPolymerProperties>()),

View File

@ -60,8 +60,6 @@ std::vector<T> sorted(std::vector<T> v) {
return v;
}
}
template <typename T>
int compare(const std::string& name, const T& v1, const T& v2, const std::string& fmt) {
if (v1 == v2)
@ -97,8 +95,8 @@ bool rst_cmp(const Opm::RestartIO::RstState& rst1, const Opm::RestartIO::RstStat
error_count += compare(well1.name, well1.well_status, well2.well_status, "Different status for well: {} case1: {} case2: {}");
error_count += compare(well1.name, well1.active_control, well2.active_control, "Different active_control for well: {} case1: {} case2: {}");
error_count += compare(well1.name, well1.vfp_table, well2.vfp_table, "Different vfp_table for well: {} case1: {} case2: {}");
error_count += compare(well1.name, well1.pred_requested_control, well2.pred_requested_control,"Different pred_requested_control for well: {} case1: {} case2: {}");
error_count += compare(well1.name, well1.allow_xflow, well2.allow_xflow, "Different allow_xflow for well: {} case1: {} case2: {}");
error_count += compare(well1.name, well1.preferred_phase, well2.preferred_phase, "Different preferred_phase for well: {} case1: {} case2: {}");
error_count += compare(well1.name, well1.hist_requested_control, well2.hist_requested_control,"Different hist_requested_control for well: {} case1: {} case2: {}");
error_count += compare(well1.name, well1.msw_index, well2.msw_index, "Different msw_index for well: {} case1: {} case2: {}");
error_count += compare(well1.name, well1.completion_ordering, well2.completion_ordering, "Different completion_ordering for well: {} case1: {} case2: {}");
@ -106,7 +104,7 @@ bool rst_cmp(const Opm::RestartIO::RstState& rst1, const Opm::RestartIO::RstStat
}
return error_count == 0;
}
}
using namespace Opm::EclIO;