2017-06-15 04:34:07 -05:00
|
|
|
/*
|
|
|
|
Copyright 2017 SINTEF ICT, Applied Mathematics.
|
|
|
|
Copyright 2017 Statoil ASA.
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 10:19:49 -05:00
|
|
|
WellInterface(const Well* well, const int time_step, const Wells* wells)
|
2017-06-15 04:34:07 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: trying to use wells struct as little as possible here, be prepared to
|
|
|
|
// remove the wells struct in future
|
|
|
|
const std::string& well_name = well->name();
|
|
|
|
|
|
|
|
// looking for the location of the well in the wells struct
|
|
|
|
int index_well;
|
|
|
|
for (index_well = 0; index_well < wells->number_of_wells; ++index_well) {
|
|
|
|
if (well_name == std::string(wells->name[index_well])) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// should not enter the constructor if the well does not exist in the wells struct
|
|
|
|
// here, just another assertion.
|
|
|
|
assert(index_well != wells->number_of_wells);
|
|
|
|
|
|
|
|
name_ = well_name;
|
|
|
|
index_of_well_ = index_well;
|
|
|
|
well_type_ = wells->type[index_well];
|
2017-06-21 07:07:11 -05:00
|
|
|
allow_cf_ = wells->allow_cf[index_well];
|
2017-06-15 04:34:07 -05:00
|
|
|
number_of_phases_ = wells->number_of_phases;
|
|
|
|
|
|
|
|
// copying the comp_frac
|
|
|
|
{
|
|
|
|
comp_frac_.resize(number_of_phases_);
|
|
|
|
const int index_begin = index_well * number_of_phases_;
|
|
|
|
std::copy(wells->comp_frac + index_begin,
|
|
|
|
wells->comp_frac + index_begin + number_of_phases_, comp_frac_.begin() );
|
|
|
|
}
|
|
|
|
|
|
|
|
well_controls_ = wells->ctrls[index_well];
|
|
|
|
|
2017-06-23 09:32:43 -05:00
|
|
|
ref_depth_ = wells->depth_ref[index_well];
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
// perforations related
|
|
|
|
{
|
|
|
|
const int perf_index_begin = wells->well_connpos[index_well];
|
|
|
|
const int perf_index_end = wells->well_connpos[index_well + 1];
|
|
|
|
number_of_perforations_ = perf_index_end - perf_index_begin;
|
2017-06-23 07:55:56 -05:00
|
|
|
first_perf_ = perf_index_begin;
|
2017-06-15 04:34:07 -05:00
|
|
|
|
|
|
|
well_cell_.resize(number_of_perforations_);
|
|
|
|
std::copy(wells->well_cells + perf_index_begin,
|
|
|
|
wells->well_cells + perf_index_end,
|
|
|
|
well_cell_.begin() );
|
|
|
|
|
|
|
|
well_index_.resize(number_of_perforations_);
|
|
|
|
std::copy(wells->WI + perf_index_begin,
|
|
|
|
wells->WI + perf_index_end,
|
|
|
|
well_index_.begin() );
|
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
saturation_table_number_.resize(number_of_perforations_);
|
|
|
|
std::copy(wells->sat_table_id + perf_index_begin,
|
|
|
|
wells->sat_table_id + perf_index_end,
|
|
|
|
saturation_table_number_.begin() );
|
|
|
|
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
// TODO: not sure about the processing of depth for perforations here
|
|
|
|
// Will revisit here later. There are different ways and the definition for different wells
|
|
|
|
// can be different, it is possible that we need to remove this from the WellInterface
|
|
|
|
perf_depth_.resize(number_of_perforations_, 0.);
|
|
|
|
const auto& completion_set = well->getCompletions(time_step);
|
|
|
|
for (int i = 0; i < number_of_perforations_; ++i) {
|
|
|
|
perf_depth_[i] = completion_set.get(i).getCenterDepth();
|
|
|
|
}
|
|
|
|
}
|
2017-06-21 07:07:11 -05:00
|
|
|
|
|
|
|
well_efficiency_factor_ = 1.0;
|
|
|
|
// TODO: need to calculate based on wellCollections, or it should happen in the Well Model side.
|
2017-06-15 04:34:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
void
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
init(const PhaseUsage* phase_usage_arg,
|
|
|
|
const std::vector<bool>* active_arg,
|
|
|
|
const VFPProperties* vfp_properties_arg,
|
2017-06-21 07:07:11 -05:00
|
|
|
const double gravity_arg,
|
|
|
|
const int /* num_cells */)
|
2017-06-15 04:34:07 -05:00
|
|
|
{
|
|
|
|
phase_usage_ = phase_usage_arg;
|
|
|
|
active_ = active_arg;
|
|
|
|
vfp_properties_ = vfp_properties_arg;
|
|
|
|
gravity_ = gravity_arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
const std::string&
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
name() const
|
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
int
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
indexOfWell() const
|
|
|
|
{
|
|
|
|
return index_of_well_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
WellType
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
wellType() const
|
|
|
|
{
|
|
|
|
return well_type_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
int
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
numberOfPhases() const
|
|
|
|
{
|
|
|
|
return number_of_phases_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
const std::vector<double>&
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
compFrac() const
|
|
|
|
{
|
|
|
|
return comp_frac_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
WellControls*
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
wellControls() const
|
|
|
|
{
|
|
|
|
return well_controls_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
template<typename TypeTag>
|
|
|
|
const std::vector<int>&
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
saturationTableNumber() const
|
|
|
|
{
|
|
|
|
return saturation_table_number_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
int
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
numberOfPerforations() const
|
|
|
|
{
|
|
|
|
return number_of_perforations_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
const std::vector<double>&
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
wellIndex() const
|
|
|
|
{
|
|
|
|
return well_index_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
const std::vector<double>&
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
perfDepth() const
|
|
|
|
{
|
|
|
|
return perf_depth_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
const std::vector<int>&
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
wellCells() const
|
|
|
|
{
|
|
|
|
return well_cell_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
const std::vector<bool>&
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
active() const
|
|
|
|
{
|
|
|
|
assert(active_);
|
|
|
|
|
|
|
|
return *active_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-27 05:17:36 -05:00
|
|
|
template<typename TypeTag>
|
|
|
|
bool
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
allowCrossFlow() const
|
|
|
|
{
|
|
|
|
return allow_cf_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
const PhaseUsage&
|
2017-06-19 07:49:49 -05:00
|
|
|
WellInterface<TypeTag>::
|
2017-06-15 04:34:07 -05:00
|
|
|
phaseUsage() const
|
|
|
|
{
|
|
|
|
assert(phase_usage_);
|
|
|
|
|
|
|
|
return *phase_usage_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-19 08:05:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
int
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
flowPhaseToEbosCompIdx( const int phaseIdx ) const
|
|
|
|
{
|
2017-06-27 09:04:04 -05:00
|
|
|
const int phaseToComp[ 3 ] = { FluidSystem::waterCompIdx, FluidSystem::oilCompIdx, FluidSystem::gasCompIdx};
|
|
|
|
if (phaseIdx > 2 )
|
|
|
|
return phaseIdx;
|
2017-06-19 08:05:15 -05:00
|
|
|
return phaseToComp[ phaseIdx ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
int
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
flowToEbosPvIdx( const int flowPv ) const
|
|
|
|
{
|
2017-06-27 09:04:04 -05:00
|
|
|
const int flowToEbos[ 3 ] = {
|
|
|
|
BlackoilIndices::pressureSwitchIdx,
|
|
|
|
BlackoilIndices::waterSaturationIdx,
|
|
|
|
BlackoilIndices::compositionSwitchIdx
|
|
|
|
};
|
|
|
|
|
|
|
|
if (flowPv > 2 )
|
|
|
|
return flowPv;
|
|
|
|
|
2017-06-19 08:05:15 -05:00
|
|
|
return flowToEbos[ flowPv ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
int
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
flowPhaseToEbosPhaseIdx( const int phaseIdx ) const
|
|
|
|
{
|
|
|
|
assert(phaseIdx < 3);
|
|
|
|
const int flowToEbos[ 3 ] = { FluidSystem::waterPhaseIdx, FluidSystem::oilPhaseIdx, FluidSystem::gasPhaseIdx };
|
|
|
|
return flowToEbos[ phaseIdx ];
|
|
|
|
}
|
|
|
|
|
2017-06-19 09:46:06 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
int
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
numPhases() const
|
|
|
|
{
|
|
|
|
return number_of_phases_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
int
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
numComponents() const
|
|
|
|
{
|
|
|
|
if (numPhases() == 2) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
int numComp = FluidSystem::numComponents;
|
|
|
|
|
|
|
|
if (has_solvent) {
|
|
|
|
numComp ++;
|
|
|
|
}
|
|
|
|
return numComp;
|
|
|
|
}
|
|
|
|
|
2017-06-23 03:58:46 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
2017-07-24 07:48:57 -05:00
|
|
|
double
|
2017-06-23 03:58:46 -05:00
|
|
|
WellInterface<TypeTag>::
|
|
|
|
wsolvent() const
|
|
|
|
{
|
|
|
|
// TODO: not handling it for the moment
|
|
|
|
// TODO: it needs information from the well_ecl
|
|
|
|
// TODO: will decide on well_ecl role later.
|
|
|
|
// It can be just one member variable and no need to deal with well_ecl at all
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2017-07-24 07:48:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
double
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
mostStrictBhpFromBhpLimits() const
|
|
|
|
{
|
|
|
|
double bhp;
|
|
|
|
|
|
|
|
// initial bhp value, making the value not usable
|
|
|
|
switch( well_type_ ) {
|
|
|
|
case INJECTOR:
|
|
|
|
bhp = std::numeric_limits<double>::max();
|
|
|
|
break;
|
|
|
|
case PRODUCER:
|
|
|
|
bhp = -std::numeric_limits<double>::max();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OPM_THROW(std::logic_error, "Expected PRODUCER or INJECTOR type for well " << name());
|
|
|
|
}
|
|
|
|
|
|
|
|
// The number of the well controls/constraints
|
|
|
|
const int nwc = well_controls_get_num(well_controls_);
|
|
|
|
|
|
|
|
for (int ctrl_index = 0; ctrl_index < nwc; ++ctrl_index) {
|
|
|
|
// finding a BHP constraint
|
|
|
|
if (well_controls_iget_type(well_controls_, ctrl_index) == BHP) {
|
|
|
|
// get the bhp constraint value, it should always be postive assummingly
|
|
|
|
const double bhp_target = well_controls_iget_target(well_controls_, ctrl_index);
|
|
|
|
|
|
|
|
switch(well_type_) {
|
|
|
|
case INJECTOR: // using the lower bhp contraint from Injectors
|
|
|
|
if (bhp_target < bhp) {
|
|
|
|
bhp = bhp_target;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PRODUCER:
|
|
|
|
if (bhp_target > bhp) {
|
|
|
|
bhp = bhp_target;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OPM_THROW(std::logic_error, "Expected PRODUCER or INJECTOR type for well " << name());
|
|
|
|
} // end of switch
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bhp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
bool
|
|
|
|
WellInterface<TypeTag>::
|
|
|
|
wellHasTHPConstraints() const
|
|
|
|
{
|
|
|
|
const int nwc = well_controls_get_num(well_controls_);
|
|
|
|
for (int ctrl_index = 0; ctrl_index < nwc; ++ctrl_index) {
|
|
|
|
if (well_controls_iget_type(well_controls_, ctrl_index) == THP) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-15 04:34:07 -05:00
|
|
|
}
|