Use PerfData for perforation rates

This commit is contained in:
Joakim Hove
2021-06-06 17:09:44 +02:00
parent 76838cd8a4
commit 3010b96611
7 changed files with 26 additions and 50 deletions

View File

@@ -188,11 +188,10 @@ loadRestartData(const data::Wells& rst_wells,
well_state.wellRates(well_index)[i] = rst_well.rates.get(phs[i]);
}
auto& perf_rates = well_state.perfRates(well_index);
auto& perf_phase_rates = well_state.perfPhaseRates(well_index);
auto& perf_data = well_state.perfData(well_index);
auto& perf_pressure = perf_data.pressure;
auto& perf_rates = perf_data.rates;
auto& perf_phase_rates = perf_data.phase_rates;
const auto& old_perf_data = this->well_perf_data_[well_index];
for (std::size_t perf_index = 0; perf_index < old_perf_data.size(); perf_index++) {

View File

@@ -1536,7 +1536,8 @@ namespace Opm {
auto& well_info = *local_parallel_well_info_[wellID];
const int num_perf_this_well = well_info.communication().sum(well_perf_data_[wellID].size());
auto& perf_phase_rate = this->wellState().perfPhaseRates(wellID);
auto& perf_data = this->wellState().perfData(wellID);
auto& perf_phase_rate = perf_data.phase_rates;
for (int perf = 0; perf < num_perf_this_well; ++perf) {
const int cell_idx = well_perf_data_[wellID][perf].cell_index;

View File

@@ -1248,7 +1248,7 @@ namespace Opm
// calculating the perforation rate for each perforation that belongs to this segment
const EvalWell seg_pressure = this->getSegmentPressure(seg);
auto& perf_data = well_state.perfData(this->index_of_well_);
auto& perf_rates = well_state.perfPhaseRates(this->index_of_well_);
auto& perf_rates = perf_data.phase_rates;
auto& perf_press_state = perf_data.pressure;
for (const int perf : this->segment_perforations_[seg]) {
const int cell_idx = well_cells_[perf];

View File

@@ -202,7 +202,8 @@ namespace Opm
const int np = number_of_phases_;
std::vector<RateVector> connectionRates = connectionRates_; // Copy to get right size.
auto& perf_rates = well_state.perfPhaseRates(this->index_of_well_);
auto& perf_data = well_state.perfData(this->index_of_well_);
auto& perf_rates = perf_data.phase_rates;
for (int perf = 0; perf < number_of_perforations_; ++perf) {
// Calculate perforation quantities.
std::vector<EvalWell> cq_s(num_components_, {this->numWellEq_ + numEq, 0.0});
@@ -316,6 +317,7 @@ namespace Opm
computePerfRate(intQuants, mob, bhp, Tw, perf, allow_cf,
cq_s, perf_dis_gas_rate, perf_vap_oil_rate, deferred_logger);
auto& perf_data = well_state.perfData(this->index_of_well_);
if constexpr (has_polymer && Base::has_polymermw) {
if (this->isInjector()) {
// Store the original water flux computed from the reservoir quantities.
@@ -455,7 +457,7 @@ namespace Opm
cq_s_sm *= this->extendEval(intQuants.fluidState().saltConcentration());
}
// Note. Efficiency factor is handled in the output layer
auto& perf_rate_brine = well_state.perfRateBrine(this->index_of_well_);
auto& perf_rate_brine = perf_data.brine_rates;
perf_rate_brine[perf] = cq_s_sm.value();
cq_s_sm *= well_efficiency_factor_;
@@ -463,7 +465,6 @@ namespace Opm
}
// Store the perforation pressure for later usage.
auto& perf_data = well_state.perfData(this->index_of_well_);
perf_data.pressure[perf] = well_state.bhp(this->index_of_well_) + this->perf_pressure_diffs_[perf];
}
@@ -1133,7 +1134,8 @@ namespace Opm
const int nperf = number_of_perforations_;
const int np = number_of_phases_;
std::vector<double> perfRates(b_perf.size(),0.0);
const auto& perf_rates_state = well_state.perfPhaseRates(this->index_of_well_);
const auto& perf_data = well_state.perfData(this->index_of_well_);
const auto& perf_rates_state = perf_data.phase_rates;
for (int perf = 0; perf < nperf; ++perf) {
for (int comp = 0; comp < np; ++comp) {

View File

@@ -844,7 +844,8 @@ checkMaxRatioLimitCompletions(const WellState& well_state,
double max_ratio_completion = 0;
const int np = number_of_phases_;
const auto& perf_phase_rates = well_state.perfPhaseRates(this->index_of_well_);
const auto& perf_data = well_state.perfData(this->index_of_well_);
const auto& perf_phase_rates = perf_data.phase_rates;
// look for the worst_offending_completion
for (const auto& completion : completions_) {
std::vector<double> completion_rates(np, 0.0);

View File

@@ -44,8 +44,6 @@ void WellState::base_init(const std::vector<double>& cellPressures,
this->perf_skin_pressure_.clear();
this->perf_water_throughput_.clear();
this->perf_water_velocity_.clear();
this->perfphaserates_.clear();
this->perfRateBrine_.clear();
this->perfRateSolvent_.clear();
this->perfRatePolymer_.clear();
this->status_.clear();
@@ -109,7 +107,6 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
const int num_perf_this_well = well_info->communication().sum(well_perf_data_[w].size());
this->segment_state.add(well.name(), SegmentState{});
this->perfdata.add(well.name(), PerfData{num_perf_this_well, this->phase_usage_});
this->perfphaserates_.add(well.name(), std::vector<double>(np*num_perf_this_well, 0));
this->perf_skin_pressure_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
this->perf_water_velocity_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
this->perf_water_throughput_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
@@ -303,13 +300,12 @@ void WellState::init(const std::vector<double>& cellPressures,
const int num_perf_this_well = well_info[2];
const int global_num_perf_this_well = ecl_well.getConnections().num_open();
auto& perf_data = this->perfData(w);
auto& phase_rates = this->perfPhaseRates(w);
auto& phase_rates = perf_data.phase_rates;
for (int perf = 0; perf < num_perf_this_well; ++perf) {
if (wells_ecl[w].getStatus() == Well::Status::OPEN) {
for (int p = 0; p < this->numPhases(); ++p) {
phase_rates[this->numPhases()*perf + p] = wellRates(w)[p] / double(global_num_perf_this_well);
perf_data.phase_rates[this->numPhases()*perf + p] = wellRates(w)[p] / double(global_num_perf_this_well);
}
}
perf_data.pressure[perf] = cellPressures[well_perf_data[w][perf].cell_index];
@@ -427,16 +423,13 @@ void WellState::init(const std::vector<double>& cellPressures,
// number of perforations.
if (global_num_perf_same)
{
const auto& src_rates = prevState->perfPhaseRates(oldIndex);
auto& target_rates = this->perfPhaseRates(newIndex);
for (int perf_index = 0; perf_index < num_perf_this_well; perf_index++) {
for (int p = 0; p < np; p++) {
target_rates[perf_index*np + p] = src_rates[perf_index*np + p];
}
}
auto& perf_data = this->perfData(w);
const auto& prev_perf_data = prevState->perfData(w);
perf_data.try_assign(prev_perf_data);
} else {
const int global_num_perf_this_well = well.getConnections().num_open();
auto& target_rates = this->perfPhaseRates(newIndex);
auto& perf_data = this->perfData(w);
auto& target_rates = perf_data.phase_rates;
for (int perf_index = 0; perf_index < num_perf_this_well; perf_index++) {
for (int p = 0; p < np; ++p) {
target_rates[perf_index*np + p] = wellRates(w)[p] / double(global_num_perf_this_well);
@@ -736,7 +729,7 @@ void WellState::reportConnections(data::Well& well,
pi .at( pu.phase_pos[Gas] ) = rt::productivity_index_gas;
}
for( auto& comp : well.connections) {
const auto * rates = &this->perfPhaseRates(well_index)[np*local_comp_index];
const auto * rates = &perf_data.phase_rates[np*local_comp_index];
const auto& connPI = this->connectionProductivityIndex(well_index);
for( int i = 0; i < np; ++i ) {
@@ -748,7 +741,7 @@ void WellState::reportConnections(data::Well& well,
comp.rates.set( rt::polymer, perf_polymer_rate[local_comp_index]);
}
if ( pu.has_brine ) {
const auto& perf_brine_rate = this->perfRateBrine(well_index);
const auto& perf_brine_rate = perf_data.brine_rates;
comp.rates.set( rt::brine, perf_brine_rate[local_comp_index]);
}
if ( pu.has_solvent ) {
@@ -819,7 +812,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
"Inconsistent number of reservoir connections in well");
if (pu.phase_used[Gas]) {
auto& perf_rates = this->perfPhaseRates(w);
auto& perf_rates = perf_data.phase_rates;
const int gaspos = pu.phase_pos[Gas];
// scale the phase rates for Gas to avoid too bad initial guess for gas fraction
// it will probably benefit the standard well too, while it needs to be justified
@@ -830,7 +823,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
perf_rates[perf*np + gaspos] *= 100;
}
const auto& perf_rates = this->perfPhaseRates(w);
const auto& perf_rates = perf_data.phase_rates;
std::vector<double> perforation_rates(perf_rates.begin(), perf_rates.end());
auto& segments = this->segments(w);
@@ -928,7 +921,8 @@ double WellState::polymerWellRate(const int w) const
double WellState::brineWellRate(const int w) const
{
const auto& perf_rates_brine = this->perfRateBrine(w);
const auto& perf_data = this->perfData(w);
const auto& perf_rates_brine = perf_data.brine_rates;
return parallel_well_info_[w]->sumPerfValues(perf_rates_brine.begin(), perf_rates_brine.end());
}

View File

@@ -100,16 +100,6 @@ public:
const std::vector<std::vector<PerforationData>>& well_perf_data,
const SummaryState& summary_state);
/// One rate per phase and well connection.
std::vector<double>& perfPhaseRates(std::size_t well_index) {
return this->perfphaserates_[well_index];
}
const std::vector<double>& perfPhaseRates(std::size_t well_index) const {
return this->perfphaserates_[well_index];
}
/// One current control per injecting well.
Well::InjectorCMode currentInjectionControl(std::size_t well_index) const { return current_injection_controls_[well_index]; }
void currentInjectionControl(std::size_t well_index, Well::InjectorCMode cmode) { current_injection_controls_[well_index] = cmode; }
@@ -178,15 +168,6 @@ public:
/// One rate pr well
double polymerWellRate(const int w) const;
/// One rate pr well connection.
std::vector<double>& perfRateBrine(std::size_t well_index) {
return this->perfRateBrine_[well_index];
}
const std::vector<double>& perfRateBrine(std::size_t well_index) const {
return this->perfRateBrine_[well_index];
}
/// One rate pr well
double brineWellRate(const int w) const;
@@ -435,7 +416,6 @@ private:
PhaseUsage phase_usage_;
WellContainer<PerfData> perfdata;
WellContainer<std::vector<double>> perfphaserates_;
WellContainer<int> is_producer_; // Size equal to number of local wells.
// vector with size number of wells +1.
@@ -454,7 +434,6 @@ private:
// only for output
WellContainer<std::vector<double>> perfRatePolymer_;
WellContainer<std::vector<double>> perfRateBrine_;
// it is the throughput of water flow through the perforations
// it is used as a measure of formation damage around well-bore due to particle deposition