Restart File: Output Well's Preferred Phase

Note: We're missing the 'LIQUID' option (integer value 4) since

    Well::getPreferredPhase()

does not return that value.

Also, while here, remove the previously misattributed IWEL[15] item.
This item is the well's preferred phase, not the prediction control.
Finally, don't assign the active control mode to the history control.
That was a mistake.
This commit is contained in:
Bård Skaflestad 2020-02-28 05:27:25 +01:00
parent 767f77e8c8
commit 9a669f5400
5 changed files with 73 additions and 32 deletions

View File

@ -69,7 +69,6 @@ struct RstWell {
int well_status;
int active_control;
int vfp_table;
int pred_requested_control;
bool allow_xflow;
int hist_requested_control;
int msw_index;

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,7 +64,6 @@ 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),
hist_requested_control( iwel[VI::IWell::HistReqWCtrl]),
msw_index( iwel[VI::IWell::MsWID]),

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,59 @@ namespace {
}
}
int preferredPhase(const Opm::Well& well)
{
using PhaseVal = VI::IWell::Value::Preferred_Phase;
if (well.isProducer()) { // Preferred phase from WELSPECS
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()))
+ '\''
};
}
}
else { // Injector. Preferred phase reset to injected phase.
using IType = Opm::InjectorType;
const auto& iprop = well.getInjectionProperties();
switch (iprop.injectorType) {
case IType::OIL: return PhaseVal::Oil;
case IType::GAS: return PhaseVal::Gas;
case IType::WATER: return PhaseVal::Water;
default:
throw std::invalid_argument {
"Unsupported Injector Type '" +
std::to_string(static_cast<int>(iprop.injectorType))
+ '\''
};
}
}
}
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 +297,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 +326,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 +342,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 +403,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>()),