mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Use SingleWellState to manage well surface rates
This commit is contained in:
@@ -434,7 +434,7 @@ protected:
|
|||||||
// occasionally significant different from the sum over connections (as calculated above). Only observed
|
// occasionally significant different from the sum over connections (as calculated above). Only observed
|
||||||
// for small values, neglible for the rate itself, but matters when used to calculate tracer concentrations.
|
// for small values, neglible for the rate itself, but matters when used to calculate tracer concentrations.
|
||||||
std::size_t well_index = simulator_.problem().wellModel().wellState().wellIndex(well.name());
|
std::size_t well_index = simulator_.problem().wellModel().wellState().wellIndex(well.name());
|
||||||
Scalar official_well_rate_total = simulator_.problem().wellModel().wellState().wellRates(well_index)[tr.phaseIdx_];
|
Scalar official_well_rate_total = simulator_.problem().wellModel().wellState().well(well_index).surface_rates[tr.phaseIdx_];
|
||||||
|
|
||||||
rateWellTotal = official_well_rate_total;
|
rateWellTotal = official_well_rate_total;
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ loadRestartData(const data::Wells& rst_wells,
|
|||||||
|
|
||||||
for( size_t i = 0; i < phs.size(); ++i ) {
|
for( size_t i = 0; i < phs.size(); ++i ) {
|
||||||
assert( rst_well.rates.has( phs[ i ] ) );
|
assert( rst_well.rates.has( phs[ i ] ) );
|
||||||
well_state.wellRates(well_index)[i] = rst_well.rates.get(phs[i]);
|
ws.surface_rates[i] = rst_well.rates.get(phs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& perf_data = well_state.perfData(well_index);
|
auto& perf_data = well_state.perfData(well_index);
|
||||||
@@ -1173,7 +1173,7 @@ getGuideRateValues(const Well& well) const
|
|||||||
auto grval = data::GuideRateValue{};
|
auto grval = data::GuideRateValue{};
|
||||||
|
|
||||||
const auto& wname = well.name();
|
const auto& wname = well.name();
|
||||||
if (!this->wellState().hasWellRates(wname)) {
|
if (!this->wellState().has(wname)) {
|
||||||
// No flow rates for 'wname' -- might be before well comes
|
// No flow rates for 'wname' -- might be before well comes
|
||||||
// online (e.g., for the initial condition before simulation
|
// online (e.g., for the initial condition before simulation
|
||||||
// starts).
|
// starts).
|
||||||
@@ -1333,7 +1333,7 @@ calculateAllGroupGuiderates(const int reportStepIdx) const
|
|||||||
// group tree (FIELD group).
|
// group tree (FIELD group).
|
||||||
|
|
||||||
for (const auto& wname : schedule_.wellNames(reportStepIdx)) {
|
for (const auto& wname : schedule_.wellNames(reportStepIdx)) {
|
||||||
if (! (this->wellState().hasWellRates(wname) &&
|
if (! (this->wellState().has(wname) &&
|
||||||
this->guideRate_.has(wname)))
|
this->guideRate_.has(wname)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -300,7 +300,8 @@ GasLiftGroupInfo::
|
|||||||
getProducerWellRates_(int well_index)
|
getProducerWellRates_(int well_index)
|
||||||
{
|
{
|
||||||
const auto& pu = this->phase_usage_;
|
const auto& pu = this->phase_usage_;
|
||||||
const auto& wrate = this->well_state_.wellRates(well_index);
|
const auto& ws= this->well_state_.well(well_index);
|
||||||
|
const auto& wrate = ws.surface_rates;
|
||||||
|
|
||||||
const auto oil_rate = pu.phase_used[Oil]
|
const auto oil_rate = pu.phase_used[Oil]
|
||||||
? -wrate[pu.phase_pos[Oil]]
|
? -wrate[pu.phase_pos[Oil]]
|
||||||
|
|||||||
@@ -404,11 +404,10 @@ GasLiftStage2::
|
|||||||
getStdWellRates_(const WellInterfaceGeneric &well)
|
getStdWellRates_(const WellInterfaceGeneric &well)
|
||||||
{
|
{
|
||||||
const int well_index = well.indexOfWell();
|
const int well_index = well.indexOfWell();
|
||||||
|
const auto& ws = this->well_state_.well(well_index);
|
||||||
const auto& pu = well.phaseUsage();
|
const auto& pu = well.phaseUsage();
|
||||||
auto oil_rate =
|
auto oil_rate = -ws.surface_rates[pu.phase_pos[Oil]];
|
||||||
-this->well_state_.wellRates(well_index)[pu.phase_pos[Oil]];
|
auto gas_rate = -ws.surface_rates[pu.phase_pos[Gas]];
|
||||||
auto gas_rate =
|
|
||||||
-this->well_state_.wellRates(well_index)[pu.phase_pos[Gas]];
|
|
||||||
return {oil_rate, gas_rate};
|
return {oil_rate, gas_rate};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1473,11 +1473,11 @@ updateThp(WellState& well_state,
|
|||||||
static constexpr int Gas = BlackoilPhases::Vapour;
|
static constexpr int Gas = BlackoilPhases::Vapour;
|
||||||
static constexpr int Oil = BlackoilPhases::Liquid;
|
static constexpr int Oil = BlackoilPhases::Liquid;
|
||||||
static constexpr int Water = BlackoilPhases::Aqua;
|
static constexpr int Water = BlackoilPhases::Aqua;
|
||||||
|
auto& ws = well_state.well(baseif_.indexOfWell());
|
||||||
|
|
||||||
// When there is no vaild VFP table provided, we set the thp to be zero.
|
// When there is no vaild VFP table provided, we set the thp to be zero.
|
||||||
if (!baseif_.isVFPActive(deferred_logger) || baseif_.wellIsStopped()) {
|
if (!baseif_.isVFPActive(deferred_logger) || baseif_.wellIsStopped()) {
|
||||||
auto& well = well_state.well(baseif_.indexOfWell());
|
ws.thp = 0;
|
||||||
well.thp = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1486,18 +1486,16 @@ updateThp(WellState& well_state,
|
|||||||
|
|
||||||
const PhaseUsage& pu = baseif_.phaseUsage();
|
const PhaseUsage& pu = baseif_.phaseUsage();
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||||
rates[ Water ] = well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[ Water ] ];
|
rates[ Water ] = ws.surface_rates[pu.phase_pos[ Water ] ];
|
||||||
}
|
}
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
||||||
rates[ Oil ] = well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[ Oil ] ];
|
rates[ Oil ] = ws.surface_rates[pu.phase_pos[ Oil ] ];
|
||||||
}
|
}
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||||
rates[ Gas ] = well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[ Gas ] ];
|
rates[ Gas ] = ws.surface_rates[pu.phase_pos[ Gas ] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& well = well_state.well(baseif_.indexOfWell());
|
ws.thp = this->calculateThpFromBhp(rates, ws.bhp, rho, deferred_logger);
|
||||||
const double bhp = well.bhp;
|
|
||||||
well.thp = this->calculateThpFromBhp(rates, bhp, rho, deferred_logger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename FluidSystem, typename Indices, typename Scalar>
|
template<typename FluidSystem, typename Indices, typename Scalar>
|
||||||
@@ -1657,7 +1655,7 @@ updateWellStateFromPrimaryVariables(WellState& well_state,
|
|||||||
const double phase_rate = g_total * fractions[p];
|
const double phase_rate = g_total * fractions[p];
|
||||||
segment_rates[seg*baseif_.numPhases() + p] = phase_rate;
|
segment_rates[seg*baseif_.numPhases() + p] = phase_rate;
|
||||||
if (seg == 0) { // top segment
|
if (seg == 0) { // top segment
|
||||||
well_state.wellRates(baseif_.indexOfWell())[p] = phase_rate;
|
ws.surface_rates[p] = phase_rate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ scaleSegmentRatesWithWellRates(WellState& well_state) const
|
|||||||
auto& segment_rates = segments.rates;
|
auto& segment_rates = segments.rates;
|
||||||
for (int phase = 0; phase < baseif_.numPhases(); ++phase) {
|
for (int phase = 0; phase < baseif_.numPhases(); ++phase) {
|
||||||
const double unscaled_top_seg_rate = segment_rates[phase];
|
const double unscaled_top_seg_rate = segment_rates[phase];
|
||||||
const double well_phase_rate = well_state.wellRates(baseif_.indexOfWell())[phase];
|
const double well_phase_rate = ws.surface_rates[phase];
|
||||||
if (std::abs(unscaled_top_seg_rate) > 1e-12)
|
if (std::abs(unscaled_top_seg_rate) > 1e-12)
|
||||||
{
|
{
|
||||||
for (int seg = 0; seg < numberOfSegments(); ++seg) {
|
for (int seg = 0; seg < numberOfSegments(); ++seg) {
|
||||||
@@ -120,7 +120,7 @@ scaleSegmentRatesWithWellRates(WellState& well_state) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> perforation_rates(baseif_.numPhases() * baseif_.numPerfs(),0.0);
|
std::vector<double> perforation_rates(baseif_.numPhases() * baseif_.numPerfs(),0.0);
|
||||||
const double perf_phaserate_scaled = well_state.wellRates(baseif_.indexOfWell())[phase] / sumTw;
|
const double perf_phaserate_scaled = ws.surface_rates[phase] / sumTw;
|
||||||
for (int perf = 0; perf < baseif_.numPerfs(); ++perf) {
|
for (int perf = 0; perf < baseif_.numPerfs(); ++perf) {
|
||||||
perforation_rates[baseif_.numPhases()* perf + phase] = baseif_.wellIndex()[perf] * perf_phaserate_scaled;
|
perforation_rates[baseif_.numPhases()* perf + phase] = baseif_.wellIndex()[perf] * perf_phaserate_scaled;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,14 +279,14 @@ namespace Opm
|
|||||||
|
|
||||||
double total_rate = 0.0;
|
double total_rate = 0.0;
|
||||||
for (int phase = 0; phase < np; ++phase){
|
for (int phase = 0; phase < np; ++phase){
|
||||||
total_rate += well_state.wellRates(index_of_well_)[phase];
|
total_rate += ws.surface_rates[phase];
|
||||||
}
|
}
|
||||||
// for pressure controlled wells the well rates are the potentials
|
// for pressure controlled wells the well rates are the potentials
|
||||||
// if the rates are trivial we are most probably looking at the newly
|
// if the rates are trivial we are most probably looking at the newly
|
||||||
// opened well and we therefore make the affort of computing the potentials anyway.
|
// opened well and we therefore make the affort of computing the potentials anyway.
|
||||||
if (std::abs(total_rate) > 0) {
|
if (std::abs(total_rate) > 0) {
|
||||||
for (int phase = 0; phase < np; ++phase){
|
for (int phase = 0; phase < np; ++phase){
|
||||||
well_potentials[phase] = well_state.wellRates(index_of_well_)[phase];
|
well_potentials[phase] = ws.surface_rates[phase];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -367,7 +367,7 @@ namespace Opm
|
|||||||
const int np = number_of_phases_;
|
const int np = number_of_phases_;
|
||||||
const double sign = well_copy.well_ecl_.isInjector() ? 1.0 : -1.0;
|
const double sign = well_copy.well_ecl_.isInjector() ? 1.0 : -1.0;
|
||||||
for (int phase = 0; phase < np; ++phase){
|
for (int phase = 0; phase < np; ++phase){
|
||||||
well_state_copy.wellRates(well_copy.index_of_well_)[phase] = sign * ws.well_potentials[phase];
|
ws.surface_rates[phase] = sign * ws.well_potentials[phase];
|
||||||
}
|
}
|
||||||
well_copy.scaleSegmentRatesWithWellRates(well_state_copy);
|
well_copy.scaleSegmentRatesWithWellRates(well_state_copy);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ SingleWellState::SingleWellState(bool is_producer, std::size_t num_phases, doubl
|
|||||||
, temperature(temp)
|
, temperature(temp)
|
||||||
, well_potentials(num_phases)
|
, well_potentials(num_phases)
|
||||||
, productivity_index(num_phases)
|
, productivity_index(num_phases)
|
||||||
|
, surface_rates(num_phases)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,6 +50,8 @@ void SingleWellState::shut() {
|
|||||||
this->bhp = 0;
|
this->bhp = 0;
|
||||||
this->thp = 0;
|
this->thp = 0;
|
||||||
this->status = Well::Status::SHUT;
|
this->status = Well::Status::SHUT;
|
||||||
|
std::fill(this->surface_rates.begin(), this->surface_rates.end(), 0);
|
||||||
|
std::fill(this->productivity_index.begin(), this->productivity_index.end(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleWellState::stop() {
|
void SingleWellState::stop() {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public:
|
|||||||
double vaporized_oil_rate{0};
|
double vaporized_oil_rate{0};
|
||||||
std::vector<double> well_potentials;
|
std::vector<double> well_potentials;
|
||||||
std::vector<double> productivity_index;
|
std::vector<double> productivity_index;
|
||||||
|
std::vector<double> surface_rates;
|
||||||
SegmentState segments;
|
SegmentState segments;
|
||||||
Events events;
|
Events events;
|
||||||
Well::InjectorCMode injection_cmode{Well::InjectorCMode::CMODE_UNDEFINED};
|
Well::InjectorCMode injection_cmode{Well::InjectorCMode::CMODE_UNDEFINED};
|
||||||
|
|||||||
@@ -255,11 +255,11 @@ updatePrimaryVariables(const WellState& well_state, DeferredLogger& deferred_log
|
|||||||
const int well_index = baseif_.indexOfWell();
|
const int well_index = baseif_.indexOfWell();
|
||||||
const int np = baseif_.numPhases();
|
const int np = baseif_.numPhases();
|
||||||
const auto& pu = baseif_.phaseUsage();
|
const auto& pu = baseif_.phaseUsage();
|
||||||
const auto& well = well_state.well(well_index);
|
const auto& ws = well_state.well(well_index);
|
||||||
// the weighted total well rate
|
// the weighted total well rate
|
||||||
double total_well_rate = 0.0;
|
double total_well_rate = 0.0;
|
||||||
for (int p = 0; p < np; ++p) {
|
for (int p = 0; p < np; ++p) {
|
||||||
total_well_rate += baseif_.scalingFactor(p) * well_state.wellRates(well_index)[p];
|
total_well_rate += baseif_.scalingFactor(p) * ws.surface_rates[p];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not: for the moment, the first primary variable for the injectors is not G_total. The injection rate
|
// Not: for the moment, the first primary variable for the injectors is not G_total. The injection rate
|
||||||
@@ -267,13 +267,13 @@ updatePrimaryVariables(const WellState& well_state, DeferredLogger& deferred_log
|
|||||||
if (baseif_.isInjector()) {
|
if (baseif_.isInjector()) {
|
||||||
switch (baseif_.wellEcl().injectorType()) {
|
switch (baseif_.wellEcl().injectorType()) {
|
||||||
case InjectorType::WATER:
|
case InjectorType::WATER:
|
||||||
primary_variables_[WQTotal] = well_state.wellRates(well_index)[pu.phase_pos[Water]];
|
primary_variables_[WQTotal] = ws.surface_rates[pu.phase_pos[Water]];
|
||||||
break;
|
break;
|
||||||
case InjectorType::GAS:
|
case InjectorType::GAS:
|
||||||
primary_variables_[WQTotal] = well_state.wellRates(well_index)[pu.phase_pos[Gas]];
|
primary_variables_[WQTotal] = ws.surface_rates[pu.phase_pos[Gas]];
|
||||||
break;
|
break;
|
||||||
case InjectorType::OIL:
|
case InjectorType::OIL:
|
||||||
primary_variables_[WQTotal] = well_state.wellRates(well_index)[pu.phase_pos[Oil]];
|
primary_variables_[WQTotal] = ws.surface_rates[pu.phase_pos[Oil]];
|
||||||
break;
|
break;
|
||||||
case InjectorType::MULTI:
|
case InjectorType::MULTI:
|
||||||
// Not supported.
|
// Not supported.
|
||||||
@@ -287,10 +287,10 @@ updatePrimaryVariables(const WellState& well_state, DeferredLogger& deferred_log
|
|||||||
|
|
||||||
if (std::abs(total_well_rate) > 0.) {
|
if (std::abs(total_well_rate) > 0.) {
|
||||||
if constexpr (has_wfrac_variable) {
|
if constexpr (has_wfrac_variable) {
|
||||||
primary_variables_[WFrac] = baseif_.scalingFactor(pu.phase_pos[Water]) * well_state.wellRates(well_index)[pu.phase_pos[Water]] / total_well_rate;
|
primary_variables_[WFrac] = baseif_.scalingFactor(pu.phase_pos[Water]) * ws.surface_rates[pu.phase_pos[Water]] / total_well_rate;
|
||||||
}
|
}
|
||||||
if constexpr (has_gfrac_variable) {
|
if constexpr (has_gfrac_variable) {
|
||||||
primary_variables_[GFrac] = baseif_.scalingFactor(pu.phase_pos[Gas]) * (well_state.wellRates(well_index)[pu.phase_pos[Gas]]
|
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 ? well_state.solventWellRate(well_index) : 0.0) ) / total_well_rate ;
|
||||||
}
|
}
|
||||||
if constexpr (Indices::enableSolvent) {
|
if constexpr (Indices::enableSolvent) {
|
||||||
@@ -342,7 +342,7 @@ updatePrimaryVariables(const WellState& well_state, DeferredLogger& deferred_log
|
|||||||
|
|
||||||
|
|
||||||
// BHP
|
// BHP
|
||||||
primary_variables_[Bhp] = well.bhp;
|
primary_variables_[Bhp] = ws.bhp;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class FluidSystem, class Indices, class Scalar>
|
template<class FluidSystem, class Indices, class Scalar>
|
||||||
@@ -556,11 +556,11 @@ updateThp(WellState& well_state,
|
|||||||
static constexpr int Gas = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Gas;
|
static constexpr int Gas = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Gas;
|
||||||
static constexpr int Oil = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Oil;
|
static constexpr int Oil = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Oil;
|
||||||
static constexpr int Water = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Water;
|
static constexpr int Water = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Water;
|
||||||
auto& well = well_state.well(baseif_.indexOfWell());
|
auto& ws = well_state.well(baseif_.indexOfWell());
|
||||||
|
|
||||||
// When there is no vaild VFP table provided, we set the thp to be zero.
|
// When there is no vaild VFP table provided, we set the thp to be zero.
|
||||||
if (!baseif_.isVFPActive(deferred_logger) || baseif_.wellIsStopped()) {
|
if (!baseif_.isVFPActive(deferred_logger) || baseif_.wellIsStopped()) {
|
||||||
well.thp = 0;
|
ws.thp = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,20 +569,18 @@ updateThp(WellState& well_state,
|
|||||||
|
|
||||||
const PhaseUsage& pu = baseif_.phaseUsage();
|
const PhaseUsage& pu = baseif_.phaseUsage();
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||||
rates[ Water ] = well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[ Water ] ];
|
rates[ Water ] = ws.surface_rates[pu.phase_pos[ Water ] ];
|
||||||
}
|
}
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
||||||
rates[ Oil ] = well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[ Oil ] ];
|
rates[ Oil ] = ws.surface_rates[pu.phase_pos[ Oil ] ];
|
||||||
}
|
}
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||||
rates[ Gas ] = well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[ Gas ] ];
|
rates[ Gas ] = ws.surface_rates[pu.phase_pos[ Gas ] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
const double bhp = well.bhp;
|
ws.thp = this->calculateThpFromBhp(well_state,
|
||||||
|
|
||||||
well.thp = this->calculateThpFromBhp(well_state,
|
|
||||||
rates,
|
rates,
|
||||||
bhp,
|
ws.bhp,
|
||||||
deferred_logger);
|
deferred_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,29 +653,29 @@ updateWellStateFromPrimaryVariables(WellState& well_state,
|
|||||||
F[pu.phase_pos[Gas]] += F_solvent;
|
F[pu.phase_pos[Gas]] += F_solvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& well = well_state.well(baseif_.indexOfWell());
|
auto& ws = well_state.well(baseif_.indexOfWell());
|
||||||
well.bhp = primary_variables_[Bhp];
|
ws.bhp = primary_variables_[Bhp];
|
||||||
|
|
||||||
// calculate the phase rates based on the primary variables
|
// calculate the phase rates based on the primary variables
|
||||||
// for producers, this is not a problem, while not sure for injectors here
|
// for producers, this is not a problem, while not sure for injectors here
|
||||||
if (baseif_.isProducer()) {
|
if (baseif_.isProducer()) {
|
||||||
const double g_total = primary_variables_[WQTotal];
|
const double g_total = primary_variables_[WQTotal];
|
||||||
for (int p = 0; p < baseif_.numPhases(); ++p) {
|
for (int p = 0; p < baseif_.numPhases(); ++p) {
|
||||||
well_state.wellRates(baseif_.indexOfWell())[p] = g_total * F[p];
|
ws.surface_rates[p] = g_total * F[p];
|
||||||
}
|
}
|
||||||
} else { // injectors
|
} else { // injectors
|
||||||
for (int p = 0; p < baseif_.numPhases(); ++p) {
|
for (int p = 0; p < baseif_.numPhases(); ++p) {
|
||||||
well_state.wellRates(baseif_.indexOfWell())[p] = 0.0;
|
ws.surface_rates[p] = 0.0;
|
||||||
}
|
}
|
||||||
switch (baseif_.wellEcl().injectorType()) {
|
switch (baseif_.wellEcl().injectorType()) {
|
||||||
case InjectorType::WATER:
|
case InjectorType::WATER:
|
||||||
well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[Water]] = primary_variables_[WQTotal];
|
ws.surface_rates[pu.phase_pos[Water]] = primary_variables_[WQTotal];
|
||||||
break;
|
break;
|
||||||
case InjectorType::GAS:
|
case InjectorType::GAS:
|
||||||
well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[Gas]] = primary_variables_[WQTotal];
|
ws.surface_rates[pu.phase_pos[Gas]] = primary_variables_[WQTotal];
|
||||||
break;
|
break;
|
||||||
case InjectorType::OIL:
|
case InjectorType::OIL:
|
||||||
well_state.wellRates(baseif_.indexOfWell())[pu.phase_pos[Oil]] = primary_variables_[WQTotal];
|
ws.surface_rates[pu.phase_pos[Oil]] = primary_variables_[WQTotal];
|
||||||
break;
|
break;
|
||||||
case InjectorType::MULTI:
|
case InjectorType::MULTI:
|
||||||
// Not supported.
|
// Not supported.
|
||||||
|
|||||||
@@ -1252,10 +1252,10 @@ namespace Opm
|
|||||||
const int gaspos = gasCompIdx + perf * num_components_;
|
const int gaspos = gasCompIdx + perf * num_components_;
|
||||||
|
|
||||||
if (oilPresent) {
|
if (oilPresent) {
|
||||||
const double oilrate = std::abs(well_state.wellRates(w)[pu.phase_pos[Oil]]); //in order to handle negative rates in producers
|
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);
|
rvmax_perf[perf] = FluidSystem::gasPvt().saturatedOilVaporizationFactor(fs.pvtRegionIndex(), temperature, p_avg);
|
||||||
if (oilrate > 0) {
|
if (oilrate > 0) {
|
||||||
const double gasrate = std::abs(well_state.wellRates(w)[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 ? well_state.solventWellRate(w) : 0.0);
|
||||||
double rv = 0.0;
|
double rv = 0.0;
|
||||||
if (gasrate > 0) {
|
if (gasrate > 0) {
|
||||||
rv = oilrate / gasrate;
|
rv = oilrate / gasrate;
|
||||||
@@ -1278,9 +1278,9 @@ namespace Opm
|
|||||||
const int oilpos = oilCompIdx + perf * num_components_;
|
const int oilpos = oilCompIdx + perf * num_components_;
|
||||||
if (gasPresent) {
|
if (gasPresent) {
|
||||||
rsmax_perf[perf] = FluidSystem::oilPvt().saturatedGasDissolutionFactor(fs.pvtRegionIndex(), temperature, p_avg);
|
rsmax_perf[perf] = FluidSystem::oilPvt().saturatedGasDissolutionFactor(fs.pvtRegionIndex(), temperature, p_avg);
|
||||||
const double gasrate = std::abs(well_state.wellRates(w)[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 ? well_state.solventWellRate(w) : 0.0);
|
||||||
if (gasrate > 0) {
|
if (gasrate > 0) {
|
||||||
const double oilrate = std::abs(well_state.wellRates(w)[pu.phase_pos[Oil]]);
|
const double oilrate = std::abs(ws.surface_rates[pu.phase_pos[Oil]]);
|
||||||
double rs = 0.0;
|
double rs = 0.0;
|
||||||
if (oilrate > 0) {
|
if (oilrate > 0) {
|
||||||
rs = gasrate / oilrate;
|
rs = gasrate / oilrate;
|
||||||
@@ -1862,14 +1862,14 @@ namespace Opm
|
|||||||
|
|
||||||
double total_rate = 0.0;
|
double total_rate = 0.0;
|
||||||
for (int phase = 0; phase < np; ++phase){
|
for (int phase = 0; phase < np; ++phase){
|
||||||
total_rate += well_state.wellRates(index_of_well_)[phase];
|
total_rate += ws.surface_rates[phase];
|
||||||
}
|
}
|
||||||
// for pressure controlled wells the well rates are the potentials
|
// for pressure controlled wells the well rates are the potentials
|
||||||
// if the rates are trivial we are most probably looking at the newly
|
// if the rates are trivial we are most probably looking at the newly
|
||||||
// opened well and we therefore make the affort of computing the potentials anyway.
|
// opened well and we therefore make the affort of computing the potentials anyway.
|
||||||
if (std::abs(total_rate) > 0) {
|
if (std::abs(total_rate) > 0) {
|
||||||
for (int phase = 0; phase < np; ++phase){
|
for (int phase = 0; phase < np; ++phase){
|
||||||
well_potentials[phase] = well_state.wellRates(index_of_well_)[phase];
|
well_potentials[phase] = ws.surface_rates[phase];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ namespace {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
double factor = wellEcl.getEfficiencyFactor();
|
double factor = wellEcl.getEfficiencyFactor();
|
||||||
|
const auto& ws = wellState.well(well_index);
|
||||||
if (res_rates) {
|
if (res_rates) {
|
||||||
const auto& well_rates = wellState.wellReservoirRates(well_index);
|
const auto& well_rates = wellState.wellReservoirRates(well_index);
|
||||||
if (injector)
|
if (injector)
|
||||||
@@ -104,7 +105,7 @@ namespace {
|
|||||||
else
|
else
|
||||||
rate -= factor * well_rates[phasePos];
|
rate -= factor * well_rates[phasePos];
|
||||||
} else {
|
} else {
|
||||||
const auto& well_rates = wellState.wellRates(well_index);
|
const auto& well_rates = ws.surface_rates;
|
||||||
if (injector)
|
if (injector)
|
||||||
rate += factor * well_rates[phasePos];
|
rate += factor * well_rates[phasePos];
|
||||||
else
|
else
|
||||||
@@ -414,16 +415,17 @@ namespace WellGroupHelpers
|
|||||||
|
|
||||||
const double efficiency = wellTmp.getEfficiencyFactor();
|
const double efficiency = wellTmp.getEfficiencyFactor();
|
||||||
// add contributino from wells not under group control
|
// add contributino from wells not under group control
|
||||||
|
const auto& ws_nupcol = wellStateNupcol.well(well_index);
|
||||||
const auto& ws = wellState.well(well_index);
|
const auto& ws = wellState.well(well_index);
|
||||||
if (isInjector) {
|
if (isInjector) {
|
||||||
if (ws.injection_cmode != Well::InjectorCMode::GRUP)
|
if (ws.injection_cmode != Well::InjectorCMode::GRUP)
|
||||||
for (int phase = 0; phase < np; phase++) {
|
for (int phase = 0; phase < np; phase++) {
|
||||||
groupTargetReduction[phase] += wellStateNupcol.wellRates(well_index)[phase] * efficiency;
|
groupTargetReduction[phase] += ws_nupcol.surface_rates[phase] * efficiency;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ws.production_cmode != Well::ProducerCMode::GRUP)
|
if (ws.production_cmode != Well::ProducerCMode::GRUP)
|
||||||
for (int phase = 0; phase < np; phase++) {
|
for (int phase = 0; phase < np; phase++) {
|
||||||
groupTargetReduction[phase] -= wellStateNupcol.wellRates(well_index)[phase] * efficiency;
|
groupTargetReduction[phase] -= ws_nupcol.surface_rates[phase] * efficiency;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -487,16 +489,16 @@ namespace WellGroupHelpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// scale rates
|
// scale rates
|
||||||
const auto& ws = wellState.well(well_index);
|
auto& ws = wellState.well(well_index);
|
||||||
if (isInjector) {
|
if (isInjector) {
|
||||||
if (ws.injection_cmode == Well::InjectorCMode::GRUP)
|
if (ws.injection_cmode == Well::InjectorCMode::GRUP)
|
||||||
for (int phase = 0; phase < np; phase++) {
|
for (int phase = 0; phase < np; phase++) {
|
||||||
wellState.wellRates(well_index)[phase] *= scale;
|
ws.surface_rates[phase] *= scale;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ws.production_cmode == Well::ProducerCMode::GRUP)
|
if (ws.production_cmode == Well::ProducerCMode::GRUP)
|
||||||
for (int phase = 0; phase < np; phase++) {
|
for (int phase = 0; phase < np; phase++) {
|
||||||
wellState.wellRates(well_index)[phase] *= scale;
|
ws.surface_rates[phase] *= scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -578,8 +580,9 @@ namespace WellGroupHelpers
|
|||||||
// opm-common that production and injection rates are positive.
|
// opm-common that production and injection rates are positive.
|
||||||
if (!wellTmp.isInjector())
|
if (!wellTmp.isInjector())
|
||||||
sign = -1;
|
sign = -1;
|
||||||
|
const auto& ws = wellStateNupcol.well(well_index);
|
||||||
for (int phase = 0; phase < np; ++phase) {
|
for (int phase = 0; phase < np; ++phase) {
|
||||||
rates[phase] = sign * wellStateNupcol.wellRates(well_index)[phase];
|
rates[phase] = sign * ws.surface_rates[phase];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wellState.setCurrentWellRates(wellName, rates);
|
wellState.setCurrentWellRates(wellName, rates);
|
||||||
|
|||||||
@@ -67,9 +67,10 @@ calculateReservoirRates(WellState& well_state) const
|
|||||||
const int fipreg = 0; // not considering the region for now
|
const int fipreg = 0; // not considering the region for now
|
||||||
const int np = number_of_phases_;
|
const int np = number_of_phases_;
|
||||||
|
|
||||||
|
auto& ws = well_state.well(this->index_of_well_);
|
||||||
std::vector<double> surface_rates(np, 0.0);
|
std::vector<double> surface_rates(np, 0.0);
|
||||||
for (int p = 0; p < np; ++p) {
|
for (int p = 0; p < np; ++p) {
|
||||||
surface_rates[p] = well_state.wellRates(index_of_well_)[p];
|
surface_rates[p] = ws.surface_rates[p];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> voidage_rates(np, 0.0);
|
std::vector<double> voidage_rates(np, 0.0);
|
||||||
@@ -101,26 +102,26 @@ activeProductionConstraint(const WellState& well_state,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (controls.hasControl(Well::ProducerCMode::ORAT) && currentControl != Well::ProducerCMode::ORAT) {
|
if (controls.hasControl(Well::ProducerCMode::ORAT) && currentControl != Well::ProducerCMode::ORAT) {
|
||||||
double current_rate = -well_state.wellRates(well_index)[pu.phase_pos[BlackoilPhases::Liquid]];
|
double current_rate = -ws.surface_rates[pu.phase_pos[BlackoilPhases::Liquid]];
|
||||||
if (controls.oil_rate < current_rate)
|
if (controls.oil_rate < current_rate)
|
||||||
return Well::ProducerCMode::ORAT;
|
return Well::ProducerCMode::ORAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controls.hasControl(Well::ProducerCMode::WRAT) && currentControl != Well::ProducerCMode::WRAT) {
|
if (controls.hasControl(Well::ProducerCMode::WRAT) && currentControl != Well::ProducerCMode::WRAT) {
|
||||||
double current_rate = -well_state.wellRates(well_index)[pu.phase_pos[BlackoilPhases::Aqua]];
|
double current_rate = -ws.surface_rates[pu.phase_pos[BlackoilPhases::Aqua]];
|
||||||
if (controls.water_rate < current_rate)
|
if (controls.water_rate < current_rate)
|
||||||
return Well::ProducerCMode::WRAT;
|
return Well::ProducerCMode::WRAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controls.hasControl(Well::ProducerCMode::GRAT) && currentControl != Well::ProducerCMode::GRAT) {
|
if (controls.hasControl(Well::ProducerCMode::GRAT) && currentControl != Well::ProducerCMode::GRAT) {
|
||||||
double current_rate = -well_state.wellRates(well_index)[pu.phase_pos[BlackoilPhases::Vapour]];
|
double current_rate = -ws.surface_rates[pu.phase_pos[BlackoilPhases::Vapour]];
|
||||||
if (controls.gas_rate < current_rate)
|
if (controls.gas_rate < current_rate)
|
||||||
return Well::ProducerCMode::GRAT;
|
return Well::ProducerCMode::GRAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controls.hasControl(Well::ProducerCMode::LRAT) && currentControl != Well::ProducerCMode::LRAT) {
|
if (controls.hasControl(Well::ProducerCMode::LRAT) && currentControl != Well::ProducerCMode::LRAT) {
|
||||||
double current_rate = -well_state.wellRates(well_index)[pu.phase_pos[BlackoilPhases::Liquid]];
|
double current_rate = -ws.surface_rates[pu.phase_pos[BlackoilPhases::Liquid]];
|
||||||
current_rate -= well_state.wellRates(well_index)[pu.phase_pos[BlackoilPhases::Aqua]];
|
current_rate -= ws.surface_rates[pu.phase_pos[BlackoilPhases::Aqua]];
|
||||||
if (controls.liquid_rate < current_rate)
|
if (controls.liquid_rate < current_rate)
|
||||||
return Well::ProducerCMode::LRAT;
|
return Well::ProducerCMode::LRAT;
|
||||||
}
|
}
|
||||||
@@ -203,17 +204,17 @@ activeInjectionConstraint(const WellState& well_state,
|
|||||||
switch (injectorType) {
|
switch (injectorType) {
|
||||||
case InjectorType::WATER:
|
case InjectorType::WATER:
|
||||||
{
|
{
|
||||||
current_rate = well_state.wellRates(well_index)[ pu.phase_pos[BlackoilPhases::Aqua] ];
|
current_rate = ws.surface_rates[ pu.phase_pos[BlackoilPhases::Aqua] ];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InjectorType::OIL:
|
case InjectorType::OIL:
|
||||||
{
|
{
|
||||||
current_rate = well_state.wellRates(well_index)[ pu.phase_pos[BlackoilPhases::Liquid] ];
|
current_rate = ws.surface_rates[ pu.phase_pos[BlackoilPhases::Liquid] ];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InjectorType::GAS:
|
case InjectorType::GAS:
|
||||||
{
|
{
|
||||||
current_rate = well_state.wellRates(well_index)[ pu.phase_pos[BlackoilPhases::Vapour] ];
|
current_rate = ws.surface_rates[ pu.phase_pos[BlackoilPhases::Vapour] ];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -317,6 +318,7 @@ checkGroupConstraintsInj(const Group& group,
|
|||||||
std::vector<double> resv_coeff(phaseUsage().num_phases, 1.0);
|
std::vector<double> resv_coeff(phaseUsage().num_phases, 1.0);
|
||||||
rateConverter_.calcInjCoeff(0, pvtRegionIdx_, resv_coeff); // FIPNUM region 0 here, should use FIPNUM from WELSPECS.
|
rateConverter_.calcInjCoeff(0, pvtRegionIdx_, resv_coeff); // FIPNUM region 0 here, should use FIPNUM from WELSPECS.
|
||||||
|
|
||||||
|
const auto& ws = well_state.well(this->index_of_well_);
|
||||||
// Call check for the well's injection phase.
|
// Call check for the well's injection phase.
|
||||||
return WellGroupHelpers::checkGroupConstraintsInj(name(),
|
return WellGroupHelpers::checkGroupConstraintsInj(name(),
|
||||||
well_ecl_.groupName(),
|
well_ecl_.groupName(),
|
||||||
@@ -325,7 +327,7 @@ checkGroupConstraintsInj(const Group& group,
|
|||||||
group_state,
|
group_state,
|
||||||
current_step_,
|
current_step_,
|
||||||
guide_rate_,
|
guide_rate_,
|
||||||
well_state.wellRates(index_of_well_).data(),
|
ws.surface_rates.data(),
|
||||||
injectionPhase,
|
injectionPhase,
|
||||||
phaseUsage(),
|
phaseUsage(),
|
||||||
efficiencyFactor,
|
efficiencyFactor,
|
||||||
@@ -350,6 +352,7 @@ checkGroupConstraintsProd(const Group& group,
|
|||||||
std::vector<double> resv_coeff(this->phaseUsage().num_phases, 1.0);
|
std::vector<double> resv_coeff(this->phaseUsage().num_phases, 1.0);
|
||||||
rateConverter_.calcCoeff(0, pvtRegionIdx_, resv_coeff); // FIPNUM region 0 here, should use FIPNUM from WELSPECS.
|
rateConverter_.calcCoeff(0, pvtRegionIdx_, resv_coeff); // FIPNUM region 0 here, should use FIPNUM from WELSPECS.
|
||||||
|
|
||||||
|
const auto& ws = well_state.well(this->index_of_well_);
|
||||||
return WellGroupHelpers::checkGroupConstraintsProd(name(),
|
return WellGroupHelpers::checkGroupConstraintsProd(name(),
|
||||||
well_ecl_.groupName(),
|
well_ecl_.groupName(),
|
||||||
group,
|
group,
|
||||||
@@ -357,7 +360,7 @@ checkGroupConstraintsProd(const Group& group,
|
|||||||
group_state,
|
group_state,
|
||||||
current_step_,
|
current_step_,
|
||||||
guide_rate_,
|
guide_rate_,
|
||||||
well_state.wellRates(index_of_well_).data(),
|
ws.surface_rates.data(),
|
||||||
phaseUsage(),
|
phaseUsage(),
|
||||||
efficiencyFactor,
|
efficiencyFactor,
|
||||||
schedule,
|
schedule,
|
||||||
@@ -400,7 +403,7 @@ checkGroupConstraints(WellState& well_state,
|
|||||||
ws.injection_cmode = Well::InjectorCMode::GRUP;
|
ws.injection_cmode = Well::InjectorCMode::GRUP;
|
||||||
const int np = well_state.numPhases();
|
const int np = well_state.numPhases();
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(index_of_well_)[p] *= group_constraint.second;
|
ws.surface_rates[p] *= group_constraint.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return group_constraint.first;
|
return group_constraint.first;
|
||||||
@@ -428,7 +431,7 @@ checkGroupConstraints(WellState& well_state,
|
|||||||
ws.production_cmode = Well::ProducerCMode::GRUP;
|
ws.production_cmode = Well::ProducerCMode::GRUP;
|
||||||
const int np = well_state.numPhases();
|
const int np = well_state.numPhases();
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(index_of_well_)[p] *= group_constraint.second;
|
ws.surface_rates[p] *= group_constraint.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return group_constraint.first;
|
return group_constraint.first;
|
||||||
@@ -698,7 +701,7 @@ updateWellTestStateEconomic(const WellState& well_state,
|
|||||||
if (quantity_limit == WellEconProductionLimits::QuantityLimit::POTN)
|
if (quantity_limit == WellEconProductionLimits::QuantityLimit::POTN)
|
||||||
rate_limit_violated = checkRateEconLimits(econ_production_limits, ws.well_potentials.data(), deferred_logger);
|
rate_limit_violated = checkRateEconLimits(econ_production_limits, ws.well_potentials.data(), deferred_logger);
|
||||||
else {
|
else {
|
||||||
rate_limit_violated = checkRateEconLimits(econ_production_limits, well_state.wellRates(index_of_well_).data(), deferred_logger);
|
rate_limit_violated = checkRateEconLimits(econ_production_limits, ws.surface_rates.data(), deferred_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,9 +902,9 @@ checkMaxRatioLimitWell(const WellState& well_state,
|
|||||||
const int np = number_of_phases_;
|
const int np = number_of_phases_;
|
||||||
|
|
||||||
std::vector<double> well_rates(np, 0.0);
|
std::vector<double> well_rates(np, 0.0);
|
||||||
|
const auto& ws = well_state.well(this->index_of_well_);
|
||||||
for (int p = 0; p < np; ++p) {
|
for (int p = 0; p < np; ++p) {
|
||||||
well_rates[p] = well_state.wellRates(index_of_well_)[p];
|
well_rates[p] = ws.surface_rates[p];
|
||||||
}
|
}
|
||||||
|
|
||||||
const double well_ratio = ratioFunc(well_rates, phaseUsage());
|
const double well_ratio = ratioFunc(well_rates, phaseUsage());
|
||||||
@@ -1099,7 +1102,8 @@ getGroupProductionTargetRate(const Group& group,
|
|||||||
}
|
}
|
||||||
// Avoid negative target rates coming from too large local reductions.
|
// Avoid negative target rates coming from too large local reductions.
|
||||||
const double target_rate = std::max(0.0, target / efficiencyFactor);
|
const double target_rate = std::max(0.0, target / efficiencyFactor);
|
||||||
const auto& rates = well_state.wellRates(index_of_well_);
|
const auto& ws = well_state.well(this->index_of_well_);
|
||||||
|
const auto& rates = ws.surface_rates;
|
||||||
const auto current_rate = -tcalc.calcModeRateFromRates(rates); // Switch sign since 'rates' are negative for producers.
|
const auto current_rate = -tcalc.calcModeRateFromRates(rates); // Switch sign since 'rates' are negative for producers.
|
||||||
double scale = 1.0;
|
double scale = 1.0;
|
||||||
if (current_rate > 1e-14)
|
if (current_rate > 1e-14)
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ namespace Opm
|
|||||||
|
|
||||||
if (this->wellIsStopped()) {
|
if (this->wellIsStopped()) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = 0.0;
|
ws.surface_rates[p] = 0;
|
||||||
}
|
}
|
||||||
ws.thp = 0;
|
ws.thp = 0;
|
||||||
return;
|
return;
|
||||||
@@ -647,7 +647,7 @@ namespace Opm
|
|||||||
switch(current) {
|
switch(current) {
|
||||||
case Well::InjectorCMode::RATE:
|
case Well::InjectorCMode::RATE:
|
||||||
{
|
{
|
||||||
well_state.wellRates(well_index)[phasePos] = controls.surface_rate;
|
ws.surface_rates[phasePos] = controls.surface_rate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,16 +656,13 @@ namespace Opm
|
|||||||
std::vector<double> convert_coeff(this->number_of_phases_, 1.0);
|
std::vector<double> convert_coeff(this->number_of_phases_, 1.0);
|
||||||
this->rateConverter_.calcCoeff(/*fipreg*/ 0, this->pvtRegionIdx_, convert_coeff);
|
this->rateConverter_.calcCoeff(/*fipreg*/ 0, this->pvtRegionIdx_, convert_coeff);
|
||||||
const double coeff = convert_coeff[phasePos];
|
const double coeff = convert_coeff[phasePos];
|
||||||
well_state.wellRates(well_index)[phasePos] = controls.reservoir_rate/coeff;
|
ws.surface_rates[phasePos] = controls.reservoir_rate/coeff;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Well::InjectorCMode::THP:
|
case Well::InjectorCMode::THP:
|
||||||
{
|
{
|
||||||
std::vector<double> rates(3, 0.0);
|
auto rates = ws.surface_rates;
|
||||||
for (int p = 0; p<np; ++p) {
|
|
||||||
rates[p] = well_state.wellRates(well_index)[p];
|
|
||||||
}
|
|
||||||
double bhp = this->calculateBhpFromThp(well_state, rates, well, summaryState, this->getRefDensity(), deferred_logger);
|
double bhp = this->calculateBhpFromThp(well_state, rates, well, summaryState, this->getRefDensity(), deferred_logger);
|
||||||
ws.bhp = bhp;
|
ws.bhp = bhp;
|
||||||
|
|
||||||
@@ -673,11 +670,9 @@ namespace Opm
|
|||||||
// we try to provide a better intial well rate
|
// we try to provide a better intial well rate
|
||||||
// using the well potentials
|
// using the well potentials
|
||||||
double total_rate = std::accumulate(rates.begin(), rates.end(), 0.0);
|
double total_rate = std::accumulate(rates.begin(), rates.end(), 0.0);
|
||||||
if (total_rate <= 0.0){
|
if (total_rate <= 0.0)
|
||||||
for (int p = 0; p<np; ++p) {
|
ws.surface_rates = ws.well_potentials;
|
||||||
well_state.wellRates(well_index)[p] = ws.well_potentials[p];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Well::InjectorCMode::BHP:
|
case Well::InjectorCMode::BHP:
|
||||||
@@ -685,16 +680,14 @@ namespace Opm
|
|||||||
ws.bhp = controls.bhp_limit;
|
ws.bhp = controls.bhp_limit;
|
||||||
double total_rate = 0.0;
|
double total_rate = 0.0;
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
total_rate += well_state.wellRates(well_index)[p];
|
total_rate += ws.surface_rates[p];
|
||||||
}
|
}
|
||||||
// if the total rates are negative or zero
|
// if the total rates are negative or zero
|
||||||
// we try to provide a better intial well rate
|
// we try to provide a better intial well rate
|
||||||
// using the well potentials
|
// using the well potentials
|
||||||
if (total_rate <= 0.0){
|
if (total_rate <= 0.0)
|
||||||
for (int p = 0; p<np; ++p) {
|
ws.surface_rates = ws.well_potentials;
|
||||||
well_state.wellRates(well_index)[p] = ws.well_potentials[p];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Well::InjectorCMode::GRUP:
|
case Well::InjectorCMode::GRUP:
|
||||||
@@ -712,7 +705,7 @@ namespace Opm
|
|||||||
efficiencyFactor,
|
efficiencyFactor,
|
||||||
deferred_logger);
|
deferred_logger);
|
||||||
if (target)
|
if (target)
|
||||||
well_state.wellRates(well_index)[phasePos] = *target;
|
ws.surface_rates[phasePos] = *target;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Well::InjectorCMode::CMODE_UNDEFINED:
|
case Well::InjectorCMode::CMODE_UNDEFINED:
|
||||||
@@ -730,19 +723,19 @@ namespace Opm
|
|||||||
switch (current) {
|
switch (current) {
|
||||||
case Well::ProducerCMode::ORAT:
|
case Well::ProducerCMode::ORAT:
|
||||||
{
|
{
|
||||||
double current_rate = -well_state.wellRates(well_index)[ pu.phase_pos[Oil] ];
|
double current_rate = -ws.surface_rates[ pu.phase_pos[Oil] ];
|
||||||
// for trivial rates or opposite direction we don't just scale the rates
|
// for trivial rates or opposite direction we don't just scale the rates
|
||||||
// but use either the potentials or the mobility ratio to initial the well rates
|
// but use either the potentials or the mobility ratio to initial the well rates
|
||||||
if (current_rate > 0.0) {
|
if (current_rate > 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] *= controls.oil_rate/current_rate;
|
ws.surface_rates[p] *= controls.oil_rate/current_rate;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
||||||
double control_fraction = fractions[pu.phase_pos[Oil]];
|
double control_fraction = fractions[pu.phase_pos[Oil]];
|
||||||
if (control_fraction != 0.0) {
|
if (control_fraction != 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = - fractions[p] * controls.oil_rate/control_fraction;
|
ws.surface_rates[p] = - fractions[p] * controls.oil_rate/control_fraction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -750,19 +743,19 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
case Well::ProducerCMode::WRAT:
|
case Well::ProducerCMode::WRAT:
|
||||||
{
|
{
|
||||||
double current_rate = -well_state.wellRates(well_index)[ pu.phase_pos[Water] ];
|
double current_rate = -ws.surface_rates[ pu.phase_pos[Water] ];
|
||||||
// for trivial rates or opposite direction we don't just scale the rates
|
// for trivial rates or opposite direction we don't just scale the rates
|
||||||
// but use either the potentials or the mobility ratio to initial the well rates
|
// but use either the potentials or the mobility ratio to initial the well rates
|
||||||
if (current_rate > 0.0) {
|
if (current_rate > 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] *= controls.water_rate/current_rate;
|
ws.surface_rates[p] *= controls.water_rate/current_rate;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
||||||
double control_fraction = fractions[pu.phase_pos[Water]];
|
double control_fraction = fractions[pu.phase_pos[Water]];
|
||||||
if (control_fraction != 0.0) {
|
if (control_fraction != 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = - fractions[p] * controls.water_rate/control_fraction;
|
ws.surface_rates[p] = - fractions[p] * controls.water_rate/control_fraction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -770,19 +763,19 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
case Well::ProducerCMode::GRAT:
|
case Well::ProducerCMode::GRAT:
|
||||||
{
|
{
|
||||||
double current_rate = -well_state.wellRates(well_index)[pu.phase_pos[Gas] ];
|
double current_rate = -ws.surface_rates[pu.phase_pos[Gas] ];
|
||||||
// or trivial rates or opposite direction we don't just scale the rates
|
// or trivial rates or opposite direction we don't just scale the rates
|
||||||
// but use either the potentials or the mobility ratio to initial the well rates
|
// but use either the potentials or the mobility ratio to initial the well rates
|
||||||
if (current_rate > 0.0) {
|
if (current_rate > 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] *= controls.gas_rate/current_rate;
|
ws.surface_rates[p] *= controls.gas_rate/current_rate;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
||||||
double control_fraction = fractions[pu.phase_pos[Gas]];
|
double control_fraction = fractions[pu.phase_pos[Gas]];
|
||||||
if (control_fraction != 0.0) {
|
if (control_fraction != 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = - fractions[p] * controls.gas_rate/control_fraction;
|
ws.surface_rates[p] = - fractions[p] * controls.gas_rate/control_fraction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -792,20 +785,20 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
case Well::ProducerCMode::LRAT:
|
case Well::ProducerCMode::LRAT:
|
||||||
{
|
{
|
||||||
double current_rate = -well_state.wellRates(well_index)[ pu.phase_pos[Water] ]
|
double current_rate = -ws.surface_rates[ pu.phase_pos[Water] ]
|
||||||
- well_state.wellRates(well_index)[ pu.phase_pos[Oil] ];
|
- ws.surface_rates[ pu.phase_pos[Oil] ];
|
||||||
// or trivial rates or opposite direction we don't just scale the rates
|
// or trivial rates or opposite direction we don't just scale the rates
|
||||||
// but use either the potentials or the mobility ratio to initial the well rates
|
// but use either the potentials or the mobility ratio to initial the well rates
|
||||||
if (current_rate > 0.0) {
|
if (current_rate > 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] *= controls.liquid_rate/current_rate;
|
ws.surface_rates[p] *= controls.liquid_rate/current_rate;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
||||||
double control_fraction = fractions[pu.phase_pos[Water]] + fractions[pu.phase_pos[Oil]];
|
double control_fraction = fractions[pu.phase_pos[Water]] + fractions[pu.phase_pos[Oil]];
|
||||||
if (control_fraction != 0.0) {
|
if (control_fraction != 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = - fractions[p] * controls.liquid_rate / control_fraction;
|
ws.surface_rates[p] = - fractions[p] * controls.liquid_rate / control_fraction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -821,19 +814,19 @@ namespace Opm
|
|||||||
this->rateConverter_.calcCoeff(/*fipreg*/ 0, this->pvtRegionIdx_, convert_coeff);
|
this->rateConverter_.calcCoeff(/*fipreg*/ 0, this->pvtRegionIdx_, convert_coeff);
|
||||||
double total_res_rate = 0.0;
|
double total_res_rate = 0.0;
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
total_res_rate -= well_state.wellRates(well_index)[p] * convert_coeff[p];
|
total_res_rate -= ws.surface_rates[p] * convert_coeff[p];
|
||||||
}
|
}
|
||||||
if (controls.prediction_mode) {
|
if (controls.prediction_mode) {
|
||||||
// or trivial rates or opposite direction we don't just scale the rates
|
// or trivial rates or opposite direction we don't just scale the rates
|
||||||
// but use either the potentials or the mobility ratio to initial the well rates
|
// but use either the potentials or the mobility ratio to initial the well rates
|
||||||
if (total_res_rate > 0.0) {
|
if (total_res_rate > 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] *= controls.resv_rate/total_res_rate;
|
ws.surface_rates[p] *= controls.resv_rate/total_res_rate;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = - fractions[p] * controls.resv_rate / convert_coeff[p];
|
ws.surface_rates[p] = - fractions[p] * controls.resv_rate / convert_coeff[p];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -854,12 +847,12 @@ namespace Opm
|
|||||||
// but use either the potentials or the mobility ratio to initial the well rates
|
// but use either the potentials or the mobility ratio to initial the well rates
|
||||||
if (total_res_rate > 0.0) {
|
if (total_res_rate > 0.0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] *= target/total_res_rate;
|
ws.surface_rates[p] *= target/total_res_rate;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
const std::vector<double> fractions = initialWellRateFractions(ebos_simulator, well_state);
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = - fractions[p] * target / convert_coeff[p];
|
ws.surface_rates[p] = - fractions[p] * target / convert_coeff[p];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,24 +864,21 @@ namespace Opm
|
|||||||
ws.bhp = controls.bhp_limit;
|
ws.bhp = controls.bhp_limit;
|
||||||
double total_rate = 0.0;
|
double total_rate = 0.0;
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
total_rate -= well_state.wellRates(well_index)[p];
|
total_rate -= ws.surface_rates[p];
|
||||||
}
|
}
|
||||||
// if the total rates are negative or zero
|
// if the total rates are negative or zero
|
||||||
// we try to provide a better intial well rate
|
// we try to provide a better intial well rate
|
||||||
// using the well potentials
|
// using the well potentials
|
||||||
if (total_rate <= 0.0){
|
if (total_rate <= 0.0){
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = -ws.well_potentials[p];
|
ws.surface_rates[p] = -ws.well_potentials[p];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Well::ProducerCMode::THP:
|
case Well::ProducerCMode::THP:
|
||||||
{
|
{
|
||||||
std::vector<double> rates(3, 0.0);
|
auto rates = ws.surface_rates;
|
||||||
for (int p = 0; p<np; ++p) {
|
|
||||||
rates[p] = well_state.wellRates(well_index)[p];
|
|
||||||
}
|
|
||||||
double bhp = this->calculateBhpFromThp(well_state, rates, well, summaryState, this->getRefDensity(), deferred_logger);
|
double bhp = this->calculateBhpFromThp(well_state, rates, well, summaryState, this->getRefDensity(), deferred_logger);
|
||||||
ws.bhp = bhp;
|
ws.bhp = bhp;
|
||||||
|
|
||||||
@@ -898,7 +888,7 @@ namespace Opm
|
|||||||
double total_rate = -std::accumulate(rates.begin(), rates.end(), 0.0);
|
double total_rate = -std::accumulate(rates.begin(), rates.end(), 0.0);
|
||||||
if (total_rate <= 0.0){
|
if (total_rate <= 0.0){
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] = -ws.well_potentials[p];
|
ws.surface_rates[p] = -ws.well_potentials[p];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -918,7 +908,7 @@ namespace Opm
|
|||||||
// we don't want to scale with zero and get zero rates.
|
// we don't want to scale with zero and get zero rates.
|
||||||
if (scale > 0) {
|
if (scale > 0) {
|
||||||
for (int p = 0; p<np; ++p) {
|
for (int p = 0; p<np; ++p) {
|
||||||
well_state.wellRates(well_index)[p] *= scale;
|
ws.surface_rates[p] *= scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -989,9 +979,10 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
// Check if the rates of this well only are single-phase, do nothing
|
// Check if the rates of this well only are single-phase, do nothing
|
||||||
// if more than one nonzero rate.
|
// if more than one nonzero rate.
|
||||||
|
auto& ws = well_state.well(this->index_of_well_);
|
||||||
int nonzero_rate_index = -1;
|
int nonzero_rate_index = -1;
|
||||||
for (int p = 0; p < this->number_of_phases_; ++p) {
|
for (int p = 0; p < this->number_of_phases_; ++p) {
|
||||||
if (well_state.wellRates(this->index_of_well_)[p] != 0.0) {
|
if (ws.surface_rates[p] != 0.0) {
|
||||||
if (nonzero_rate_index == -1) {
|
if (nonzero_rate_index == -1) {
|
||||||
nonzero_rate_index = p;
|
nonzero_rate_index = p;
|
||||||
} else {
|
} else {
|
||||||
@@ -1009,12 +1000,12 @@ namespace Opm
|
|||||||
std::vector<double> well_q_s = computeCurrentWellRates(ebosSimulator, deferred_logger);
|
std::vector<double> well_q_s = computeCurrentWellRates(ebosSimulator, deferred_logger);
|
||||||
|
|
||||||
// Set the currently-zero phase flows to be nonzero in proportion to well_q_s.
|
// Set the currently-zero phase flows to be nonzero in proportion to well_q_s.
|
||||||
const double initial_nonzero_rate = well_state.wellRates(this->index_of_well_)[nonzero_rate_index];
|
const double initial_nonzero_rate = ws.surface_rates[nonzero_rate_index];
|
||||||
const int comp_idx_nz = this->flowPhaseToEbosCompIdx(nonzero_rate_index);
|
const int comp_idx_nz = this->flowPhaseToEbosCompIdx(nonzero_rate_index);
|
||||||
for (int p = 0; p < this->number_of_phases_; ++p) {
|
for (int p = 0; p < this->number_of_phases_; ++p) {
|
||||||
if (p != nonzero_rate_index) {
|
if (p != nonzero_rate_index) {
|
||||||
const int comp_idx = this->flowPhaseToEbosCompIdx(p);
|
const int comp_idx = this->flowPhaseToEbosCompIdx(p);
|
||||||
double& rate = well_state.wellRates(this->index_of_well_)[p];
|
double& rate = ws.surface_rates[p];
|
||||||
rate = (initial_nonzero_rate/well_q_s[comp_idx_nz]) * (well_q_s[comp_idx]);
|
rate = (initial_nonzero_rate/well_q_s[comp_idx_nz]) * (well_q_s[comp_idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ void WellState::base_init(const std::vector<double>& cellPressures,
|
|||||||
this->wellMap_.clear();
|
this->wellMap_.clear();
|
||||||
this->perfdata.clear();
|
this->perfdata.clear();
|
||||||
this->parallel_well_info_.clear();
|
this->parallel_well_info_.clear();
|
||||||
this->wellrates_.clear();
|
|
||||||
this->wells_.clear();
|
this->wells_.clear();
|
||||||
{
|
{
|
||||||
// const int nw = wells->number_of_wells;
|
// const int nw = wells->number_of_wells;
|
||||||
@@ -53,7 +52,7 @@ void WellState::base_init(const std::vector<double>& cellPressures,
|
|||||||
const Well& well = wells_ecl[w];
|
const Well& well = wells_ecl[w];
|
||||||
|
|
||||||
// Initialize bhp(), thp(), wellRates(), temperature().
|
// Initialize bhp(), thp(), wellRates(), temperature().
|
||||||
initSingleWell(cellPressures, w, well, well_perf_data[w], parallel_well_info[w], summary_state);
|
initSingleWell(cellPressures, well, well_perf_data[w], parallel_well_info[w], summary_state);
|
||||||
|
|
||||||
// Setup wellname -> well index mapping.
|
// Setup wellname -> well index mapping.
|
||||||
const int num_perf_this_well = well_perf_data[w].size();
|
const int num_perf_this_well = well_perf_data[w].size();
|
||||||
@@ -73,11 +72,10 @@ void WellState::base_init(const std::vector<double>& cellPressures,
|
|||||||
|
|
||||||
|
|
||||||
void WellState::initSingleWell(const std::vector<double>& cellPressures,
|
void WellState::initSingleWell(const std::vector<double>& cellPressures,
|
||||||
const int w,
|
const Well& well,
|
||||||
const Well& well,
|
const std::vector<PerforationData>& well_perf_data,
|
||||||
const std::vector<PerforationData>& well_perf_data,
|
const ParallelWellInfo* well_info,
|
||||||
const ParallelWellInfo* well_info,
|
const SummaryState& summary_state)
|
||||||
const SummaryState& summary_state)
|
|
||||||
{
|
{
|
||||||
assert(well.isInjector() || well.isProducer());
|
assert(well.isInjector() || well.isProducer());
|
||||||
|
|
||||||
@@ -89,7 +87,6 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
|
|||||||
|
|
||||||
auto& ws = this->wells_.add(well.name(), SingleWellState{well.isProducer(), static_cast<std::size_t>(np), temp});
|
auto& ws = this->wells_.add(well.name(), SingleWellState{well.isProducer(), static_cast<std::size_t>(np), temp});
|
||||||
this->parallel_well_info_.add(well.name(), well_info);
|
this->parallel_well_info_.add(well.name(), well_info);
|
||||||
this->wellrates_.add(well.name(), std::vector<double>(np, 0));
|
|
||||||
const int num_perf_this_well = well_info->communication().sum(well_perf_data.size());
|
const int num_perf_this_well = well_info->communication().sum(well_perf_data.size());
|
||||||
this->perfdata.add(well.name(), PerfData{static_cast<std::size_t>(num_perf_this_well), well.isInjector(), this->phase_usage_});
|
this->perfdata.add(well.name(), PerfData{static_cast<std::size_t>(num_perf_this_well), well.isInjector(), this->phase_usage_});
|
||||||
|
|
||||||
@@ -142,7 +139,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
|
|||||||
// (producer) or RATE (injector).
|
// (producer) or RATE (injector).
|
||||||
// Otherwise, we cannot set the correct
|
// Otherwise, we cannot set the correct
|
||||||
// value here and initialize to zero rate.
|
// value here and initialize to zero rate.
|
||||||
auto& rates = this->wellrates_[w];
|
auto& rates = ws.surface_rates;
|
||||||
if (well.isInjector()) {
|
if (well.isInjector()) {
|
||||||
if (inj_controls.cmode == Well::InjectorCMode::RATE) {
|
if (inj_controls.cmode == Well::InjectorCMode::RATE) {
|
||||||
switch (inj_controls.injector_type) {
|
switch (inj_controls.injector_type) {
|
||||||
@@ -267,6 +264,7 @@ void WellState::init(const std::vector<double>& cellPressures,
|
|||||||
const int global_num_perf_this_well = ecl_well.getConnections().num_open();
|
const int global_num_perf_this_well = ecl_well.getConnections().num_open();
|
||||||
auto& perf_data = this->perfData(w);
|
auto& perf_data = this->perfData(w);
|
||||||
const auto& perf_input = well_perf_data[w];
|
const auto& perf_input = well_perf_data[w];
|
||||||
|
const auto& ws = this->well(w);
|
||||||
|
|
||||||
for (int perf = 0; perf < num_perf_this_well; ++perf) {
|
for (int perf = 0; perf < num_perf_this_well; ++perf) {
|
||||||
perf_data.cell_index[perf] = perf_input[perf].cell_index;
|
perf_data.cell_index[perf] = perf_input[perf].cell_index;
|
||||||
@@ -276,7 +274,7 @@ void WellState::init(const std::vector<double>& cellPressures,
|
|||||||
|
|
||||||
if (wells_ecl[w].getStatus() == Well::Status::OPEN) {
|
if (wells_ecl[w].getStatus() == Well::Status::OPEN) {
|
||||||
for (int p = 0; p < this->numPhases(); ++p) {
|
for (int p = 0; p < this->numPhases(); ++p) {
|
||||||
perf_data.phase_rates[this->numPhases()*perf + p] = wellRates(w)[p] / double(global_num_perf_this_well);
|
perf_data.phase_rates[this->numPhases()*perf + p] = ws.surface_rates[p] / double(global_num_perf_this_well);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
perf_data.pressure[perf] = cellPressures[well_perf_data[w][perf].cell_index];
|
perf_data.pressure[perf] = cellPressures[well_perf_data[w][perf].cell_index];
|
||||||
@@ -348,7 +346,7 @@ void WellState::init(const std::vector<double>& cellPressures,
|
|||||||
new_well.production_cmode = prev_well.production_cmode;
|
new_well.production_cmode = prev_well.production_cmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
wellRates(w) = prevState->wellRates(oldIndex);
|
new_well.surface_rates = prev_well.surface_rates;
|
||||||
wellReservoirRates(w) = prevState->wellReservoirRates(oldIndex);
|
wellReservoirRates(w) = prevState->wellReservoirRates(oldIndex);
|
||||||
new_well.well_potentials = prev_well.well_potentials;
|
new_well.well_potentials = prev_well.well_potentials;
|
||||||
|
|
||||||
@@ -380,7 +378,7 @@ void WellState::init(const std::vector<double>& cellPressures,
|
|||||||
auto& target_rates = perf_data.phase_rates;
|
auto& target_rates = perf_data.phase_rates;
|
||||||
for (int perf_index = 0; perf_index < num_perf_this_well; perf_index++) {
|
for (int perf_index = 0; perf_index < num_perf_this_well; perf_index++) {
|
||||||
for (int p = 0; p < np; ++p) {
|
for (int p = 0; p < np; ++p) {
|
||||||
target_rates[perf_index*np + p] = wellRates(w)[p] / double(global_num_perf_this_well);
|
target_rates[perf_index*np + p] = new_well.surface_rates[p] / double(global_num_perf_this_well);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,7 +475,7 @@ WellState::report(const int* globalCellIdxMap,
|
|||||||
const auto& reservoir_rates = this->well_reservoir_rates_[well_index];
|
const auto& reservoir_rates = this->well_reservoir_rates_[well_index];
|
||||||
const auto& well_potentials = ws.well_potentials;
|
const auto& well_potentials = ws.well_potentials;
|
||||||
const auto& wpi = ws.productivity_index;
|
const auto& wpi = ws.productivity_index;
|
||||||
const auto& wv = this->wellRates(well_index);
|
const auto& wv = ws.surface_rates;
|
||||||
|
|
||||||
data::Well well;
|
data::Well well;
|
||||||
well.bhp = ws.bhp;
|
well.bhp = ws.bhp;
|
||||||
@@ -814,14 +812,10 @@ void WellState::shutWell(int well_index)
|
|||||||
auto& ws = this->well(well_index);
|
auto& ws = this->well(well_index);
|
||||||
ws.shut();
|
ws.shut();
|
||||||
const int np = numPhases();
|
const int np = numPhases();
|
||||||
this->wellrates_[well_index].assign(np, 0);
|
|
||||||
|
|
||||||
auto& resv = this->well_reservoir_rates_[well_index];
|
auto& resv = this->well_reservoir_rates_[well_index];
|
||||||
auto& wpi = ws.productivity_index;
|
|
||||||
|
|
||||||
for (int p = 0; p < np; ++p) {
|
for (int p = 0; p < np; ++p) {
|
||||||
resv[p] = 0.0;
|
resv[p] = 0.0;
|
||||||
wpi[p] = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& perf_data = this->perfData(well_index);
|
auto& perf_data = this->perfData(well_index);
|
||||||
|
|||||||
@@ -255,8 +255,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// One rate per well and phase.
|
/// One rate per well and phase.
|
||||||
std::vector<double>& wellRates(std::size_t well_index) { return wellrates_[well_index]; }
|
std::vector<double>& wellRates(std::size_t well_index) { return this->wells_[well_index].surface_rates; }
|
||||||
const std::vector<double>& wellRates(std::size_t well_index) const { return wellrates_[well_index]; }
|
const std::vector<double>& wellRates(std::size_t well_index) const { return this->wells_[well_index].surface_rates; }
|
||||||
|
|
||||||
std::size_t numPerf(std::size_t well_index) const { return this->perfdata[well_index].size(); }
|
std::size_t numPerf(std::size_t well_index) const { return this->perfdata[well_index].size(); }
|
||||||
|
|
||||||
@@ -312,7 +312,6 @@ private:
|
|||||||
|
|
||||||
WellContainer<SingleWellState> wells_;
|
WellContainer<SingleWellState> wells_;
|
||||||
WellContainer<const ParallelWellInfo*> parallel_well_info_;
|
WellContainer<const ParallelWellInfo*> parallel_well_info_;
|
||||||
WellContainer<std::vector<double>> wellrates_;
|
|
||||||
WellContainer<PerfData> perfdata;
|
WellContainer<PerfData> perfdata;
|
||||||
|
|
||||||
// The well_rates variable is defined for all wells on all processors. The
|
// The well_rates variable is defined for all wells on all processors. The
|
||||||
@@ -358,7 +357,6 @@ private:
|
|||||||
const SummaryState& summary_state);
|
const SummaryState& summary_state);
|
||||||
|
|
||||||
void initSingleWell(const std::vector<double>& cellPressures,
|
void initSingleWell(const std::vector<double>& cellPressures,
|
||||||
const int w,
|
|
||||||
const Well& well,
|
const Well& well,
|
||||||
const std::vector<PerforationData>& well_perf_data,
|
const std::vector<PerforationData>& well_perf_data,
|
||||||
const ParallelWellInfo* well_info,
|
const ParallelWellInfo* well_info,
|
||||||
|
|||||||
Reference in New Issue
Block a user