mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Implement connection rate summation in SingleWellState
This commit is contained in:
parent
86a0662381
commit
3aaaa23ed1
@ -67,6 +67,25 @@ void SingleWellState::open() {
|
||||
this->status = Well::Status::OPEN;
|
||||
}
|
||||
|
||||
|
||||
double SingleWellState::sum_connection_rates(const std::vector<double> connection_rates) const {
|
||||
return this->parallel_info.get().sumPerfValues(connection_rates.begin(), connection_rates.end());
|
||||
}
|
||||
|
||||
double SingleWellState::sum_brine_rates() const {
|
||||
return this->sum_connection_rates(this->perf_data.brine_rates);
|
||||
}
|
||||
|
||||
|
||||
double SingleWellState::sum_polymer_rates() const {
|
||||
return this->sum_connection_rates(this->perf_data.polymer_rates);
|
||||
}
|
||||
|
||||
|
||||
double SingleWellState::sum_solvent_rates() const {
|
||||
return this->sum_connection_rates(this->perf_data.solvent_rates);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,6 +59,15 @@ public:
|
||||
void shut();
|
||||
void stop();
|
||||
void open();
|
||||
|
||||
// The sum_xxx_rates() functions sum over all connection rates of pertinent
|
||||
// types. In the case of distributed wells this involves an MPI
|
||||
// communication.
|
||||
double sum_solvent_rates() const;
|
||||
double sum_polymer_rates() const;
|
||||
double sum_brine_rates() const;
|
||||
private:
|
||||
double sum_connection_rates(const std::vector<double> connection_rates) const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -291,10 +291,10 @@ updatePrimaryVariables(const WellState& well_state, DeferredLogger& deferred_log
|
||||
}
|
||||
if constexpr (has_gfrac_variable) {
|
||||
primary_variables_[GFrac] = baseif_.scalingFactor(pu.phase_pos[Gas]) * (ws.surface_rates[pu.phase_pos[Gas]]
|
||||
- (Indices::enableSolvent ? well_state.solventWellRate(well_index) : 0.0) ) / total_well_rate ;
|
||||
- (Indices::enableSolvent ? ws.sum_solvent_rates() : 0.0) ) / total_well_rate ;
|
||||
}
|
||||
if constexpr (Indices::enableSolvent) {
|
||||
primary_variables_[SFrac] = baseif_.scalingFactor(pu.phase_pos[Gas]) * well_state.solventWellRate(well_index) / total_well_rate ;
|
||||
primary_variables_[SFrac] = baseif_.scalingFactor(pu.phase_pos[Gas]) * ws.sum_solvent_rates() / total_well_rate ;
|
||||
}
|
||||
} else { // total_well_rate == 0
|
||||
if (baseif_.isInjector()) {
|
||||
|
@ -1210,7 +1210,6 @@ namespace Opm
|
||||
const PhaseUsage& pu = phaseUsage();
|
||||
b_perf.resize(nperf * this->num_components_);
|
||||
surf_dens_perf.resize(nperf * this->num_components_);
|
||||
const int w = this->index_of_well_;
|
||||
const auto& ws = well_state.well(this->index_of_well_);
|
||||
|
||||
const bool waterPresent = FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx);
|
||||
@ -1254,7 +1253,7 @@ namespace Opm
|
||||
const double oilrate = std::abs(ws.surface_rates[pu.phase_pos[Oil]]); //in order to handle negative rates in producers
|
||||
rvmax_perf[perf] = FluidSystem::gasPvt().saturatedOilVaporizationFactor(fs.pvtRegionIndex(), temperature, p_avg);
|
||||
if (oilrate > 0) {
|
||||
const double gasrate = std::abs(ws.surface_rates[pu.phase_pos[Gas]]) - (has_solvent ? well_state.solventWellRate(w) : 0.0);
|
||||
const double gasrate = std::abs(ws.surface_rates[pu.phase_pos[Gas]]) - (has_solvent ? ws.sum_solvent_rates() : 0.0);
|
||||
double rv = 0.0;
|
||||
if (gasrate > 0) {
|
||||
rv = oilrate / gasrate;
|
||||
@ -1277,7 +1276,7 @@ namespace Opm
|
||||
const int oilpos = oilCompIdx + perf * this->num_components_;
|
||||
if (gasPresent) {
|
||||
rsmax_perf[perf] = FluidSystem::oilPvt().saturatedGasDissolutionFactor(fs.pvtRegionIndex(), temperature, p_avg);
|
||||
const double gasrate = std::abs(ws.surface_rates[pu.phase_pos[Gas]]) - (has_solvent ? well_state.solventWellRate(w) : 0.0);
|
||||
const double gasrate = std::abs(ws.surface_rates[pu.phase_pos[Gas]]) - (has_solvent ? ws.sum_solvent_rates() : 0.0);
|
||||
if (gasrate > 0) {
|
||||
const double oilrate = std::abs(ws.surface_rates[pu.phase_pos[Oil]]);
|
||||
double rs = 0.0;
|
||||
|
@ -240,11 +240,12 @@ namespace WellGroupHelpers
|
||||
if (wellEcl.getStatus() == Well::Status::SHUT)
|
||||
continue;
|
||||
|
||||
const auto& ws = wellState.well(well_index.value());
|
||||
double factor = wellEcl.getEfficiencyFactor();
|
||||
if (injector)
|
||||
rate += factor * wellState.solventWellRate(well_index.value());
|
||||
rate += factor * ws.sum_solvent_rates();
|
||||
else
|
||||
rate -= factor * wellState.solventWellRate(well_index.value());
|
||||
rate -= factor * ws.sum_solvent_rates();
|
||||
}
|
||||
return rate;
|
||||
}
|
||||
|
@ -469,15 +469,15 @@ WellState::report(const int* globalCellIdxMap,
|
||||
}
|
||||
|
||||
if (pu.has_solvent || pu.has_zFraction) {
|
||||
well.rates.set(rt::solvent, solventWellRate(well_index));
|
||||
well.rates.set(rt::solvent, ws.sum_solvent_rates());
|
||||
}
|
||||
|
||||
if (pu.has_polymer) {
|
||||
well.rates.set(rt::polymer, polymerWellRate(well_index));
|
||||
well.rates.set(rt::polymer, ws.sum_polymer_rates());
|
||||
}
|
||||
|
||||
if (pu.has_brine) {
|
||||
well.rates.set(rt::brine, brineWellRate(well_index));
|
||||
well.rates.set(rt::brine, ws.sum_brine_rates());
|
||||
}
|
||||
|
||||
if (ws.producer) {
|
||||
@ -735,31 +735,6 @@ WellState::calculateSegmentRates(const std::vector<std::vector<int>>& segment_in
|
||||
}
|
||||
}
|
||||
|
||||
double WellState::solventWellRate(const int w) const
|
||||
{
|
||||
auto& ws = this->well(w);
|
||||
const auto& perf_data = ws.perf_data;
|
||||
const auto& perf_rates_solvent = perf_data.solvent_rates;
|
||||
return ws.parallel_info.get().sumPerfValues(perf_rates_solvent.begin(), perf_rates_solvent.end());
|
||||
}
|
||||
|
||||
double WellState::polymerWellRate(const int w) const
|
||||
{
|
||||
auto& ws = this->well(w);
|
||||
const auto& perf_data = ws.perf_data;
|
||||
const auto& perf_rates_polymer = perf_data.polymer_rates;
|
||||
return ws.parallel_info.get().sumPerfValues(perf_rates_polymer.begin(), perf_rates_polymer.end());
|
||||
}
|
||||
|
||||
double WellState::brineWellRate(const int w) const
|
||||
{
|
||||
auto& ws = this->well(w);
|
||||
const auto& perf_data = ws.perf_data;
|
||||
const auto& perf_rates_brine = perf_data.brine_rates;
|
||||
return ws.parallel_info.get().sumPerfValues(perf_rates_brine.begin(), perf_rates_brine.end());
|
||||
}
|
||||
|
||||
|
||||
void WellState::stopWell(int well_index)
|
||||
{
|
||||
auto& ws = this->well(well_index);
|
||||
|
@ -132,15 +132,6 @@ public:
|
||||
static void calculateSegmentRates(const std::vector<std::vector<int>>& segment_inlets, const std::vector<std::vector<int>>&segment_perforations,
|
||||
const std::vector<double>& perforation_rates, const int np, const int segment, std::vector<double>& segment_rates);
|
||||
|
||||
/// One rate pr well
|
||||
double solventWellRate(const int w) const;
|
||||
|
||||
/// One rate pr well
|
||||
double polymerWellRate(const int w) const;
|
||||
|
||||
/// One rate pr well
|
||||
double brineWellRate(const int w) const;
|
||||
|
||||
|
||||
template<class Comm>
|
||||
void communicateGroupRates(const Comm& comm);
|
||||
|
Loading…
Reference in New Issue
Block a user