mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Move Rateconverter and pvtIdx to the wellInterface
This commit is contained in:
@@ -221,13 +221,14 @@ namespace Opm {
|
|||||||
|
|
||||||
const Well* well_ecl = wells_ecl_[index_well];
|
const Well* well_ecl = wells_ecl_[index_well];
|
||||||
|
|
||||||
|
// Use the pvtRegionIdx from the top cell
|
||||||
const int well_cell_top = wells()->well_cells[wells()->well_connpos[w]];
|
const int well_cell_top = wells()->well_cells[wells()->well_connpos[w]];
|
||||||
const int pvtreg = pvt_region_idx_[well_cell_top];
|
const int pvtreg = pvt_region_idx_[well_cell_top];
|
||||||
|
|
||||||
if ( !well_ecl->isMultiSegment(time_step) || !param_.use_multisegment_well_) {
|
if ( !well_ecl->isMultiSegment(time_step) || !param_.use_multisegment_well_) {
|
||||||
well_container.emplace_back(new StandardWell<TypeTag>(well_ecl, time_step, wells(), param_, *rateConverter_, pvtreg ) );
|
well_container.emplace_back(new StandardWell<TypeTag>(well_ecl, time_step, wells(), param_, *rateConverter_, pvtreg ) );
|
||||||
} else {
|
} else {
|
||||||
well_container.emplace_back(new MultisegmentWell<TypeTag>(well_ecl, time_step, wells(), param_) );
|
well_container.emplace_back(new MultisegmentWell<TypeTag>(well_ecl, time_step, wells(), param_, *rateConverter_, pvtreg) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ namespace Opm
|
|||||||
using typename Base::ModelParameters;
|
using typename Base::ModelParameters;
|
||||||
using typename Base::MaterialLaw;
|
using typename Base::MaterialLaw;
|
||||||
using typename Base::BlackoilIndices;
|
using typename Base::BlackoilIndices;
|
||||||
|
using typename Base::RateConverterType;
|
||||||
|
|
||||||
|
|
||||||
/// the number of reservior equations
|
/// the number of reservior equations
|
||||||
using Base::numEq;
|
using Base::numEq;
|
||||||
@@ -97,7 +99,10 @@ namespace Opm
|
|||||||
// TODO: for now, we only use one type to save some implementation efforts, while improve later.
|
// TODO: for now, we only use one type to save some implementation efforts, while improve later.
|
||||||
typedef DenseAd::Evaluation<double, /*size=*/numEq + numWellEq> EvalWell;
|
typedef DenseAd::Evaluation<double, /*size=*/numEq + numWellEq> EvalWell;
|
||||||
|
|
||||||
MultisegmentWell(const Well* well, const int time_step, const Wells* wells, const ModelParameters& param);
|
MultisegmentWell(const Well* well, const int time_step, const Wells* wells,
|
||||||
|
const ModelParameters& param,
|
||||||
|
const RateConverterType& rate_converter,
|
||||||
|
const int pvtRegionIdx);
|
||||||
|
|
||||||
virtual void init(const PhaseUsage* phase_usage_arg,
|
virtual void init(const PhaseUsage* phase_usage_arg,
|
||||||
const std::vector<bool>* active_arg,
|
const std::vector<bool>* active_arg,
|
||||||
@@ -188,6 +193,7 @@ namespace Opm
|
|||||||
using Base::flowPhaseToEbosPhaseIdx;
|
using Base::flowPhaseToEbosPhaseIdx;
|
||||||
using Base::flowPhaseToEbosCompIdx;
|
using Base::flowPhaseToEbosCompIdx;
|
||||||
using Base::getAllowCrossFlow;
|
using Base::getAllowCrossFlow;
|
||||||
|
using Base::scalingFactor;
|
||||||
|
|
||||||
// TODO: trying to use the information from the Well opm-parser as much
|
// TODO: trying to use the information from the Well opm-parser as much
|
||||||
// as possible, it will possibly be re-implemented later for efficiency reason.
|
// as possible, it will possibly be re-implemented later for efficiency reason.
|
||||||
@@ -329,8 +335,6 @@ namespace Opm
|
|||||||
|
|
||||||
void updateWellStateFromPrimaryVariables(WellState& well_state) const;
|
void updateWellStateFromPrimaryVariables(WellState& well_state) const;
|
||||||
|
|
||||||
double scalingFactor(const int comp_idx) const;
|
|
||||||
|
|
||||||
bool frictionalPressureLossConsidered() const;
|
bool frictionalPressureLossConsidered() const;
|
||||||
|
|
||||||
bool accelerationalPressureLossConsidered() const;
|
bool accelerationalPressureLossConsidered() const;
|
||||||
|
|||||||
@@ -27,8 +27,11 @@ namespace Opm
|
|||||||
|
|
||||||
template <typename TypeTag>
|
template <typename TypeTag>
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
MultisegmentWell(const Well* well, const int time_step, const Wells* wells, const ModelParameters& param)
|
MultisegmentWell(const Well* well, const int time_step, const Wells* wells,
|
||||||
: Base(well, time_step, wells, param)
|
const ModelParameters& param,
|
||||||
|
const RateConverterType& rate_converter,
|
||||||
|
const int pvtRegionIdx)
|
||||||
|
: Base(well, time_step, wells, param, rate_converter, pvtRegionIdx)
|
||||||
, segment_perforations_(numberOfSegments())
|
, segment_perforations_(numberOfSegments())
|
||||||
, segment_inlets_(numberOfSegments())
|
, segment_inlets_(numberOfSegments())
|
||||||
, cell_perforation_depth_diffs_(number_of_perforations_, 0.0)
|
, cell_perforation_depth_diffs_(number_of_perforations_, 0.0)
|
||||||
@@ -1666,40 +1669,6 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename TypeTag>
|
|
||||||
double
|
|
||||||
MultisegmentWell<TypeTag>::
|
|
||||||
scalingFactor(const int comp_idx) const
|
|
||||||
{
|
|
||||||
const double* distr = well_controls_get_current_distr(well_controls_);
|
|
||||||
|
|
||||||
if (well_controls_get_current_type(well_controls_) == RESERVOIR_RATE) {
|
|
||||||
// if (has_solvent && phaseIdx == contiSolventEqIdx )
|
|
||||||
// OPM_THROW(std::runtime_error, "RESERVOIR_RATE control in combination with solvent is not implemented");
|
|
||||||
return distr[comp_idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
const PhaseUsage& pu = phaseUsage();
|
|
||||||
|
|
||||||
if (active()[Water] && pu.phase_pos[Water] == comp_idx)
|
|
||||||
return 1.0;
|
|
||||||
if (active()[Oil] && pu.phase_pos[Oil] == comp_idx)
|
|
||||||
return 1.0;
|
|
||||||
if (active()[Gas] && pu.phase_pos[Gas] == comp_idx)
|
|
||||||
return 0.01;
|
|
||||||
// if (has_solvent && phaseIdx == contiSolventEqIdx )
|
|
||||||
// return 0.01;
|
|
||||||
|
|
||||||
// we should not come this far
|
|
||||||
assert(false);
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename TypeTag>
|
template <typename TypeTag>
|
||||||
bool
|
bool
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace Opm
|
|||||||
using typename Base::ModelParameters;
|
using typename Base::ModelParameters;
|
||||||
using typename Base::BlackoilIndices;
|
using typename Base::BlackoilIndices;
|
||||||
using typename Base::PolymerModule;
|
using typename Base::PolymerModule;
|
||||||
|
using typename Base::RateConverterType;
|
||||||
|
|
||||||
using Base::numEq;
|
using Base::numEq;
|
||||||
|
|
||||||
@@ -105,10 +106,6 @@ namespace Opm
|
|||||||
|
|
||||||
typedef DenseAd::Evaluation<double, /*size=*/numEq + numWellEq> EvalWell;
|
typedef DenseAd::Evaluation<double, /*size=*/numEq + numWellEq> EvalWell;
|
||||||
|
|
||||||
// For the conversion between the surface volume rate and resrevoir voidage rate
|
|
||||||
using RateConverterType = RateConverter::
|
|
||||||
SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
|
|
||||||
|
|
||||||
// TODO: should these go to WellInterface?
|
// TODO: should these go to WellInterface?
|
||||||
static const int contiSolventEqIdx = BlackoilIndices::contiSolventEqIdx;
|
static const int contiSolventEqIdx = BlackoilIndices::contiSolventEqIdx;
|
||||||
static const int contiPolymerEqIdx = BlackoilIndices::contiPolymerEqIdx;
|
static const int contiPolymerEqIdx = BlackoilIndices::contiPolymerEqIdx;
|
||||||
@@ -177,6 +174,7 @@ namespace Opm
|
|||||||
using Base::wpolymer;
|
using Base::wpolymer;
|
||||||
using Base::wellHasTHPConstraints;
|
using Base::wellHasTHPConstraints;
|
||||||
using Base::mostStrictBhpFromBhpLimits;
|
using Base::mostStrictBhpFromBhpLimits;
|
||||||
|
using Base::scalingFactor;
|
||||||
|
|
||||||
// protected member variables from the Base class
|
// protected member variables from the Base class
|
||||||
using Base::vfp_properties_;
|
using Base::vfp_properties_;
|
||||||
@@ -228,9 +226,6 @@ namespace Opm
|
|||||||
// the saturations in the well bore under surface conditions at the beginning of the time step
|
// the saturations in the well bore under surface conditions at the beginning of the time step
|
||||||
std::vector<double> F0_;
|
std::vector<double> F0_;
|
||||||
|
|
||||||
const RateConverterType& rateConverter_;
|
|
||||||
int pvtRegionIdx_;
|
|
||||||
|
|
||||||
// TODO: this function should be moved to the base class.
|
// TODO: this function should be moved to the base class.
|
||||||
// while it faces chanllenges for MSWell later, since the calculation of bhp
|
// while it faces chanllenges for MSWell later, since the calculation of bhp
|
||||||
// based on THP is never implemented for MSWell yet.
|
// based on THP is never implemented for MSWell yet.
|
||||||
@@ -313,7 +308,6 @@ namespace Opm
|
|||||||
const int perf,
|
const int perf,
|
||||||
std::vector<EvalWell>& mob) const;
|
std::vector<EvalWell>& mob) const;
|
||||||
|
|
||||||
double scalingFactor(const int comp_idx) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,14 +28,12 @@ namespace Opm
|
|||||||
const ModelParameters& param,
|
const ModelParameters& param,
|
||||||
const RateConverterType& rate_converter,
|
const RateConverterType& rate_converter,
|
||||||
const int pvtRegionIdx)
|
const int pvtRegionIdx)
|
||||||
: Base(well, time_step, wells, param)
|
: Base(well, time_step, wells, param, rate_converter, pvtRegionIdx)
|
||||||
, perf_densities_(number_of_perforations_)
|
, perf_densities_(number_of_perforations_)
|
||||||
, perf_pressure_diffs_(number_of_perforations_)
|
, perf_pressure_diffs_(number_of_perforations_)
|
||||||
, primary_variables_(numWellEq, 0.0)
|
, primary_variables_(numWellEq, 0.0)
|
||||||
, primary_variables_evaluation_(numWellEq) // the number of the primary variables
|
, primary_variables_evaluation_(numWellEq) // the number of the primary variables
|
||||||
, F0_(numWellEq)
|
, F0_(numWellEq)
|
||||||
, rateConverter_(rate_converter)
|
|
||||||
, pvtRegionIdx_(pvtRegionIdx)
|
|
||||||
{
|
{
|
||||||
duneB_.setBuildMode( OffDiagMatWell::row_wise );
|
duneB_.setBuildMode( OffDiagMatWell::row_wise );
|
||||||
duneC_.setBuildMode( OffDiagMatWell::row_wise );
|
duneC_.setBuildMode( OffDiagMatWell::row_wise );
|
||||||
@@ -1984,37 +1982,7 @@ namespace Opm
|
|||||||
return thp;
|
return thp;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TypeTag>
|
|
||||||
double
|
|
||||||
StandardWell<TypeTag>::scalingFactor(const int phaseIdx) const
|
|
||||||
{
|
|
||||||
const WellControls* wc = well_controls_;
|
|
||||||
const double* distr = well_controls_get_current_distr(wc);
|
|
||||||
|
|
||||||
if (well_controls_get_current_type(wc) == RESERVOIR_RATE) {
|
|
||||||
if (has_solvent && phaseIdx == contiSolventEqIdx ) {
|
|
||||||
typedef Ewoms::BlackOilSolventModule<TypeTag> SolventModule;
|
|
||||||
double coeff = 0;
|
|
||||||
rateConverter_.template calcCoeffSolvent<SolventModule>(0, pvtRegionIdx_, coeff);
|
|
||||||
return coeff;
|
|
||||||
}
|
|
||||||
// TODO: use the rateConverter here as well.
|
|
||||||
return distr[phaseIdx];
|
|
||||||
}
|
|
||||||
const auto& pu = phaseUsage();
|
|
||||||
if (active()[Water] && pu.phase_pos[Water] == phaseIdx)
|
|
||||||
return 1.0;
|
|
||||||
if (active()[Oil] && pu.phase_pos[Oil] == phaseIdx)
|
|
||||||
return 1.0;
|
|
||||||
if (active()[Gas] && pu.phase_pos[Gas] == phaseIdx)
|
|
||||||
return 0.01;
|
|
||||||
if (has_solvent && phaseIdx == contiSolventEqIdx )
|
|
||||||
return 0.01;
|
|
||||||
|
|
||||||
// we should not come this far
|
|
||||||
assert(false);
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
||||||
Copyright 2017 Statoil ASA.
|
Copyright 2017 Statoil ASA.
|
||||||
|
Copyright 2017 IRIS
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
This file is part of the Open Porous Media project (OPM).
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
#include <opm/autodiff/WellHelpers.hpp>
|
#include <opm/autodiff/WellHelpers.hpp>
|
||||||
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
||||||
#include <opm/autodiff/BlackoilModelParameters.hpp>
|
#include <opm/autodiff/BlackoilModelParameters.hpp>
|
||||||
|
#include <opm/autodiff/RateConverter.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/WellSwitchingLogger.hpp>
|
#include <opm/simulators/WellSwitchingLogger.hpp>
|
||||||
|
|
||||||
@@ -89,9 +91,18 @@ namespace Opm
|
|||||||
|
|
||||||
static const bool has_solvent = GET_PROP_VALUE(TypeTag, EnableSolvent);
|
static const bool has_solvent = GET_PROP_VALUE(TypeTag, EnableSolvent);
|
||||||
static const bool has_polymer = GET_PROP_VALUE(TypeTag, EnablePolymer);
|
static const bool has_polymer = GET_PROP_VALUE(TypeTag, EnablePolymer);
|
||||||
|
static const int contiSolventEqIdx = BlackoilIndices::contiSolventEqIdx;
|
||||||
|
|
||||||
|
|
||||||
|
// For the conversion between the surface volume rate and resrevoir voidage rate
|
||||||
|
using RateConverterType = RateConverter::
|
||||||
|
SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
WellInterface(const Well* well, const int time_step, const Wells* wells, const ModelParameters& param);
|
WellInterface(const Well* well, const int time_step, const Wells* wells,
|
||||||
|
const ModelParameters& param,
|
||||||
|
const RateConverterType& rate_converter,
|
||||||
|
const int pvtRegionIdx);
|
||||||
|
|
||||||
/// Virutal destructor
|
/// Virutal destructor
|
||||||
virtual ~WellInterface() {}
|
virtual ~WellInterface() {}
|
||||||
@@ -264,6 +275,13 @@ namespace Opm
|
|||||||
|
|
||||||
double gravity_;
|
double gravity_;
|
||||||
|
|
||||||
|
// For the conversion between the surface volume rate and resrevoir voidage rate
|
||||||
|
const RateConverterType& rateConverter_;
|
||||||
|
|
||||||
|
// The pvt region of the well. We assume
|
||||||
|
// We assume a well to not penetrate more than one pvt region.
|
||||||
|
int pvtRegionIdx_;
|
||||||
|
|
||||||
const std::vector<bool>& active() const;
|
const std::vector<bool>& active() const;
|
||||||
|
|
||||||
const PhaseUsage& phaseUsage() const;
|
const PhaseUsage& phaseUsage() const;
|
||||||
@@ -304,6 +322,9 @@ namespace Opm
|
|||||||
RatioCheckTuple checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
|
RatioCheckTuple checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
|
||||||
const WellState& well_state) const;
|
const WellState& well_state) const;
|
||||||
|
|
||||||
|
double scalingFactor(const int comp_idx) const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,15 @@ namespace Opm
|
|||||||
|
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
WellInterface<TypeTag>::
|
WellInterface<TypeTag>::
|
||||||
WellInterface(const Well* well, const int time_step, const Wells* wells, const ModelParameters& param)
|
WellInterface(const Well* well, const int time_step, const Wells* wells,
|
||||||
|
const ModelParameters& param,
|
||||||
|
const RateConverterType& rate_converter,
|
||||||
|
const int pvtRegionIdx)
|
||||||
: well_ecl_(well)
|
: well_ecl_(well)
|
||||||
, current_step_(time_step)
|
, current_step_(time_step)
|
||||||
, param_(param)
|
, param_(param)
|
||||||
|
, rateConverter_(rate_converter)
|
||||||
|
, pvtRegionIdx_(pvtRegionIdx)
|
||||||
{
|
{
|
||||||
if (!well) {
|
if (!well) {
|
||||||
OPM_THROW(std::invalid_argument, "Null pointer of Well is used to construct WellInterface");
|
OPM_THROW(std::invalid_argument, "Null pointer of Well is used to construct WellInterface");
|
||||||
@@ -850,4 +855,36 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename TypeTag>
|
||||||
|
double
|
||||||
|
WellInterface<TypeTag>::scalingFactor(const int phaseIdx) const
|
||||||
|
{
|
||||||
|
const WellControls* wc = well_controls_;
|
||||||
|
const double* distr = well_controls_get_current_distr(wc);
|
||||||
|
|
||||||
|
if (well_controls_get_current_type(wc) == RESERVOIR_RATE) {
|
||||||
|
if (has_solvent && phaseIdx == contiSolventEqIdx ) {
|
||||||
|
typedef Ewoms::BlackOilSolventModule<TypeTag> SolventModule;
|
||||||
|
double coeff = 0;
|
||||||
|
rateConverter_.template calcCoeffSolvent<SolventModule>(0, pvtRegionIdx_, coeff);
|
||||||
|
return coeff;
|
||||||
|
}
|
||||||
|
// TODO: use the rateConverter here as well.
|
||||||
|
return distr[phaseIdx];
|
||||||
|
}
|
||||||
|
const auto& pu = phaseUsage();
|
||||||
|
if (active()[Water] && pu.phase_pos[Water] == phaseIdx)
|
||||||
|
return 1.0;
|
||||||
|
if (active()[Oil] && pu.phase_pos[Oil] == phaseIdx)
|
||||||
|
return 1.0;
|
||||||
|
if (active()[Gas] && pu.phase_pos[Gas] == phaseIdx)
|
||||||
|
return 0.01;
|
||||||
|
if (has_solvent && phaseIdx == contiSolventEqIdx )
|
||||||
|
return 0.01;
|
||||||
|
|
||||||
|
// we should not come this far
|
||||||
|
assert(false);
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user