From 273538e1f4e04fa987c5e9be66a1d4a0fbcfb7f3 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 16 Dec 2020 12:58:17 +0100 Subject: [PATCH] some cleanup --- opm/simulators/wells/MultisegmentWell.hpp | 3 +- .../wells/MultisegmentWell_impl.hpp | 29 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWell.hpp b/opm/simulators/wells/MultisegmentWell.hpp index f4c8edd6c..00c74d117 100644 --- a/opm/simulators/wells/MultisegmentWell.hpp +++ b/opm/simulators/wells/MultisegmentWell.hpp @@ -340,7 +340,8 @@ namespace Opm // scale the segment rates and pressure based on well rates and bhp - void scaleSegmentRatesAndPressureWithWellRatesAndPressure(WellState& well_state) const; + void scaleSegmentRatesWithWellRates(WellState& well_state) const; + void scaleSegmentPressuresWithBhp(WellState& well_state) const; // computing the accumulation term for later use in well mass equations void computeInitialSegmentFluids(const Simulator& ebos_simulator); diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index b1e0f0944..8fe543a8c 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -296,7 +296,6 @@ namespace Opm const auto& well = well_ecl_; const int well_index = index_of_well_; - const int top_segment_index = well_state.topSegmentIndex(index_of_well_); const auto& pu = phaseUsage(); const int np = well_state.numPhases(); const auto& summaryState = ebos_simulator.vanguard().summaryState(); @@ -512,7 +511,8 @@ namespace Opm // scale segment rates based on the wellRates // and segment pressure based on bhp - scaleSegmentRatesAndPressureWithWellRatesAndPressure(well_state); + scaleSegmentPressuresWithBhp(well_state); + scaleSegmentRatesWithWellRates(well_state); } @@ -522,10 +522,9 @@ namespace Opm template void MultisegmentWell:: - scaleSegmentRatesAndPressureWithWellRatesAndPressure(WellState& well_state) const + scaleSegmentRatesWithWellRates(WellState& well_state) const { const int top_segment_index = well_state.topSegmentIndex(index_of_well_); - for (int phase = 0; phase < number_of_phases_; ++phase) { const double well_phase_rate = well_state.wellRates()[number_of_phases_*index_of_well_ + phase]; const double unscaled_top_seg_rate = well_state.segRates()[number_of_phases_*top_segment_index + phase]; @@ -544,22 +543,27 @@ namespace Opm } std::vector perforation_rates(number_of_phases_ * number_of_perforations_,0.0); - for (int phase = 0; phase < number_of_phases_; ++phase) { - const double perf_phaserate_scaled = well_state.wellRates()[number_of_phases_ * index_of_well_ + phase] / sumTw; - for (int perf = 0; perf < number_of_perforations_; ++perf) { - perforation_rates[number_of_phases_ * perf + phase] = well_index_[perf] * perf_phaserate_scaled; - } + const double perf_phaserate_scaled = well_state.wellRates()[number_of_phases_ * index_of_well_ + phase] / sumTw; + for (int perf = 0; perf < number_of_perforations_; ++perf) { + perforation_rates[number_of_phases_ * perf + phase] = well_index_[perf] * perf_phaserate_scaled; } + std::vector segment_rates; WellState::calculateSegmentRates(segment_inlets_, segment_perforations_, perforation_rates, number_of_phases_, 0, segment_rates); - const int top_segment_index = well_state.topSegmentIndex(index_of_well_); std::copy(segment_rates.begin(), segment_rates.end(), well_state.segRates().begin() + number_of_phases_ * top_segment_index ); } } + } + template + void + MultisegmentWell:: + scaleSegmentPressuresWithBhp(WellState& well_state) const + { //scale segment pressures + const int top_segment_index = well_state.topSegmentIndex(index_of_well_); const double bhp = well_state.bhp()[index_of_well_]; const double unscaled_top_seg_pressure = well_state.segPress()[top_segment_index]; for (int seg = 0; seg < numberOfSegments(); ++seg) { @@ -569,7 +573,6 @@ namespace Opm } - template ConvergenceReport MultisegmentWell:: @@ -890,6 +893,7 @@ namespace Opm well_state_copy.currentProductionControls()[index_of_well_] = Well::ProducerCMode::BHP; } well_state_copy.bhp()[well_copy.index_of_well_] = bhp; + well_copy.scaleSegmentPressuresWithBhp(well_state_copy); // initialized the well rates with the potentials i.e. the well rates based on bhp const int np = number_of_phases_; @@ -898,8 +902,7 @@ namespace Opm well_state_copy.wellRates()[well_copy.index_of_well_*np + phase] = sign * well_state_copy.wellPotentials()[well_copy.index_of_well_*np + phase]; } - // we also want to adjust the segment rates and pressure - well_copy.scaleSegmentRatesAndPressureWithWellRatesAndPressure(well_state_copy); + well_copy.scaleSegmentRatesWithWellRates(well_state_copy); well_copy.calculateExplicitQuantities(ebosSimulator, well_state_copy, deferred_logger); const double dt = ebosSimulator.timeStepSize();