Add status to SingleWellState

This commit is contained in:
Joakim Hove 2021-08-04 13:50:08 +02:00
parent 75eb65efb7
commit 379e938ee1
6 changed files with 39 additions and 33 deletions

View File

@ -37,10 +37,8 @@ GlobalWellInfo::GlobalWellInfo(const Schedule& sched, std::size_t report_step, c
this->name_map.emplace( well.name(), global_well_index );
}
for (const auto& well : local_wells) {
for (const auto& well : local_wells)
this->local_map.push_back( well.seqIndex() );
this->is_injector.push_back( well.isInjector() );
}
}
@ -56,23 +54,19 @@ bool GlobalWellInfo::in_producing_group(const std::string& wname) const {
}
void GlobalWellInfo::update_group(const std::vector<Well::Status>& well_status, const std::vector<Well::InjectorCMode>& injection_cmode, const std::vector<Well::ProducerCMode>& production_cmode) {
if (well_status.size() != this->local_map.size())
throw std::logic_error("Size mismatch");
void GlobalWellInfo::update_injector(std::size_t well_index, Well::Status well_status, Well::InjectorCMode injection_cmode) {
if (well_status == Well::Status::OPEN && injection_cmode == Well::InjectorCMode::GRUP)
this->m_in_injecting_group[this->local_map[well_index]] = 1;
}
void GlobalWellInfo::update_producer(std::size_t well_index, Well::Status well_status, Well::ProducerCMode production_cmode) {
if (well_status == Well::Status::OPEN && production_cmode == Well::ProducerCMode::GRUP)
this->m_in_producing_group[this->local_map[well_index]] = 1;
}
void GlobalWellInfo::clear() {
this->m_in_injecting_group.assign(this->name_map.size(), 0);
this->m_in_producing_group.assign(this->name_map.size(), 0);
for (std::size_t well_index = 0; well_index < well_status.size(); well_index++) {
if (well_status[well_index] == Well::Status::OPEN) {
if (this->is_injector[well_index]) {
if (injection_cmode[well_index] == Well::InjectorCMode::GRUP)
this->m_in_injecting_group[this->local_map[well_index]] = 1;
} else {
if (production_cmode[well_index] == Well::ProducerCMode::GRUP)
this->m_in_producing_group[this->local_map[well_index]] = 1;
}
}
}
}

View File

@ -69,13 +69,14 @@ public:
GlobalWellInfo(const Schedule& sched, std::size_t report_step, const std::vector<Well>& local_wells);
bool in_producing_group(const std::string& wname) const;
bool in_injecting_group(const std::string& wname) const;
void update_group(const std::vector<Well::Status>& well_status, const std::vector<Well::InjectorCMode>& injection_cmode, const std::vector<Well::ProducerCMode>& production_cmode);
std::size_t well_index(const std::string& wname) const;
const std::string& well_name(std::size_t well_index) const;
void update_injector(std::size_t well_index, Well::Status well_status, Well::InjectorCMode injection_cmode);
void update_producer(std::size_t well_index, Well::Status well_status, Well::ProducerCMode production_cmode);
void clear();
private:
std::vector<std::size_t> local_map; // local_index -> global_index
std::vector<bool> is_injector; // local_index -> bool
std::map<std::string, std::size_t> name_map; // string -> global_index
std::vector<int> m_in_injecting_group; // global_index -> int/bool

View File

@ -31,6 +31,12 @@ void SingleWellState::init_timestep(const SingleWellState& other) {
if (this->producer != other.producer)
return;
if (this->status == Well::Status::SHUT)
return;
if (other.status == Well::Status::SHUT)
return;
this->bhp = other.bhp;
this->thp = other.thp;
this->temperature = other.temperature;
@ -40,10 +46,12 @@ void SingleWellState::init_timestep(const SingleWellState& other) {
void SingleWellState::shut() {
this->bhp = 0;
this->thp = 0;
this->status = Well::Status::SHUT;
}
void SingleWellState::stop() {
this->thp = 0;
this->status = Well::Status::STOP;
}
}

View File

@ -20,6 +20,7 @@
#ifndef OPM_SINGLE_WELL_STATE_HEADER_INCLUDED
#define OPM_SINGLE_WELL_STATE_HEADER_INCLUDED
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
namespace Opm {
@ -27,7 +28,7 @@ class SingleWellState {
public:
SingleWellState(bool is_producer, double temp);
Well::Status status{Well::Status::OPEN};
bool producer;
double bhp{0};
double thp{0};

View File

@ -41,7 +41,6 @@ void WellState::base_init(const std::vector<double>& cellPressures,
// clear old name mapping
this->wellMap_.clear();
this->perfdata.clear();
this->status_.clear();
this->parallel_well_info_.clear();
this->wellrates_.clear();
this->segment_state.clear();
@ -92,7 +91,6 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
double temp = well.isInjector() ? well.injectionControls(summary_state).temperature : 273.15 + 15.56;
auto& ws = this->wells_.add(well.name(), SingleWellState{well.isProducer(), temp});
this->status_.add(well.name(), Well::Status::OPEN);
this->parallel_well_info_.add(well.name(), well_info);
this->wellrates_.add(well.name(), std::vector<double>(np, 0));
this->well_potentials_.add(well.name(), std::vector<double>(np, 0));
@ -120,7 +118,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
const double global_pressure = well_info->broadcastFirstPerforationValue(local_pressure);
if (well.getStatus() == Well::Status::OPEN) {
this->status_[w] = Well::Status::OPEN;
ws.status = Well::Status::OPEN;
}
if (well.getStatus() == Well::Status::STOP) {
@ -355,7 +353,7 @@ void WellState::init(const std::vector<double>& cellPressures,
new_well.init_timestep(prev_well);
if (prevState->status_[oldIndex] == Well::Status::SHUT) {
if (prev_well.status == Well::Status::SHUT) {
// Well was shut in previous state, do not use its values.
continue;
}
@ -494,12 +492,11 @@ WellState::report(const int* globalCellIdxMap,
data::Wells res;
for( const auto& [wname, winfo]: this->wellMap() ) {
const auto well_index = winfo[ 0 ];
if ((this->status_[well_index] == Well::Status::SHUT) &&
! wasDynamicallyClosed(well_index))
const auto& ws = this->well(well_index);
if ((ws.status == Well::Status::SHUT) && !wasDynamicallyClosed(well_index))
{
continue;
}
const auto& ws = this->well(well_index);
const auto& reservoir_rates = this->well_reservoir_rates_[well_index];
const auto& well_potentials = this->well_potentials_[well_index];
@ -766,7 +763,8 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
const auto& wname = well.name();
if (prev_well_state->segment_state.has(wname)) {
if (prev_well_state->status_[wname] == Well::Status::SHUT) {
const auto& prev_ws = prev_well_state->well(wname);
if (prev_ws.status == Well::Status::SHUT) {
continue;
}
@ -833,14 +831,12 @@ void WellState::stopWell(int well_index)
{
auto& ws = this->well(well_index);
ws.stop();
this->status_[well_index] = Well::Status::STOP;
}
void WellState::shutWell(int well_index)
{
auto& ws = this->well(well_index);
ws.shut();
this->status_[well_index] = Well::Status::SHUT;
const int np = numPhases();
this->wellrates_[well_index].assign(np, 0);
@ -925,7 +921,14 @@ void WellState::communicateGroupRates(const Comm& comm)
template<class Comm>
void WellState::updateGlobalIsGrup(const Comm& comm)
{
this->global_well_info.value().update_group(this->status_.data(), this->current_injection_controls_.data(), this->current_production_controls_.data());
this->global_well_info.value().clear();
for (std::size_t well_index = 0; well_index < this->size(); well_index++) {
const auto& ws = this->well(well_index);
if (ws.producer)
this->global_well_info.value().update_producer(well_index, ws.status, this->current_production_controls_[well_index]);
else
this->global_well_info.value().update_injector(well_index, ws.status, this->current_injection_controls_[well_index]);
}
this->global_well_info.value().communicate(comm);
}

View File

@ -294,7 +294,7 @@ public:
void updateStatus(int well_index, Well::Status status);
void openWell(int well_index) {
this->status_[well_index] = Well::Status::OPEN;
this->wells_[well_index].status = Well::Status::OPEN;
}
void shutWell(int well_index);
@ -365,7 +365,6 @@ private:
bool do_glift_optimization_;
WellContainer<SingleWellState> wells_;
WellContainer<Well::Status> status_;
WellContainer<const ParallelWellInfo*> parallel_well_info_;
WellContainer<std::vector<double>> wellrates_;
PhaseUsage phase_usage_;