diff --git a/opm/io/eclipse/rst/well.hpp b/opm/io/eclipse/rst/well.hpp index 33114a167..59f287dd9 100644 --- a/opm/io/eclipse/rst/well.hpp +++ b/opm/io/eclipse/rst/well.hpp @@ -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; diff --git a/opm/output/eclipse/VectorItems/well.hpp b/opm/output/eclipse/VectorItems/well.hpp index c1ceca186..406e1f073 100644 --- a/opm/output/eclipse/VectorItems/well.hpp +++ b/opm/output/eclipse/VectorItems/well.hpp @@ -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 diff --git a/src/opm/io/eclipse/rst/well.cpp b/src/opm/io/eclipse/rst/well.cpp index 402bae2e2..13c93c59a 100644 --- a/src/opm/io/eclipse/rst/well.cpp +++ b/src/opm/io/eclipse/rst/well.cpp @@ -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]), diff --git a/src/opm/output/eclipse/AggregateWellData.cpp b/src/opm/output/eclipse/AggregateWellData.cpp index ff0c4a60d..2ada40e53 100644 --- a/src/opm/output/eclipse/AggregateWellData.cpp +++ b/src/opm/output/eclipse/AggregateWellData.cpp @@ -27,18 +27,20 @@ #include #include -#include -#include -#include -#include -#include -#include #include #include +#include #include #include -#include #include +#include +#include +#include +#include +#include + +#include +#include #include #include @@ -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(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(iprop.injectorType)) + + '\'' + }; + } + } + } template - 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 + void setCurrentControl(const int curr, + IWellArray& iWell) + { + iWell[VI::IWell::index::ActWCtrl] = curr; } template @@ -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 = diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp index c9685b281..afe628dcb 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp @@ -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()), foam_properties(std::make_shared()), polymer_properties(std::make_shared()),