From 15305e467d71ed0b9a8b9707684b7e27106ba3b8 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Fri, 15 Sep 2023 15:21:19 +0200 Subject: [PATCH 1/4] Allow UDA for WSEGVALV item 4 --- opm/simulators/wells/MultisegmentWellEval.cpp | 8 +++++--- opm/simulators/wells/MultisegmentWellEval.hpp | 4 ++++ opm/simulators/wells/MultisegmentWellSegments.cpp | 9 ++++++--- opm/simulators/wells/MultisegmentWellSegments.hpp | 5 +++-- opm/simulators/wells/MultisegmentWell_impl.hpp | 3 ++- opm/simulators/wells/WellInterfaceGeneric.cpp | 5 +++++ opm/simulators/wells/WellInterfaceGeneric.hpp | 1 + 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellEval.cpp b/opm/simulators/wells/MultisegmentWellEval.cpp index faae8cf09..898a65331 100644 --- a/opm/simulators/wells/MultisegmentWellEval.cpp +++ b/opm/simulators/wells/MultisegmentWellEval.cpp @@ -264,6 +264,7 @@ MultisegmentWellEval:: assembleICDPressureEq(const int seg, const UnitSystem& unit_system, WellState& well_state, + const SummaryState& summary_state, const bool use_average_density, DeferredLogger& deferred_logger) { @@ -306,9 +307,9 @@ assembleICDPressureEq(const int seg, } break; case Segment::SegmentType::VALVE : - icd_pressure_drop = segments_.pressureDropValve(seg); + icd_pressure_drop = segments_.pressureDropValve(seg, summary_state); if (reverseFlow){ - extra_derivatives = -segments_.pressureDropValve(seg, /*extra_reverse_flow_derivatives*/ true); + extra_derivatives = -segments_.pressureDropValve(seg, summary_state, /*extra_reverse_flow_derivatives*/ true); } break; default: { @@ -380,6 +381,7 @@ MultisegmentWellEval:: assemblePressureEq(const int seg, const UnitSystem& unit_system, WellState& well_state, + const SummaryState& summary_state, const bool use_average_density, DeferredLogger& deferred_logger) { @@ -387,7 +389,7 @@ assemblePressureEq(const int seg, case Segment::SegmentType::SICD : case Segment::SegmentType::AICD : case Segment::SegmentType::VALVE : { - assembleICDPressureEq(seg, unit_system, well_state, use_average_density, deferred_logger); + assembleICDPressureEq(seg, unit_system, well_state, summary_state, use_average_density, deferred_logger); break; } default : diff --git a/opm/simulators/wells/MultisegmentWellEval.hpp b/opm/simulators/wells/MultisegmentWellEval.hpp index ddc4d8d95..464b02f43 100644 --- a/opm/simulators/wells/MultisegmentWellEval.hpp +++ b/opm/simulators/wells/MultisegmentWellEval.hpp @@ -41,6 +41,8 @@ class ConvergenceReport; class GroupState; class Schedule; class WellContributions; +class SummaryState; + template class WellInterfaceIndices; class WellState; @@ -83,6 +85,7 @@ protected: void assembleICDPressureEq(const int seg, const UnitSystem& unit_system, WellState& well_state, + const SummaryState& summary_state, const bool use_average_density, DeferredLogger& deferred_logger); @@ -94,6 +97,7 @@ protected: void assemblePressureEq(const int seg, const UnitSystem& unit_system, WellState& well_state, + const SummaryState& summary_state, const bool use_average_density, DeferredLogger& deferred_logger); diff --git a/opm/simulators/wells/MultisegmentWellSegments.cpp b/opm/simulators/wells/MultisegmentWellSegments.cpp index 965077fe8..08dcf9d11 100644 --- a/opm/simulators/wells/MultisegmentWellSegments.cpp +++ b/opm/simulators/wells/MultisegmentWellSegments.cpp @@ -769,10 +769,11 @@ template typename MultisegmentWellSegments::EvalWell MultisegmentWellSegments:: pressureDropValve(const int seg, + const SummaryState& summary_state, const bool extra_reverse_flow_derivatives /*false*/) const { - const auto& segment_set = well_.wellEcl().getSegments(); - const Valve& valve = segment_set[seg].valve(); + Opm::WellSegments& segment_set = well_.wellEcl().getSegments(); + Valve& valve = segment_set[seg].valve(); EvalWell mass_rate = mass_rates_[seg]; const int seg_upwind = upwinding_segments_[seg]; @@ -814,7 +815,9 @@ pressureDropValve(const int seg, const EvalWell friction_pressure_loss = mswellhelpers::frictionPressureLoss(additional_length, diameter, area, roughness, density, mass_rate, visc); - const double area_con = valve.conCrossArea(); + const double udq_default = 0.0; // TODO: Get this from UDQPARAMS + ValveUDAEval uda_eval {summary_state, this->well_.name(), seg, udq_default}; + const double area_con = valve.conCrossArea(uda_eval); const double cv = valve.conFlowCoefficient(); const EvalWell constriction_pressure_loss = diff --git a/opm/simulators/wells/MultisegmentWellSegments.hpp b/opm/simulators/wells/MultisegmentWellSegments.hpp index d61182b49..6144bea12 100644 --- a/opm/simulators/wells/MultisegmentWellSegments.hpp +++ b/opm/simulators/wells/MultisegmentWellSegments.hpp @@ -34,6 +34,7 @@ namespace Opm { class SegmentState; class UnitSystem; class WellInterfaceGeneric; + class SummaryState; } // namespace Opm @@ -85,8 +86,8 @@ public: // pressure drop for sub-critical valve (WSEGVALV) EvalWell pressureDropValve(const int seg, + const SummaryState& st, const bool extra_reverse_flow_derivatives = false) const; - // pressure loss due to acceleration EvalWell accelerationPressureLoss(const int seg) const; @@ -162,7 +163,7 @@ private: std::vector> phase_fractions_; std::vector> phase_viscosities_; - const WellInterfaceGeneric& well_; + WellInterfaceGeneric& well_; void copyPhaseDensities(const unsigned phaseIdx, const std::size_t stride, diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index 7acd70cdc..4d3d50675 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -1907,7 +1907,8 @@ namespace Opm deferred_logger); } else { const UnitSystem& unit_system = ebosSimulator.vanguard().eclState().getDeckUnitSystem(); - this->assemblePressureEq(seg, unit_system, well_state, this->param_.use_average_density_ms_wells_, deferred_logger); + const auto& summary_state = ebosSimulator.vanguard().summaryState(); + this->assemblePressureEq(seg, unit_system, well_state, summary_state, this->param_.use_average_density_ms_wells_, deferred_logger); } } diff --git a/opm/simulators/wells/WellInterfaceGeneric.cpp b/opm/simulators/wells/WellInterfaceGeneric.cpp index 947a33c89..a9e37b5d7 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.cpp +++ b/opm/simulators/wells/WellInterfaceGeneric.cpp @@ -174,6 +174,11 @@ const Well& WellInterfaceGeneric::wellEcl() const return well_ecl_; } +Well& WellInterfaceGeneric::wellEcl() +{ + return well_ecl_; +} + const PhaseUsage& WellInterfaceGeneric::phaseUsage() const { assert(phase_usage_ != nullptr); diff --git a/opm/simulators/wells/WellInterfaceGeneric.hpp b/opm/simulators/wells/WellInterfaceGeneric.hpp index ca38a1352..c1daaab75 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.hpp +++ b/opm/simulators/wells/WellInterfaceGeneric.hpp @@ -80,6 +80,7 @@ public: void adaptRatesForVFP(std::vector& rates) const; const Well& wellEcl() const; + Well& wellEcl(); const PhaseUsage& phaseUsage() const; /// Returns true if the well is currently in prediction mode (i.e. not history mode). From 62ac4dc6636e9e7cb82a092b94362ea4482350e4 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Thu, 21 Sep 2023 21:17:52 +0200 Subject: [PATCH 2/4] Take default UDQ value from UDQPARAM --- opm/simulators/wells/MultisegmentWellSegments.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellSegments.cpp b/opm/simulators/wells/MultisegmentWellSegments.cpp index 08dcf9d11..86d3c3e62 100644 --- a/opm/simulators/wells/MultisegmentWellSegments.cpp +++ b/opm/simulators/wells/MultisegmentWellSegments.cpp @@ -815,8 +815,7 @@ pressureDropValve(const int seg, const EvalWell friction_pressure_loss = mswellhelpers::frictionPressureLoss(additional_length, diameter, area, roughness, density, mass_rate, visc); - const double udq_default = 0.0; // TODO: Get this from UDQPARAMS - ValveUDAEval uda_eval {summary_state, this->well_.name(), seg, udq_default}; + const ValveUDAEval uda_eval {summary_state, this->well_.name(), static_cast(seg)}; const double area_con = valve.conCrossArea(uda_eval); const double cv = valve.conFlowCoefficient(); From 62de832e8b5ae1a9b887a5ba2da40b6a47800f9b Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Mon, 16 Oct 2023 10:05:01 +0200 Subject: [PATCH 3/4] Post review update --- opm/simulators/wells/MultisegmentWellSegments.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellSegments.cpp b/opm/simulators/wells/MultisegmentWellSegments.cpp index 86d3c3e62..56afd6f5d 100644 --- a/opm/simulators/wells/MultisegmentWellSegments.cpp +++ b/opm/simulators/wells/MultisegmentWellSegments.cpp @@ -772,8 +772,8 @@ pressureDropValve(const int seg, const SummaryState& summary_state, const bool extra_reverse_flow_derivatives /*false*/) const { - Opm::WellSegments& segment_set = well_.wellEcl().getSegments(); - Valve& valve = segment_set[seg].valve(); + const Opm::WellSegments& segment_set = well_.wellEcl().getSegments(); + const Valve& valve = segment_set[seg].valve(); EvalWell mass_rate = mass_rates_[seg]; const int seg_upwind = upwinding_segments_[seg]; @@ -815,7 +815,7 @@ pressureDropValve(const int seg, const EvalWell friction_pressure_loss = mswellhelpers::frictionPressureLoss(additional_length, diameter, area, roughness, density, mass_rate, visc); - const ValveUDAEval uda_eval {summary_state, this->well_.name(), static_cast(seg)}; + const ValveUDAEval uda_eval {summary_state, this->well_.name(), segment_set[seg].segmentNumber()}; const double area_con = valve.conCrossArea(uda_eval); const double cv = valve.conFlowCoefficient(); From fcc3a19a42b03bc3f5b56bb38942aef52cac8c2f Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Wed, 13 Dec 2023 14:34:36 +0100 Subject: [PATCH 4/4] Explicit cast to avoid narrowing warning. --- opm/simulators/wells/MultisegmentWellSegments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/simulators/wells/MultisegmentWellSegments.cpp b/opm/simulators/wells/MultisegmentWellSegments.cpp index 56afd6f5d..33f61b3ab 100644 --- a/opm/simulators/wells/MultisegmentWellSegments.cpp +++ b/opm/simulators/wells/MultisegmentWellSegments.cpp @@ -815,7 +815,7 @@ pressureDropValve(const int seg, const EvalWell friction_pressure_loss = mswellhelpers::frictionPressureLoss(additional_length, diameter, area, roughness, density, mass_rate, visc); - const ValveUDAEval uda_eval {summary_state, this->well_.name(), segment_set[seg].segmentNumber()}; + const ValveUDAEval uda_eval {summary_state, this->well_.name(), static_cast(segment_set[seg].segmentNumber())}; const double area_con = valve.conCrossArea(uda_eval); const double cv = valve.conFlowCoefficient();