2012-05-02 02:39:05 -05:00
|
|
|
/*
|
|
|
|
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2012-03-27 09:57:01 -05:00
|
|
|
|
2013-04-10 05:56:14 -05:00
|
|
|
#include "config.h"
|
2012-06-05 08:42:49 -05:00
|
|
|
#include <opm/core/wells/WellsGroup.hpp>
|
2013-03-18 04:33:34 -05:00
|
|
|
#include <opm/core/wells.h>
|
2014-01-03 08:34:01 -06:00
|
|
|
#include <opm/core/well_controls.h>
|
2013-03-14 04:29:42 -05:00
|
|
|
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2013-08-28 07:19:12 -05:00
|
|
|
#include <cmath>
|
|
|
|
#include <memory>
|
|
|
|
#include <iostream>
|
|
|
|
|
2015-08-17 01:47:33 -05:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
static double invalid_alq = -1e100;
|
|
|
|
static double invalid_vfp = -2147483647;
|
|
|
|
} //Namespace
|
|
|
|
|
2012-03-29 11:34:51 -05:00
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
// ========== WellPhasesSummed methods ===========
|
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
WellPhasesSummed::WellPhasesSummed()
|
2012-04-25 09:14:40 -05:00
|
|
|
{
|
2012-05-02 02:39:05 -05:00
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
res_inj_rates[i] = 0.0;
|
|
|
|
res_prod_rates[i] = 0.0;
|
|
|
|
surf_inj_rates[i] = 0.0;
|
|
|
|
surf_prod_rates[i] = 0.0;
|
|
|
|
}
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
void WellPhasesSummed::operator+=(const WellPhasesSummed& other)
|
2012-04-25 09:14:40 -05:00
|
|
|
{
|
2012-05-02 02:39:05 -05:00
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
res_inj_rates[i] += other.res_inj_rates[i];
|
|
|
|
res_prod_rates[i] += other.res_prod_rates[i];
|
|
|
|
surf_inj_rates[i] += other.surf_inj_rates[i];
|
|
|
|
surf_prod_rates[i] += other.surf_prod_rates[i];
|
|
|
|
}
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
|
|
|
|
// ========== WellsGroupInterface methods ===========
|
|
|
|
|
|
|
|
|
2012-04-11 03:56:08 -05:00
|
|
|
WellsGroupInterface::WellsGroupInterface(const std::string& myname,
|
2012-05-02 02:39:05 -05:00
|
|
|
const ProductionSpecification& prod_spec,
|
|
|
|
const InjectionSpecification& inje_spec,
|
|
|
|
const PhaseUsage& phase_usage)
|
|
|
|
: parent_(NULL),
|
|
|
|
name_(myname),
|
|
|
|
production_specification_(prod_spec),
|
|
|
|
injection_specification_(inje_spec),
|
|
|
|
phase_usage_(phase_usage)
|
2012-03-29 11:34:51 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
WellsGroupInterface::~WellsGroupInterface()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-04-13 04:37:50 -05:00
|
|
|
const WellsGroupInterface* WellsGroupInterface::getParent() const
|
|
|
|
{
|
|
|
|
return parent_;
|
|
|
|
}
|
2014-02-12 08:39:57 -06:00
|
|
|
const std::string& WellsGroupInterface::name() const
|
2012-03-29 11:34:51 -05:00
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
|
|
|
const PhaseUsage& WellsGroupInterface::phaseUsage() const
|
2012-05-02 06:02:59 -05:00
|
|
|
{
|
|
|
|
return phase_usage_;
|
|
|
|
}
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2012-04-11 03:49:45 -05:00
|
|
|
bool WellsGroupInterface::isLeafNode() const
|
|
|
|
{
|
2012-03-30 03:51:31 -05:00
|
|
|
return false;
|
|
|
|
}
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2012-04-13 03:32:36 -05:00
|
|
|
void WellsGroupInterface::setParent(WellsGroupInterface* parent)
|
2012-04-12 08:48:24 -05:00
|
|
|
{
|
|
|
|
parent_ = parent;
|
|
|
|
}
|
2012-04-13 03:32:36 -05:00
|
|
|
|
|
|
|
const ProductionSpecification& WellsGroupInterface::prodSpec() const
|
|
|
|
{
|
|
|
|
return production_specification_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Injection specifications for the well or well group.
|
|
|
|
|
|
|
|
const InjectionSpecification& WellsGroupInterface::injSpec() const
|
|
|
|
{
|
|
|
|
return injection_specification_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Production specifications for the well or well group.
|
|
|
|
|
|
|
|
ProductionSpecification& WellsGroupInterface::prodSpec()
|
|
|
|
{
|
|
|
|
return production_specification_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Injection specifications for the well or well group.
|
|
|
|
|
|
|
|
InjectionSpecification& WellsGroupInterface::injSpec()
|
|
|
|
{
|
|
|
|
return injection_specification_;
|
|
|
|
}
|
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
/// Calculates the correct rate for the given ProductionSpecification::ControlMode
|
2013-07-28 06:34:13 -05:00
|
|
|
double WellsGroupInterface::rateByMode(const double* res_rates,
|
2012-05-02 02:39:05 -05:00
|
|
|
const double* surf_rates,
|
|
|
|
const ProductionSpecification::ControlMode mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case ProductionSpecification::ORAT:
|
|
|
|
return surf_rates[phaseUsage().phase_pos[BlackoilPhases::Liquid]];
|
|
|
|
case ProductionSpecification::WRAT:
|
|
|
|
return surf_rates[phaseUsage().phase_pos[BlackoilPhases::Aqua]];
|
|
|
|
case ProductionSpecification::GRAT:
|
|
|
|
return surf_rates[phaseUsage().phase_pos[BlackoilPhases::Vapour]];
|
|
|
|
case ProductionSpecification::LRAT:
|
2013-07-28 06:34:13 -05:00
|
|
|
return surf_rates[phaseUsage().phase_pos[BlackoilPhases::Liquid]]
|
2012-05-02 02:39:05 -05:00
|
|
|
+ surf_rates[phaseUsage().phase_pos[BlackoilPhases::Aqua]];
|
|
|
|
case ProductionSpecification::RESV:
|
|
|
|
{
|
|
|
|
double tot_rate = 0.0;
|
|
|
|
for (int phase = 0; phase < phaseUsage().num_phases; ++phase) {
|
|
|
|
tot_rate += res_rates[phase];
|
|
|
|
}
|
|
|
|
return tot_rate;
|
|
|
|
}
|
|
|
|
default:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "No rate associated with production control mode" << mode);
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Calculates the correct rate for the given InjectionSpecification::ControlMode
|
2013-07-28 06:34:13 -05:00
|
|
|
double WellsGroupInterface::rateByMode(const double* res_rates,
|
2012-05-02 02:39:05 -05:00
|
|
|
const double* surf_rates,
|
|
|
|
const InjectionSpecification::ControlMode mode)
|
|
|
|
{
|
|
|
|
const double* rates = 0;
|
|
|
|
switch (mode) {
|
|
|
|
case InjectionSpecification::RATE:
|
|
|
|
rates = surf_rates;
|
|
|
|
break;
|
|
|
|
case InjectionSpecification::RESV:
|
|
|
|
rates = res_rates;
|
|
|
|
break;
|
|
|
|
default:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "No rate associated with injection control mode" << mode);
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
double tot_rate = 0.0;
|
|
|
|
for (int phase = 0; phase < phaseUsage().num_phases; ++phase) {
|
|
|
|
tot_rate += rates[phase];
|
|
|
|
}
|
|
|
|
return tot_rate;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
double WellsGroupInterface::getTarget(ProductionSpecification::ControlMode mode)
|
|
|
|
{
|
|
|
|
double target = -1.0;
|
|
|
|
switch (mode) {
|
|
|
|
case ProductionSpecification::GRAT:
|
|
|
|
target = prodSpec().gas_max_rate_;
|
|
|
|
break;
|
2012-05-03 08:35:44 -05:00
|
|
|
case ProductionSpecification::WRAT:
|
|
|
|
target = prodSpec().water_max_rate_;
|
|
|
|
break;
|
2012-05-02 06:02:59 -05:00
|
|
|
case ProductionSpecification::ORAT:
|
|
|
|
target = prodSpec().oil_max_rate_;
|
|
|
|
break;
|
|
|
|
case ProductionSpecification::RESV:
|
|
|
|
target = prodSpec().reservoir_flow_max_rate_;
|
|
|
|
break;
|
|
|
|
case ProductionSpecification::LRAT:
|
|
|
|
target = prodSpec().liquid_max_rate_;
|
|
|
|
break;
|
|
|
|
case ProductionSpecification::GRUP:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Can't query target production rate for GRUP control keyword");
|
2012-05-02 06:02:59 -05:00
|
|
|
break;
|
|
|
|
default:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Unsupported control mode to query target " << mode);
|
2012-05-02 06:02:59 -05:00
|
|
|
break;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
return target;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
double WellsGroupInterface::getTarget(InjectionSpecification::ControlMode mode)
|
|
|
|
{
|
|
|
|
double target = -1.0;
|
|
|
|
switch (mode) {
|
|
|
|
case InjectionSpecification::RATE:
|
|
|
|
target = injSpec().surface_flow_max_rate_;
|
|
|
|
break;
|
|
|
|
case InjectionSpecification::RESV:
|
|
|
|
target = injSpec().reservoir_flow_max_rate_;
|
|
|
|
break;
|
|
|
|
case InjectionSpecification::GRUP:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Can't query target production rate for GRUP control keyword");
|
2012-05-02 06:02:59 -05:00
|
|
|
break;
|
|
|
|
default:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Unsupported control mode to query target " << mode);
|
2012-05-02 06:02:59 -05:00
|
|
|
break;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
return target;
|
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
|
|
|
|
// ============== WellsGroup members =============
|
|
|
|
|
2012-04-25 09:42:55 -05:00
|
|
|
WellsGroupInterface* WellsGroup::findGroup(const std::string& name_of_node)
|
2012-03-29 11:34:51 -05:00
|
|
|
{
|
|
|
|
if (name() == name_of_node) {
|
|
|
|
return this;
|
|
|
|
} else {
|
2012-04-10 08:01:52 -05:00
|
|
|
for (size_t i = 0; i < children_.size(); i++) {
|
2012-03-29 11:34:51 -05:00
|
|
|
WellsGroupInterface* result = children_[i]->findGroup(name_of_node);
|
|
|
|
if (result) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not found in this node.
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2012-04-12 07:25:39 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
|
|
|
|
WellsGroup::WellsGroup(const std::string& myname,
|
|
|
|
const ProductionSpecification& prod_spec,
|
|
|
|
const InjectionSpecification& inj_spec,
|
|
|
|
const PhaseUsage& phase_usage)
|
|
|
|
: WellsGroupInterface(myname, prod_spec, inj_spec, phase_usage)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Sets the current active control to the provided one for all injectors within the group.
|
|
|
|
/// After this call, the combined rate (which rate depending on control_mode) of the group
|
|
|
|
/// shall be equal to target.
|
2012-05-02 06:02:59 -05:00
|
|
|
/// \param[in] forced if true, all children will be set under group control, otherwise
|
|
|
|
/// only children that are under group control will be changed.
|
2012-05-02 02:39:05 -05:00
|
|
|
void WellsGroup::applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,
|
2013-07-28 06:34:13 -05:00
|
|
|
const double target,
|
2012-05-02 06:02:59 -05:00
|
|
|
const bool forced)
|
2012-04-25 09:14:40 -05:00
|
|
|
{
|
2013-07-28 06:34:13 -05:00
|
|
|
if (forced || injSpec().control_mode_ == InjectionSpecification::FLD
|
2012-05-02 08:41:05 -05:00
|
|
|
|| injSpec().control_mode_ == InjectionSpecification::NONE) {
|
|
|
|
const double my_guide_rate = injectionGuideRate(!forced);
|
2012-05-02 09:54:49 -05:00
|
|
|
if (my_guide_rate == 0.0) {
|
|
|
|
// Nothing to do here
|
|
|
|
return;
|
|
|
|
}
|
2012-05-02 06:02:59 -05:00
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
2012-05-02 08:41:05 -05:00
|
|
|
const double child_target = target * children_[i]->injectionGuideRate(!forced) / my_guide_rate;
|
2012-05-02 06:02:59 -05:00
|
|
|
children_[i]->applyInjGroupControl(control_mode, child_target, true);
|
|
|
|
}
|
|
|
|
injSpec().control_mode_ = InjectionSpecification::FLD;
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
|
|
|
}
|
2012-04-16 06:44:53 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
/// Sets the current active control to the provided one for all producers within the group.
|
|
|
|
/// After this call, the combined rate (which rate depending on control_mode) of the group
|
|
|
|
/// shall be equal to target.
|
2012-05-02 06:02:59 -05:00
|
|
|
/// \param[in] forced if true, all children will be set under group control, otherwise
|
|
|
|
/// only children that are under group control will be changed.
|
2012-05-02 02:39:05 -05:00
|
|
|
void WellsGroup::applyProdGroupControl(const ProductionSpecification::ControlMode control_mode,
|
2012-05-02 06:02:59 -05:00
|
|
|
const double target,
|
|
|
|
const bool forced)
|
|
|
|
{
|
2013-07-28 06:34:13 -05:00
|
|
|
if (forced || (prodSpec().control_mode_ == ProductionSpecification::FLD
|
2012-05-02 08:41:05 -05:00
|
|
|
|| prodSpec().control_mode_ == ProductionSpecification::NONE)) {
|
|
|
|
const double my_guide_rate = productionGuideRate(!forced);
|
2012-05-02 09:54:49 -05:00
|
|
|
if (my_guide_rate == 0.0) {
|
|
|
|
// Nothing to do here
|
2012-05-03 08:35:44 -05:00
|
|
|
std::cout << "returning" << std::endl;
|
2012-05-02 09:54:49 -05:00
|
|
|
return;
|
|
|
|
}
|
2012-05-02 06:02:59 -05:00
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
2012-05-02 08:41:05 -05:00
|
|
|
const double child_target = target * children_[i]->productionGuideRate(!forced) / my_guide_rate;
|
2012-05-02 06:02:59 -05:00
|
|
|
children_[i]->applyProdGroupControl(control_mode, child_target, true);
|
|
|
|
}
|
|
|
|
prodSpec().control_mode_ = ProductionSpecification::FLD;
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WellsGroup::conditionsMet(const std::vector<double>& well_bhp,
|
|
|
|
const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase,
|
|
|
|
WellPhasesSummed& summed_phases)
|
2012-04-12 07:25:39 -05:00
|
|
|
{
|
2012-05-02 02:39:05 -05:00
|
|
|
// Check children's constraints recursively.
|
2012-04-25 09:14:40 -05:00
|
|
|
WellPhasesSummed child_phases_summed;
|
2012-05-02 02:39:05 -05:00
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
2012-04-25 09:14:40 -05:00
|
|
|
WellPhasesSummed current_child_phases_summed;
|
2012-05-02 02:39:05 -05:00
|
|
|
if (!children_[i]->conditionsMet(well_bhp,
|
|
|
|
well_reservoirrates_phase,
|
|
|
|
well_surfacerates_phase,
|
|
|
|
current_child_phases_summed)) {
|
2012-04-25 09:14:40 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
child_phases_summed += current_child_phases_summed;
|
2012-04-12 08:48:24 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
|
|
|
|
|
|
|
|
// Injection constraints.
|
2012-05-02 06:02:59 -05:00
|
|
|
InjectionSpecification::ControlMode injection_modes[] = {InjectionSpecification::RATE,
|
|
|
|
InjectionSpecification::RESV};
|
2012-05-02 02:39:05 -05:00
|
|
|
// RATE
|
2012-05-02 06:02:59 -05:00
|
|
|
for (int mode_index = 0; mode_index < 2; ++mode_index) {
|
|
|
|
InjectionSpecification::ControlMode mode = injection_modes[mode_index];
|
|
|
|
if(injSpec().control_mode_ == mode) {
|
|
|
|
continue;
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
2012-05-02 06:02:59 -05:00
|
|
|
const double target_rate = getTarget(mode);
|
2012-05-02 02:39:05 -05:00
|
|
|
if (target_rate >= 0.0) {
|
2012-05-02 06:02:59 -05:00
|
|
|
double my_rate = rateByMode(child_phases_summed.res_inj_rates,
|
|
|
|
child_phases_summed.surf_inj_rates,
|
|
|
|
mode);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
if (my_rate > target_rate) {
|
2012-05-02 06:02:59 -05:00
|
|
|
std::cout << "Group " << mode<<" target not met for group " << name() << std::endl;
|
2012-05-02 02:39:05 -05:00
|
|
|
std::cout << "target = " << target_rate << '\n'
|
|
|
|
<< "rate = " << my_rate << std::endl;
|
2012-05-02 06:02:59 -05:00
|
|
|
applyInjGroupControl(mode, target_rate, true);
|
|
|
|
injSpec().control_mode_ = mode;
|
2012-05-02 02:39:05 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
// REIN
|
|
|
|
// \TODO: Add support for REIN controls.
|
|
|
|
|
|
|
|
// Production constraints.
|
2012-05-02 06:02:59 -05:00
|
|
|
ProductionSpecification::ControlMode production_modes[] = {ProductionSpecification::ORAT,
|
|
|
|
ProductionSpecification::WRAT,
|
|
|
|
ProductionSpecification::GRAT,
|
|
|
|
ProductionSpecification::LRAT,
|
|
|
|
ProductionSpecification::RESV};
|
|
|
|
bool production_violated = false;
|
|
|
|
ProductionSpecification::ControlMode production_mode_violated;
|
|
|
|
for (int mode_index = 0; mode_index < 5; ++mode_index) {
|
|
|
|
const ProductionSpecification::ControlMode mode = production_modes[mode_index];
|
|
|
|
if (prodSpec().control_mode_ == mode) {
|
|
|
|
continue;
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
2012-05-02 06:02:59 -05:00
|
|
|
const double target_rate = getTarget(mode);
|
2012-05-02 02:39:05 -05:00
|
|
|
if (target_rate >= 0.0) {
|
2013-07-28 06:34:13 -05:00
|
|
|
const double my_rate = rateByMode(child_phases_summed.res_prod_rates,
|
2012-05-02 06:02:59 -05:00
|
|
|
child_phases_summed.surf_prod_rates,
|
|
|
|
mode);
|
2012-05-02 02:39:05 -05:00
|
|
|
if (std::fabs(my_rate) > target_rate) {
|
2012-05-02 06:02:59 -05:00
|
|
|
std::cout << "Group" << mode << " target not met for group " << name() << std::endl;
|
2012-05-02 02:39:05 -05:00
|
|
|
std::cout << "target = " << target_rate << '\n'
|
|
|
|
<< "rate = " << my_rate << std::endl;
|
2012-05-02 06:02:59 -05:00
|
|
|
production_violated = true;
|
|
|
|
production_mode_violated = mode;
|
|
|
|
break;
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
if (production_violated) {
|
2012-05-02 02:39:05 -05:00
|
|
|
switch (prodSpec().procedure_) {
|
2012-04-25 09:14:40 -05:00
|
|
|
case ProductionSpecification::WELL:
|
2012-05-02 06:02:59 -05:00
|
|
|
getWorstOffending(well_reservoirrates_phase,
|
|
|
|
well_surfacerates_phase,
|
|
|
|
production_mode_violated).first->shutWell();
|
2012-04-25 09:14:40 -05:00
|
|
|
return false;
|
|
|
|
case ProductionSpecification::RATE:
|
2012-05-03 08:35:44 -05:00
|
|
|
std::cout << "Applying group control" << std::endl;
|
2013-07-28 06:34:13 -05:00
|
|
|
applyProdGroupControl(production_mode_violated,
|
2012-05-02 06:02:59 -05:00
|
|
|
getTarget(production_mode_violated),
|
|
|
|
true);
|
|
|
|
return false;
|
|
|
|
case ProductionSpecification::NONE_P:
|
|
|
|
// Do nothing
|
2012-04-25 09:14:40 -05:00
|
|
|
return false;
|
|
|
|
}
|
2012-04-16 06:44:53 -05:00
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-25 09:14:40 -05:00
|
|
|
summed_phases += child_phases_summed;
|
|
|
|
return true;
|
2012-04-12 07:25:39 -05:00
|
|
|
}
|
2012-04-13 03:32:36 -05:00
|
|
|
|
2013-08-08 05:32:01 -05:00
|
|
|
void WellsGroup::addChild(std::shared_ptr<WellsGroupInterface> child)
|
2012-04-11 03:49:45 -05:00
|
|
|
{
|
2012-03-29 11:34:51 -05:00
|
|
|
children_.push_back(child);
|
|
|
|
}
|
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-16 06:44:53 -05:00
|
|
|
int WellsGroup::numberOfLeafNodes() {
|
2013-07-28 06:34:13 -05:00
|
|
|
// This could probably use some caching, but seeing as how the number of
|
2012-04-16 06:44:53 -05:00
|
|
|
// wells is relatively small, we'll do without for now.
|
|
|
|
int sum = 0;
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-16 06:44:53 -05:00
|
|
|
for(size_t i = 0; i < children_.size(); i++) {
|
|
|
|
sum += children_[i]->numberOfLeafNodes();
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-16 06:44:53 -05:00
|
|
|
return sum;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
std::pair<WellNode*, double> WellsGroup::getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase,
|
|
|
|
ProductionSpecification::ControlMode mode)
|
2012-04-25 09:14:40 -05:00
|
|
|
{
|
|
|
|
std::pair<WellNode*, double> max;
|
|
|
|
for (size_t i = 0; i < children_.size(); i++) {
|
2012-05-02 06:02:59 -05:00
|
|
|
std::pair<WellNode*, double> child_max = children_[i]->getWorstOffending(well_reservoirrates_phase,
|
|
|
|
well_surfacerates_phase,
|
|
|
|
mode);
|
2012-04-25 09:14:40 -05:00
|
|
|
if (i == 0 || max.second < child_max.second) {
|
|
|
|
max = child_max;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return max;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
void WellsGroup::applyProdGroupControls()
|
|
|
|
{
|
|
|
|
ProductionSpecification::ControlMode prod_mode = prodSpec().control_mode_;
|
|
|
|
switch (prod_mode) {
|
|
|
|
case ProductionSpecification::ORAT:
|
|
|
|
case ProductionSpecification::WRAT:
|
|
|
|
case ProductionSpecification::LRAT:
|
|
|
|
case ProductionSpecification::RESV:
|
|
|
|
{
|
2012-05-02 08:41:05 -05:00
|
|
|
const double my_guide_rate = productionGuideRate(true);
|
2012-05-03 08:35:44 -05:00
|
|
|
if (my_guide_rate == 0) {
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Can't apply group control for group " << name() << " as the sum of guide rates for all group controlled wells is zero.");
|
2012-05-03 08:35:44 -05:00
|
|
|
}
|
2012-05-02 06:02:59 -05:00
|
|
|
for (size_t i = 0; i < children_.size(); ++i ) {
|
2013-07-28 06:34:13 -05:00
|
|
|
// Apply for all children.
|
2012-05-02 06:02:59 -05:00
|
|
|
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
|
|
|
// as that would check if we're under group control, something we're not.
|
2012-05-02 09:54:49 -05:00
|
|
|
const double children_guide_rate = children_[i]->productionGuideRate(true);
|
2013-07-28 06:34:13 -05:00
|
|
|
children_[i]->applyProdGroupControl(prod_mode,
|
|
|
|
(children_guide_rate / my_guide_rate) * getTarget(prod_mode),
|
2012-05-02 06:02:59 -05:00
|
|
|
false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ProductionSpecification::FLD:
|
|
|
|
case ProductionSpecification::NONE:
|
|
|
|
// Call all children
|
|
|
|
for (size_t i = 0; i < children_.size(); ++i ) {
|
|
|
|
children_[i]->applyProdGroupControls();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Unhandled group production control type " << prod_mode);
|
2012-05-02 06:02:59 -05:00
|
|
|
}
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
void WellsGroup::applyInjGroupControls()
|
|
|
|
{
|
|
|
|
InjectionSpecification::ControlMode inj_mode = injSpec().control_mode_;
|
|
|
|
switch (inj_mode) {
|
|
|
|
case InjectionSpecification::RATE:
|
|
|
|
case InjectionSpecification::RESV:
|
|
|
|
{
|
2012-05-02 08:41:05 -05:00
|
|
|
const double my_guide_rate = injectionGuideRate(true);
|
2012-05-03 08:35:44 -05:00
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
2013-07-28 06:34:13 -05:00
|
|
|
// Apply for all children.
|
2012-05-02 06:02:59 -05:00
|
|
|
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
|
|
|
// as that would check if we're under group control, something we're not.
|
2012-05-02 08:41:05 -05:00
|
|
|
const double children_guide_rate = children_[i]->injectionGuideRate(true);
|
2012-05-03 08:35:44 -05:00
|
|
|
children_[i]->applyInjGroupControl(inj_mode,
|
|
|
|
(children_guide_rate / my_guide_rate) * getTarget(inj_mode),
|
|
|
|
false);
|
2012-05-02 06:02:59 -05:00
|
|
|
}
|
2012-05-03 08:35:44 -05:00
|
|
|
return;
|
2012-05-02 06:02:59 -05:00
|
|
|
}
|
2012-05-09 09:03:21 -05:00
|
|
|
case InjectionSpecification::VREP:
|
2012-05-02 09:59:42 -05:00
|
|
|
case InjectionSpecification::REIN:
|
2012-05-09 09:03:21 -05:00
|
|
|
std::cout << "Replacement keywords found, remember to call applyExplicitReinjectionControls." << std::endl;
|
2012-05-03 08:35:44 -05:00
|
|
|
return;
|
2012-05-02 06:02:59 -05:00
|
|
|
case InjectionSpecification::FLD:
|
|
|
|
case InjectionSpecification::NONE:
|
|
|
|
// Call all children
|
|
|
|
for (size_t i = 0; i < children_.size(); ++i ) {
|
|
|
|
children_[i]->applyInjGroupControls();
|
|
|
|
}
|
2012-05-03 08:35:44 -05:00
|
|
|
return;
|
2012-05-02 06:02:59 -05:00
|
|
|
default:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Unhandled group injection control mode " << inj_mode);
|
2012-05-02 06:02:59 -05:00
|
|
|
}
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 08:41:05 -05:00
|
|
|
/// Calculates the production guide rate for the group.
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] only_group If true, will only accumelate guide rates for
|
2012-05-02 08:41:05 -05:00
|
|
|
/// wells under group control
|
2013-07-28 06:34:13 -05:00
|
|
|
double WellsGroup::productionGuideRate(bool only_group)
|
2012-05-02 08:41:05 -05:00
|
|
|
{
|
|
|
|
double sum = 0.0;
|
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
|
|
|
sum += children_[i]->productionGuideRate(only_group);
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Calculates the injection guide rate for the group.
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] only_group If true, will only accumelate guide rates for
|
2012-05-02 08:41:05 -05:00
|
|
|
/// wells under group control
|
|
|
|
double WellsGroup::injectionGuideRate(bool only_group)
|
|
|
|
{
|
|
|
|
double sum = 0.0;
|
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
|
|
|
sum += children_[i]->injectionGuideRate(only_group);
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
/// Gets the total production flow of the given phase.
|
2012-05-09 05:35:26 -05:00
|
|
|
/// \param[in] phase_flows A vector containing rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
/// \param[in] phase The phase for which to sum up.
|
2012-05-02 02:39:05 -05:00
|
|
|
|
2012-05-09 05:35:26 -05:00
|
|
|
double WellsGroup::getTotalProductionFlow(const std::vector<double>& phase_flows,
|
|
|
|
const BlackoilPhases::PhaseIndex phase)
|
|
|
|
{
|
|
|
|
double sum = 0.0;
|
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
|
|
|
sum += children_[i]->getTotalProductionFlow(phase_flows, phase);
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
|
2012-05-09 05:57:36 -05:00
|
|
|
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
|
|
|
/// \param[in] well_reservoirrates_phase
|
|
|
|
/// A vector containing reservoir rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
/// \param[in] well_surfacerates_phase
|
|
|
|
/// A vector containing surface rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
2012-05-09 08:43:43 -05:00
|
|
|
void WellsGroup::applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
|
2012-05-09 05:57:36 -05:00
|
|
|
const std::vector<double>& well_surfacerates_phase)
|
|
|
|
{
|
|
|
|
if (injSpec().control_mode_ == InjectionSpecification::REIN) {
|
2012-05-10 08:30:33 -05:00
|
|
|
// Defaulting to water to satisfy -Wmaybe-uninitialized
|
|
|
|
BlackoilPhases::PhaseIndex phase = BlackoilPhases::Aqua;
|
2012-05-09 05:57:36 -05:00
|
|
|
switch (injSpec().injector_type_) {
|
|
|
|
case InjectionSpecification::WATER:
|
|
|
|
phase = BlackoilPhases::Aqua;
|
|
|
|
break;
|
|
|
|
case InjectionSpecification::GAS:
|
|
|
|
phase = BlackoilPhases::Vapour;
|
|
|
|
break;
|
|
|
|
case InjectionSpecification::OIL:
|
|
|
|
phase = BlackoilPhases::Liquid;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const double total_produced = getTotalProductionFlow(well_surfacerates_phase, phase);
|
2012-10-09 08:17:46 -05:00
|
|
|
const double total_reinjected = - total_produced; // Production negative, injection positive
|
2012-05-09 05:57:36 -05:00
|
|
|
const double my_guide_rate = injectionGuideRate(true);
|
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
2013-07-28 06:34:13 -05:00
|
|
|
// Apply for all children.
|
2012-05-09 05:57:36 -05:00
|
|
|
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
|
|
|
// as that would check if we're under group control, something we're not.
|
|
|
|
const double children_guide_rate = children_[i]->injectionGuideRate(true);
|
2012-05-09 06:58:25 -05:00
|
|
|
#ifdef DIRTY_WELLCTRL_HACK
|
|
|
|
children_[i]->applyInjGroupControl(InjectionSpecification::RESV,
|
2012-10-09 08:17:46 -05:00
|
|
|
(children_guide_rate / my_guide_rate) * total_reinjected * injSpec().reinjection_fraction_target_,
|
2012-05-09 06:58:25 -05:00
|
|
|
false);
|
|
|
|
#else
|
2012-05-09 05:57:36 -05:00
|
|
|
children_[i]->applyInjGroupControl(InjectionSpecification::RATE,
|
2012-10-09 08:17:46 -05:00
|
|
|
(children_guide_rate / my_guide_rate) * total_reinjected * injSpec().reinjection_fraction_target_,
|
2012-05-09 05:57:36 -05:00
|
|
|
false);
|
2012-05-09 06:58:25 -05:00
|
|
|
#endif
|
2012-05-09 05:57:36 -05:00
|
|
|
}
|
|
|
|
}
|
2012-05-09 08:43:43 -05:00
|
|
|
else if (injSpec().control_mode_ == InjectionSpecification::VREP) {
|
|
|
|
double total_produced = 0.0;
|
|
|
|
if (phaseUsage().phase_used[BlackoilPhases::Aqua]) {
|
|
|
|
total_produced += getTotalProductionFlow(well_reservoirrates_phase, BlackoilPhases::Aqua);
|
|
|
|
}
|
|
|
|
if (phaseUsage().phase_used[BlackoilPhases::Liquid]) {
|
|
|
|
total_produced += getTotalProductionFlow(well_reservoirrates_phase, BlackoilPhases::Liquid);
|
|
|
|
}
|
|
|
|
if (phaseUsage().phase_used[BlackoilPhases::Vapour]) {
|
|
|
|
total_produced += getTotalProductionFlow(well_reservoirrates_phase, BlackoilPhases::Vapour);
|
|
|
|
}
|
2012-10-09 08:17:46 -05:00
|
|
|
const double total_reinjected = - total_produced; // Production negative, injection positive
|
|
|
|
const double my_guide_rate = injectionGuideRate(true);
|
2012-05-09 08:43:43 -05:00
|
|
|
for (size_t i = 0; i < children_.size(); ++i) {
|
2013-07-28 06:34:13 -05:00
|
|
|
// Apply for all children.
|
2012-05-09 08:43:43 -05:00
|
|
|
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
|
|
|
// as that would check if we're under group control, something we're not.
|
|
|
|
const double children_guide_rate = children_[i]->injectionGuideRate(true);
|
|
|
|
children_[i]->applyInjGroupControl(InjectionSpecification::RESV,
|
2012-10-09 08:17:46 -05:00
|
|
|
(children_guide_rate / my_guide_rate) * total_reinjected * injSpec().voidage_replacment_fraction_,
|
2012-05-09 08:43:43 -05:00
|
|
|
false);
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-09 08:43:43 -05:00
|
|
|
}
|
2012-05-09 05:57:36 -05:00
|
|
|
}
|
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
// ============== WellNode members ============
|
|
|
|
|
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-11 03:56:08 -05:00
|
|
|
WellNode::WellNode(const std::string& myname,
|
2012-05-02 02:39:05 -05:00
|
|
|
const ProductionSpecification& prod_spec,
|
|
|
|
const InjectionSpecification& inj_spec,
|
|
|
|
const PhaseUsage& phase_usage)
|
|
|
|
: WellsGroupInterface(myname, prod_spec, inj_spec, phase_usage),
|
|
|
|
wells_(0),
|
|
|
|
self_index_(-1),
|
2012-05-02 06:02:59 -05:00
|
|
|
group_control_index_(-1),
|
|
|
|
shut_well_(true) // This is default for now
|
2012-03-29 11:34:51 -05:00
|
|
|
{
|
|
|
|
}
|
2012-04-13 03:32:36 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
bool WellNode::conditionsMet(const std::vector<double>& well_bhp,
|
|
|
|
const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase,
|
|
|
|
WellPhasesSummed& summed_phases)
|
2012-04-12 07:25:39 -05:00
|
|
|
{
|
2012-05-02 02:39:05 -05:00
|
|
|
// Report on our rates.
|
|
|
|
const int np = phaseUsage().num_phases;
|
|
|
|
for (int phase = 0; phase < np; ++phase) {
|
|
|
|
if (wells_->type[self_index_] == INJECTOR) {
|
|
|
|
summed_phases.res_inj_rates[phase] = well_reservoirrates_phase[np*self_index_ + phase];
|
|
|
|
summed_phases.surf_inj_rates[phase] = well_surfacerates_phase[np*self_index_ + phase];
|
|
|
|
} else {
|
|
|
|
summed_phases.res_prod_rates[phase] = well_reservoirrates_phase[np*self_index_ + phase];
|
|
|
|
summed_phases.surf_prod_rates[phase] = well_surfacerates_phase[np*self_index_ + phase];
|
2012-04-16 08:26:33 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check constraints.
|
|
|
|
bool is_producer = (wells_->type[self_index_] == PRODUCER);
|
2014-01-06 05:40:03 -06:00
|
|
|
const WellControls * ctrls = wells_->ctrls[self_index_];
|
|
|
|
for (int ctrl_index = 0; ctrl_index < well_controls_get_num(ctrls); ++ctrl_index) {
|
|
|
|
if (ctrl_index == well_controls_get_current(ctrls) || ctrl_index == group_control_index_) {
|
2012-05-02 02:39:05 -05:00
|
|
|
// We do not check constraints that either were used
|
|
|
|
// as the active control, or that come from group control.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
bool ctrl_violated = false;
|
2014-01-06 05:40:03 -06:00
|
|
|
switch (well_controls_iget_type(ctrls , ctrl_index)) {
|
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
case BHP: {
|
|
|
|
const double my_well_bhp = well_bhp[self_index_];
|
2014-01-06 05:40:03 -06:00
|
|
|
const double my_target_bhp = well_controls_iget_target( ctrls , ctrl_index);
|
2012-05-02 02:39:05 -05:00
|
|
|
ctrl_violated = is_producer ? (my_target_bhp > my_well_bhp)
|
|
|
|
: (my_target_bhp < my_well_bhp);
|
|
|
|
if (ctrl_violated) {
|
|
|
|
std::cout << "BHP limit violated for well " << name() << ":\n";
|
|
|
|
std::cout << "BHP limit = " << my_target_bhp << std::endl;
|
|
|
|
std::cout << "BHP = " << my_well_bhp << std::endl;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-01-06 05:40:03 -06:00
|
|
|
|
2015-07-08 10:40:47 -05:00
|
|
|
case THP: {
|
|
|
|
//TODO: Implement support
|
|
|
|
OPM_THROW(std::invalid_argument, "THP not implemented in WellNode::conditionsMet.");
|
|
|
|
}
|
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
case RESERVOIR_RATE: {
|
|
|
|
double my_rate = 0.0;
|
2014-01-06 05:40:03 -06:00
|
|
|
const double * ctrls_distr = well_controls_iget_distr( ctrls , ctrl_index );
|
2012-05-02 02:39:05 -05:00
|
|
|
for (int phase = 0; phase < np; ++phase) {
|
2014-01-06 05:40:03 -06:00
|
|
|
my_rate += ctrls_distr[phase] * well_reservoirrates_phase[np*self_index_ + phase];
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
2014-01-06 05:40:03 -06:00
|
|
|
const double my_rate_target = well_controls_iget_target(ctrls , ctrl_index);
|
2012-05-03 09:04:48 -05:00
|
|
|
ctrl_violated = std::fabs(my_rate) - std::fabs(my_rate_target)> std::max(std::abs(my_rate), std::abs(my_rate_target))*1e-6;
|
2012-05-02 02:39:05 -05:00
|
|
|
if (ctrl_violated) {
|
|
|
|
std::cout << "RESERVOIR_RATE limit violated for well " << name() << ":\n";
|
2012-05-03 08:44:51 -05:00
|
|
|
std::cout << "rate limit = " << my_rate_target << std::endl;
|
|
|
|
std::cout << "rate = " << my_rate << std::endl;
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-01-06 05:40:03 -06:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
case SURFACE_RATE: {
|
|
|
|
double my_rate = 0.0;
|
2014-01-06 05:40:03 -06:00
|
|
|
const double * ctrls_distr = well_controls_iget_distr( ctrls , ctrl_index );
|
2012-05-02 02:39:05 -05:00
|
|
|
for (int phase = 0; phase < np; ++phase) {
|
2014-01-06 05:40:03 -06:00
|
|
|
my_rate += ctrls_distr[phase] * well_surfacerates_phase[np*self_index_ + phase];
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
2014-01-06 05:40:03 -06:00
|
|
|
const double my_rate_target = well_controls_iget_target(ctrls , ctrl_index);
|
2012-05-02 02:39:05 -05:00
|
|
|
ctrl_violated = std::fabs(my_rate) > std::fabs(my_rate_target);
|
|
|
|
if (ctrl_violated) {
|
|
|
|
std::cout << "SURFACE_RATE limit violated for well " << name() << ":\n";
|
2012-05-03 08:44:51 -05:00
|
|
|
std::cout << "rate limit = " << my_rate_target << std::endl;
|
|
|
|
std::cout << "rate = " << my_rate << std::endl;
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} // end of switch()
|
|
|
|
if (ctrl_violated) {
|
|
|
|
set_current_control(self_index_, ctrl_index, wells_);
|
2012-04-25 09:14:40 -05:00
|
|
|
return false;
|
2012-04-13 06:17:25 -05:00
|
|
|
}
|
2012-04-13 05:57:47 -05:00
|
|
|
}
|
2012-04-25 09:14:40 -05:00
|
|
|
return true;
|
2012-04-12 07:25:39 -05:00
|
|
|
}
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2012-04-25 09:42:55 -05:00
|
|
|
WellsGroupInterface* WellNode::findGroup(const std::string& name_of_node)
|
2012-03-29 11:34:51 -05:00
|
|
|
{
|
|
|
|
if (name() == name_of_node) {
|
|
|
|
return this;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-04-13 03:32:36 -05:00
|
|
|
|
2012-04-11 03:49:45 -05:00
|
|
|
bool WellNode::isLeafNode() const
|
|
|
|
{
|
2012-03-30 03:51:31 -05:00
|
|
|
return true;
|
|
|
|
}
|
2012-04-13 03:32:36 -05:00
|
|
|
|
2012-04-25 09:14:40 -05:00
|
|
|
void WellNode::setWellsPointer(Wells* wells, int self_index)
|
2012-04-13 03:32:36 -05:00
|
|
|
{
|
2012-04-12 07:25:39 -05:00
|
|
|
wells_ = wells;
|
|
|
|
self_index_ = self_index;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
|
|
|
int WellNode::numberOfLeafNodes()
|
2012-04-16 06:44:53 -05:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
|
|
|
void WellNode::shutWell()
|
2012-04-25 09:14:40 -05:00
|
|
|
{
|
2012-05-02 06:02:59 -05:00
|
|
|
if (shut_well_) {
|
2014-11-18 01:32:55 -06:00
|
|
|
well_controls_stop_well( wells_->ctrls[self_index_]);
|
2012-05-02 06:02:59 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
const double target = 0.0;
|
2015-07-08 10:40:10 -05:00
|
|
|
const double alq = 0.0;
|
2012-05-02 06:02:59 -05:00
|
|
|
const double distr[3] = {1.0, 1.0, 1.0};
|
|
|
|
|
|
|
|
if (group_control_index_ < 0) {
|
|
|
|
// The well only had its own controls, no group controls.
|
2015-08-11 05:51:18 -05:00
|
|
|
append_well_controls(SURFACE_RATE, target,
|
2015-08-17 01:47:33 -05:00
|
|
|
invalid_alq, invalid_vfp,
|
2015-08-11 05:51:18 -05:00
|
|
|
distr, self_index_, wells_);
|
2014-01-06 05:40:03 -06:00
|
|
|
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
2012-05-02 06:02:59 -05:00
|
|
|
} else {
|
|
|
|
// We will now modify the last control, that
|
|
|
|
// "belongs to" the group control.
|
2014-01-06 05:40:03 -06:00
|
|
|
|
|
|
|
well_controls_iset_type( wells_->ctrls[self_index_] , group_control_index_ , SURFACE_RATE);
|
|
|
|
well_controls_iset_target( wells_->ctrls[self_index_] , group_control_index_ , target);
|
2015-07-08 10:40:10 -05:00
|
|
|
well_controls_iset_alq( wells_->ctrls[self_index_] , group_control_index_ , alq);
|
2014-01-06 05:40:03 -06:00
|
|
|
well_controls_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr);
|
2012-05-02 06:02:59 -05:00
|
|
|
}
|
2014-03-04 07:28:42 -06:00
|
|
|
well_controls_open_well( wells_->ctrls[self_index_]);
|
2012-05-02 06:02:59 -05:00
|
|
|
}
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-10-24 02:30:20 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
std::pair<WellNode*, double> WellNode::getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase,
|
|
|
|
ProductionSpecification::ControlMode mode)
|
|
|
|
{
|
|
|
|
const int np = phaseUsage().num_phases;
|
|
|
|
const int index = self_index_*np;
|
2012-10-24 14:14:24 -05:00
|
|
|
return std::pair<WellNode*, double>(this,
|
|
|
|
rateByMode(&well_reservoirrates_phase[index],
|
|
|
|
&well_surfacerates_phase[index],
|
|
|
|
mode));
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
void WellNode::applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,
|
2012-05-02 06:02:59 -05:00
|
|
|
const double target,
|
|
|
|
const bool forced)
|
2012-05-02 02:39:05 -05:00
|
|
|
{
|
2012-05-02 06:02:59 -05:00
|
|
|
// Not changing if we're not forced to change
|
2013-07-28 06:34:13 -05:00
|
|
|
if (!forced
|
2012-05-09 04:29:13 -05:00
|
|
|
&& (injSpec().control_mode_ != InjectionSpecification::GRUP && injSpec().control_mode_ != InjectionSpecification::NONE)) {
|
2012-05-02 06:02:59 -05:00
|
|
|
return;
|
|
|
|
}
|
2012-10-24 14:12:29 -05:00
|
|
|
if (wells_->type[self_index_] != INJECTOR) {
|
2013-08-28 07:00:35 -05:00
|
|
|
assert(target == 0.0);
|
2012-05-02 02:39:05 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const double distr[3] = { 1.0, 1.0, 1.0 };
|
|
|
|
WellControlType wct;
|
|
|
|
switch (control_mode) {
|
|
|
|
case InjectionSpecification::RATE:
|
|
|
|
wct = SURFACE_RATE;
|
|
|
|
break;
|
|
|
|
case InjectionSpecification::RESV:
|
|
|
|
wct = RESERVOIR_RATE;
|
|
|
|
break;
|
|
|
|
default:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Group injection control mode not handled: " << control_mode);
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (group_control_index_ < 0) {
|
|
|
|
// The well only had its own controls, no group controls.
|
2015-08-17 01:47:33 -05:00
|
|
|
append_well_controls(wct, target, invalid_alq, invalid_vfp, distr, self_index_, wells_);
|
2014-01-06 05:40:03 -06:00
|
|
|
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
2012-05-02 02:39:05 -05:00
|
|
|
} else {
|
|
|
|
// We will now modify the last control, that
|
|
|
|
// "belongs to" the group control.
|
2014-01-06 05:40:03 -06:00
|
|
|
well_controls_iset_type(wells_->ctrls[self_index_] , group_control_index_ , wct);
|
|
|
|
well_controls_iset_target(wells_->ctrls[self_index_] , group_control_index_ ,target);
|
2015-07-08 10:40:10 -05:00
|
|
|
well_controls_iset_alq(wells_->ctrls[self_index_] , group_control_index_ , -1e100);
|
2014-01-06 05:40:03 -06:00
|
|
|
well_controls_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr);
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
set_current_control(self_index_, group_control_index_, wells_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
/// Gets the total production flow of the given phase.
|
2012-05-09 05:35:26 -05:00
|
|
|
/// \param[in] phase_flows A vector containing rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
/// \param[in] phase The phase for which to sum up.
|
|
|
|
|
|
|
|
double WellNode::getTotalProductionFlow(const std::vector<double>& phase_flows,
|
|
|
|
const BlackoilPhases::PhaseIndex phase)
|
|
|
|
{
|
|
|
|
if (type() == INJECTOR) {
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
return phase_flows[self_index_*phaseUsage().num_phases + phaseUsage().phase_pos[phase]];
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-09 05:35:26 -05:00
|
|
|
WellType WellNode::type() const {
|
|
|
|
return wells_->type[self_index_];
|
|
|
|
}
|
|
|
|
|
2012-05-09 05:57:36 -05:00
|
|
|
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
|
|
|
/// \param[in] well_reservoirrates_phase
|
|
|
|
/// A vector containing reservoir rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
/// \param[in] well_surfacerates_phase
|
|
|
|
/// A vector containing surface rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
void WellNode::applyExplicitReinjectionControls(const std::vector<double>&,
|
|
|
|
const std::vector<double>&)
|
|
|
|
{
|
|
|
|
// Do nothing at well level.
|
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
void WellNode::applyProdGroupControl(const ProductionSpecification::ControlMode control_mode,
|
2012-05-02 06:02:59 -05:00
|
|
|
const double target,
|
|
|
|
const bool forced)
|
2012-04-25 09:14:40 -05:00
|
|
|
{
|
2012-05-02 06:02:59 -05:00
|
|
|
// Not changing if we're not forced to change
|
|
|
|
if (!forced && (prodSpec().control_mode_ != ProductionSpecification::GRUP
|
2012-05-09 04:29:13 -05:00
|
|
|
&& prodSpec().control_mode_ != ProductionSpecification::NONE)) {
|
|
|
|
std::cout << "Returning" << std::endl;
|
2012-05-02 06:02:59 -05:00
|
|
|
return;
|
|
|
|
}
|
2012-10-24 14:12:29 -05:00
|
|
|
if (wells_->type[self_index_] != PRODUCER) {
|
2013-08-28 07:00:35 -05:00
|
|
|
assert(target == 0.0);
|
2012-05-02 02:39:05 -05:00
|
|
|
return;
|
|
|
|
}
|
2012-05-03 08:44:51 -05:00
|
|
|
// We're a producer, so we need to negate the input
|
2012-10-08 07:27:56 -05:00
|
|
|
double ntarget = -target;
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
double distr[3] = { 0.0, 0.0, 0.0 };
|
|
|
|
const int* phase_pos = phaseUsage().phase_pos;
|
|
|
|
const int* phase_used = phaseUsage().phase_used;
|
|
|
|
WellControlType wct;
|
|
|
|
switch (control_mode) {
|
|
|
|
case ProductionSpecification::ORAT:
|
|
|
|
wct = SURFACE_RATE;
|
|
|
|
if (!phase_used[BlackoilPhases::Liquid]) {
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Oil phase not active and ORAT control specified.");
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
distr[phase_pos[BlackoilPhases::Liquid]] = 1.0;
|
|
|
|
break;
|
|
|
|
case ProductionSpecification::WRAT:
|
|
|
|
wct = SURFACE_RATE;
|
|
|
|
if (!phase_used[BlackoilPhases::Aqua]) {
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Water phase not active and WRAT control specified.");
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
distr[phase_pos[BlackoilPhases::Aqua]] = 1.0;
|
|
|
|
break;
|
|
|
|
case ProductionSpecification::GRAT:
|
|
|
|
wct = SURFACE_RATE;
|
|
|
|
if (!phase_used[BlackoilPhases::Vapour]) {
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Gas phase not active and GRAT control specified.");
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
distr[phase_pos[BlackoilPhases::Vapour]] = 1.0;
|
2012-04-25 09:14:40 -05:00
|
|
|
break;
|
2012-05-02 02:39:05 -05:00
|
|
|
case ProductionSpecification::LRAT:
|
2013-07-28 06:34:13 -05:00
|
|
|
std::cout << "applying rate" << std::endl;
|
2012-05-02 02:39:05 -05:00
|
|
|
wct = SURFACE_RATE;
|
|
|
|
if (!phase_used[BlackoilPhases::Liquid]) {
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Oil phase not active and LRAT control specified.");
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
if (!phase_used[BlackoilPhases::Aqua]) {
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Water phase not active and LRAT control specified.");
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
distr[phase_pos[BlackoilPhases::Liquid]] = 1.0;
|
|
|
|
distr[phase_pos[BlackoilPhases::Aqua]] = 1.0;
|
2012-04-25 09:14:40 -05:00
|
|
|
break;
|
2012-05-02 02:39:05 -05:00
|
|
|
case ProductionSpecification::RESV:
|
|
|
|
distr[0] = distr[1] = distr[2] = 1.0;
|
|
|
|
wct = RESERVOIR_RATE;
|
|
|
|
break;
|
|
|
|
default:
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Group production control mode not handled: " << control_mode);
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (group_control_index_ < 0) {
|
|
|
|
// The well only had its own controls, no group controls.
|
2015-08-17 01:47:33 -05:00
|
|
|
append_well_controls(wct, ntarget, invalid_alq, invalid_vfp, distr, self_index_, wells_);
|
2014-01-06 05:40:03 -06:00
|
|
|
group_control_index_ = well_controls_get_num(wells_->ctrls[self_index_]) - 1;
|
2012-05-02 02:39:05 -05:00
|
|
|
} else {
|
|
|
|
// We will now modify the last control, that
|
|
|
|
// "belongs to" the group control.
|
2014-01-06 05:40:03 -06:00
|
|
|
well_controls_iset_type(wells_->ctrls[self_index_] , group_control_index_ , wct);
|
|
|
|
well_controls_iset_target(wells_->ctrls[self_index_] , group_control_index_ , ntarget);
|
2015-07-08 10:40:10 -05:00
|
|
|
well_controls_iset_alq(wells_->ctrls[self_index_] , group_control_index_ , -1e100);
|
2014-01-06 05:40:03 -06:00
|
|
|
well_controls_iset_distr(wells_->ctrls[self_index_] , group_control_index_ , distr);
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
set_current_control(self_index_, group_control_index_, wells_);
|
2012-04-25 09:14:40 -05:00
|
|
|
}
|
2012-04-13 03:32:36 -05:00
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
void WellNode::applyProdGroupControls()
|
|
|
|
{
|
|
|
|
// Empty
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
void WellNode::applyInjGroupControls()
|
|
|
|
{
|
|
|
|
// Empty
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 08:41:05 -05:00
|
|
|
/// Calculates the production guide rate for the group.
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] only_group If true, will only accumelate guide rates for
|
2012-05-02 08:41:05 -05:00
|
|
|
/// wells under group control
|
2013-07-28 06:34:13 -05:00
|
|
|
double WellNode::productionGuideRate(bool only_group)
|
2012-05-02 08:41:05 -05:00
|
|
|
{
|
2012-05-03 08:35:44 -05:00
|
|
|
if (!only_group || prodSpec().control_mode_ == ProductionSpecification::GRUP) {
|
2012-05-02 08:41:05 -05:00
|
|
|
return prodSpec().guide_rate_;
|
|
|
|
}
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Calculates the injection guide rate for the group.
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] only_group If true, will only accumelate guide rates for
|
2012-05-02 08:41:05 -05:00
|
|
|
/// wells under group control
|
|
|
|
double WellNode::injectionGuideRate(bool only_group)
|
|
|
|
{
|
2012-05-03 08:35:44 -05:00
|
|
|
if (!only_group || injSpec().control_mode_ == InjectionSpecification::GRUP) {
|
2012-05-02 08:41:05 -05:00
|
|
|
return injSpec().guide_rate_;
|
|
|
|
}
|
|
|
|
return 0.0;
|
|
|
|
}
|
2013-07-28 06:34:13 -05:00
|
|
|
|
|
|
|
|
2012-04-11 03:56:08 -05:00
|
|
|
namespace
|
2012-03-29 11:34:51 -05:00
|
|
|
{
|
|
|
|
|
2012-05-15 10:22:05 -05:00
|
|
|
InjectionSpecification::InjectorType toInjectorType(const std::string& type)
|
2012-04-11 03:56:08 -05:00
|
|
|
{
|
2012-05-15 10:19:35 -05:00
|
|
|
if (type[0] == 'O') {
|
2012-05-02 02:39:05 -05:00
|
|
|
return InjectionSpecification::OIL;
|
2012-04-11 03:56:08 -05:00
|
|
|
}
|
2012-05-15 10:19:35 -05:00
|
|
|
if (type[0] == 'W') {
|
2012-05-02 02:39:05 -05:00
|
|
|
return InjectionSpecification::WATER;
|
2012-04-11 03:56:08 -05:00
|
|
|
}
|
2012-05-15 10:19:35 -05:00
|
|
|
if (type[0] == 'G') {
|
2012-05-02 02:39:05 -05:00
|
|
|
return InjectionSpecification::GAS;
|
2012-04-11 03:56:08 -05:00
|
|
|
}
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Unknown type " << type << ", could not convert to SurfaceComponent");
|
2012-03-29 11:34:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
#define HANDLE_ICM(x) \
|
|
|
|
if (type == #x) { \
|
|
|
|
return InjectionSpecification::x; \
|
|
|
|
}
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
InjectionSpecification::ControlMode toInjectionControlMode(std::string type)
|
|
|
|
{
|
|
|
|
HANDLE_ICM(NONE);
|
|
|
|
HANDLE_ICM(RATE);
|
|
|
|
HANDLE_ICM(RESV);
|
|
|
|
HANDLE_ICM(BHP);
|
|
|
|
HANDLE_ICM(THP);
|
|
|
|
HANDLE_ICM(REIN);
|
|
|
|
HANDLE_ICM(VREP);
|
|
|
|
HANDLE_ICM(GRUP);
|
|
|
|
HANDLE_ICM(FLD);
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Unknown type " << type << ", could not convert to InjectionSpecification::ControlMode.");
|
2012-05-02 02:39:05 -05:00
|
|
|
}
|
|
|
|
#undef HANDLE_ICM
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2012-05-02 02:39:05 -05:00
|
|
|
#define HANDLE_PCM(x) \
|
|
|
|
if (type == #x) { \
|
|
|
|
return ProductionSpecification::x; \
|
2012-03-29 11:34:51 -05:00
|
|
|
}
|
|
|
|
|
2012-04-11 03:56:08 -05:00
|
|
|
ProductionSpecification::ControlMode toProductionControlMode(std::string type)
|
|
|
|
{
|
2012-05-02 02:39:05 -05:00
|
|
|
HANDLE_PCM(NONE);
|
|
|
|
HANDLE_PCM(ORAT);
|
|
|
|
HANDLE_PCM(WRAT);
|
|
|
|
HANDLE_PCM(GRAT);
|
|
|
|
HANDLE_PCM(LRAT);
|
|
|
|
HANDLE_PCM(CRAT);
|
|
|
|
HANDLE_PCM(RESV);
|
|
|
|
HANDLE_PCM(PRBL);
|
|
|
|
HANDLE_PCM(BHP);
|
|
|
|
HANDLE_PCM(THP);
|
|
|
|
HANDLE_PCM(GRUP);
|
|
|
|
HANDLE_PCM(FLD);
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Unknown type " << type << ", could not convert to ProductionSpecification::ControlMode.");
|
2012-04-11 03:56:08 -05:00
|
|
|
}
|
2012-05-02 02:39:05 -05:00
|
|
|
#undef HANDLE_PCM
|
2012-04-13 03:32:36 -05:00
|
|
|
|
2012-04-11 03:56:08 -05:00
|
|
|
ProductionSpecification::Procedure toProductionProcedure(std::string type)
|
|
|
|
{
|
|
|
|
if (type == "NONE") {
|
|
|
|
return ProductionSpecification::NONE_P;
|
|
|
|
}
|
|
|
|
if (type == "RATE") {
|
|
|
|
return ProductionSpecification::RATE;
|
|
|
|
}
|
|
|
|
if (type == "WELL") {
|
|
|
|
return ProductionSpecification::WELL;
|
|
|
|
}
|
2012-04-13 03:32:36 -05:00
|
|
|
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Unknown type " << type << ", could not convert to ControlMode.");
|
2012-04-11 03:56:08 -05:00
|
|
|
}
|
|
|
|
} // anonymous namespace
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2014-02-11 07:12:36 -06:00
|
|
|
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(GroupConstPtr group, size_t timeStep, const PhaseUsage& phase_usage )
|
|
|
|
{
|
|
|
|
InjectionSpecification injection_specification;
|
2014-02-14 01:14:30 -06:00
|
|
|
ProductionSpecification production_specification;
|
2014-02-11 07:12:36 -06:00
|
|
|
if (group->isInjectionGroup(timeStep)) {
|
|
|
|
injection_specification.injector_type_ = toInjectorType(Phase::PhaseEnum2String(group->getInjectionPhase(timeStep)));
|
|
|
|
injection_specification.control_mode_ = toInjectionControlMode(GroupInjection::ControlEnum2String(group->getInjectionControlMode(timeStep)));
|
|
|
|
injection_specification.surface_flow_max_rate_ = group->getSurfaceMaxRate(timeStep);
|
|
|
|
injection_specification.reservoir_flow_max_rate_ = group->getReservoirMaxRate(timeStep);
|
|
|
|
injection_specification.reinjection_fraction_target_ = group->getTargetReinjectFraction(timeStep);
|
|
|
|
injection_specification.voidage_replacment_fraction_ = group->getTargetVoidReplacementFraction(timeStep);
|
|
|
|
}
|
2014-02-14 01:14:30 -06:00
|
|
|
else if (group->isProductionGroup(timeStep)) {
|
2014-02-11 07:12:36 -06:00
|
|
|
production_specification.oil_max_rate_ = group->getOilTargetRate(timeStep);
|
|
|
|
production_specification.control_mode_ = toProductionControlMode(GroupProduction::ControlEnum2String(group->getProductionControlMode(timeStep)));
|
|
|
|
production_specification.water_max_rate_ = group->getWaterTargetRate(timeStep);
|
|
|
|
production_specification.gas_max_rate_ = group->getGasTargetRate(timeStep);
|
|
|
|
production_specification.liquid_max_rate_ = group->getLiquidTargetRate(timeStep);
|
|
|
|
production_specification.procedure_ = toProductionProcedure(GroupProductionExceedLimit::ActionEnum2String(group->getProductionExceedLimitAction(timeStep)));
|
2015-08-13 03:21:24 -05:00
|
|
|
production_specification.reservoir_flow_max_rate_ = group->getReservoirVolumeTargetRate(timeStep);
|
2014-02-11 07:12:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<WellsGroupInterface> wells_group(new WellsGroup(group->name(), production_specification, injection_specification, phase_usage));
|
|
|
|
return wells_group;
|
|
|
|
}
|
|
|
|
|
2014-10-14 05:34:58 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
Wells which are shut with the WELOPEN or WCONPROD keywords
|
|
|
|
typically will not have any valid control settings, it is then
|
|
|
|
impossible to set a valid control mode. The Schedule::Well
|
|
|
|
objects from opm-parser have the possible well controle mode
|
|
|
|
'CMODE_UNDEFINED' - we do not carry that over the specification
|
|
|
|
objects here.
|
|
|
|
*/
|
2014-02-11 07:12:36 -06:00
|
|
|
std::shared_ptr<WellsGroupInterface> createWellWellsGroup(WellConstPtr well, size_t timeStep, const PhaseUsage& phase_usage )
|
|
|
|
{
|
|
|
|
InjectionSpecification injection_specification;
|
|
|
|
ProductionSpecification production_specification;
|
|
|
|
if (well->isInjector(timeStep)) {
|
2014-03-20 18:35:15 -05:00
|
|
|
const WellInjectionProperties& properties = well->getInjectionProperties(timeStep);
|
|
|
|
injection_specification.BHP_limit_ = properties.BHPLimit;
|
|
|
|
injection_specification.injector_type_ = toInjectorType(WellInjector::Type2String(properties.injectorType));
|
|
|
|
injection_specification.surface_flow_max_rate_ = properties.surfaceInjectionRate;
|
|
|
|
injection_specification.reservoir_flow_max_rate_ = properties.reservoirInjectionRate;
|
2014-02-11 07:12:36 -06:00
|
|
|
production_specification.guide_rate_ = 0.0; // We know we're not a producer
|
2014-10-14 05:34:58 -05:00
|
|
|
if (properties.controlMode != WellInjector::CMODE_UNDEFINED) {
|
|
|
|
injection_specification.control_mode_ = toInjectionControlMode(WellInjector::ControlMode2String(properties.controlMode));
|
|
|
|
}
|
2014-02-11 07:12:36 -06:00
|
|
|
}
|
2014-02-14 01:14:30 -06:00
|
|
|
else if (well->isProducer(timeStep)) {
|
2014-03-20 18:35:15 -05:00
|
|
|
const WellProductionProperties& properties = well->getProductionProperties(timeStep);
|
|
|
|
production_specification.BHP_limit_ = properties.BHPLimit;
|
|
|
|
production_specification.reservoir_flow_max_rate_ = properties.ResVRate;
|
|
|
|
production_specification.oil_max_rate_ = properties.OilRate;
|
|
|
|
production_specification.water_max_rate_ = properties.WaterRate;
|
2014-02-11 07:12:36 -06:00
|
|
|
injection_specification.guide_rate_ = 0.0; // we know we're not an injector
|
2014-10-14 05:34:58 -05:00
|
|
|
if (properties.controlMode != WellProducer::CMODE_UNDEFINED) {
|
|
|
|
production_specification.control_mode_ = toProductionControlMode(WellProducer::ControlMode2String(properties.controlMode));
|
|
|
|
}
|
2014-02-11 07:12:36 -06:00
|
|
|
}
|
|
|
|
std::shared_ptr<WellsGroupInterface> wells_group(new WellNode(well->name(), production_specification, injection_specification, phase_usage));
|
|
|
|
return wells_group;
|
|
|
|
}
|
2012-04-11 03:49:45 -05:00
|
|
|
}
|