GasLiftSingleWellGeneric: template Scalar type

This commit is contained in:
Arne Morten Kvarving 2024-02-20 08:24:50 +01:00
parent 25de745dab
commit 09065dd130
10 changed files with 667 additions and 460 deletions

View File

@ -115,7 +115,7 @@ namespace Opm {
using GLiftWellStateMap =
typename BlackoilWellModelGeneric<Scalar>::GLiftWellStateMap;
using GLiftEclWells = typename GasLiftGroupInfo<Scalar>::GLiftEclWells;
using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups;
using GLiftSyncGroups = typename GasLiftSingleWellGeneric<Scalar>::GLiftSyncGroups;
constexpr static std::size_t pressureVarIndex = GetPropType<TypeTag, Properties::Indices>::pressureSwitchIdx;
typedef typename BaseAuxiliaryModule<TypeTag>::NeighborSet NeighborSet;

View File

@ -54,7 +54,7 @@ namespace Opm {
class DeferredLogger;
class EclipseState;
template<class Scalar> class GasLiftGroupInfo;
class GasLiftSingleWellGeneric;
template<class Scalar> class GasLiftSingleWellGeneric;
template<class Scalar> class GasLiftWellState;
class Group;
class GuideRateConfig;
@ -83,7 +83,7 @@ class BlackoilWellModelGeneric
{
public:
// --------- Types ---------
using GLiftOptWells = std::map<std::string, std::unique_ptr<GasLiftSingleWellGeneric>>;
using GLiftOptWells = std::map<std::string, std::unique_ptr<GasLiftSingleWellGeneric<Scalar>>>;
using GLiftProdWells = std::map<std::string, const WellInterfaceGeneric*>;
using GLiftWellStateMap = std::map<std::string, std::unique_ptr<GasLiftWellState<Scalar>>>;

View File

@ -34,11 +34,12 @@
namespace Opm
{
template<class TypeTag>
class GasLiftSingleWell : public GasLiftSingleWellGeneric
class GasLiftSingleWell : public GasLiftSingleWellGeneric<GetPropType<TypeTag, Properties::Scalar>>
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups;
using GLiftSyncGroups = typename GasLiftSingleWellGeneric<Scalar>::GLiftSyncGroups;
using BasicRates = typename GasLiftSingleWellGeneric<Scalar>::BasicRates;
public:
GasLiftSingleWell(

File diff suppressed because it is too large Load Diff

View File

@ -33,8 +33,7 @@
#include <tuple>
#include <utility>
namespace Opm
{
namespace Opm {
class DeferredLogger;
class GasLiftWell;
@ -45,43 +44,52 @@ class WellInterfaceGeneric;
template<class Scalar> class WellState;
template<class Scalar> class GroupState;
class GasLiftSingleWellGeneric : public GasLiftCommon<double>
template<class Scalar>
class GasLiftSingleWellGeneric : public GasLiftCommon<Scalar>
{
protected:
static constexpr int Water = BlackoilPhases::Aqua;
static constexpr int Oil = BlackoilPhases::Liquid;
static constexpr int Gas = BlackoilPhases::Vapour;
static constexpr int NUM_PHASES = 3;
static constexpr double ALQ_EPSILON = 1e-8;
static constexpr Scalar ALQ_EPSILON = 1e-8;
public:
using GLiftSyncGroups = std::set<int>;
using Rate = GasLiftGroupInfo<double>::Rate;
using Rate = typename GasLiftGroupInfo<Scalar>::Rate;
using MessageType = typename GasLiftCommon<Scalar>::MessageType;
struct GradInfo
{
GradInfo() { }
GradInfo() = default;
GradInfo(Scalar grad_,
Scalar new_oil_rate_,
bool oil_is_limited_,
Scalar new_gas_rate_,
bool gas_is_limited_,
Scalar new_water_rate_,
bool water_is_limited_,
Scalar alq_,
bool alq_is_limited_)
: grad{grad_}
, new_oil_rate{new_oil_rate_}
, oil_is_limited{oil_is_limited_}
, new_gas_rate{new_gas_rate_}
, gas_is_limited{gas_is_limited_}
, new_water_rate{new_water_rate_}
, water_is_limited{water_is_limited_}
, alq{alq_}
, alq_is_limited{alq_is_limited_}
{}
GradInfo(double grad_, double new_oil_rate_, bool oil_is_limited_,
double new_gas_rate_, bool gas_is_limited_,
double new_water_rate_, bool water_is_limited_,
double alq_, bool alq_is_limited_) :
grad{grad_},
new_oil_rate{new_oil_rate_},
oil_is_limited{oil_is_limited_},
new_gas_rate{new_gas_rate_},
gas_is_limited{gas_is_limited_},
new_water_rate{new_water_rate_},
water_is_limited{water_is_limited_},
alq{alq_},
alq_is_limited{alq_is_limited_} {}
double grad;
double new_oil_rate;
Scalar grad;
Scalar new_oil_rate;
bool oil_is_limited;
double new_gas_rate;
Scalar new_gas_rate;
bool gas_is_limited;
double new_water_rate;
Scalar new_water_rate;
bool water_is_limited;
double alq;
Scalar alq;
bool alq_is_limited;
};
@ -89,33 +97,31 @@ public:
const std::string& name() const { return well_name_; }
std::optional<GradInfo> calcIncOrDecGradient(double oil_rate, double gas_rate,
double water_rate,
double alq,
std::optional<GradInfo> calcIncOrDecGradient(Scalar oil_rate,
Scalar gas_rate,
Scalar water_rate,
Scalar alq,
const std::string& gr_name_dont_limit,
bool increase,
bool debug_output = true
) const;
bool debug_output = true) const;
std::unique_ptr<GasLiftWellState<double>> runOptimize(const int iteration_idx);
std::unique_ptr<GasLiftWellState<Scalar>> runOptimize(const int iteration_idx);
virtual const WellInterfaceGeneric& getWell() const = 0;
protected:
GasLiftSingleWellGeneric(
DeferredLogger& deferred_logger,
WellState<double>& well_state,
const GroupState<double>& group_state,
GasLiftSingleWellGeneric(DeferredLogger& deferred_logger,
WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
const Well& ecl_well,
const SummaryState& summary_state,
GasLiftGroupInfo<double>& group_info,
GasLiftGroupInfo<Scalar>& group_info,
const PhaseUsage& phase_usage,
const Schedule& schedule,
const int report_step_idx,
GLiftSyncGroups& sync_groups,
const Parallel::Communication& comm,
bool glift_debug
);
bool glift_debug);
struct LimitedRates;
struct BasicRates
@ -126,24 +132,33 @@ protected:
water{rates.water},
bhp_is_limited{rates.bhp_is_limited}
{}
BasicRates(double oil_, double gas_, double water_, bool bhp_is_limited_) :
oil{oil_},
gas{gas_},
water{water_},
bhp_is_limited{bhp_is_limited_}
BasicRates(Scalar oil_,
Scalar gas_,
Scalar water_,
bool bhp_is_limited_)
: oil{oil_}
, gas{gas_}
, water{water_}
, bhp_is_limited{bhp_is_limited_}
{}
BasicRates& operator=(const BasicRates& rates) {
BasicRates& operator=(const BasicRates& rates)
{
oil = rates.oil;
gas = rates.gas;
water = rates.water;
bhp_is_limited = rates.bhp_is_limited;
return *this;
}
// This copy constructor cannot be defined inline here since LimitedRates
// has not been defined yet (it is defined below). Instead it is defined in
// in the .cpp file
BasicRates(const LimitedRates& rates);
double operator[](Rate rate_type) const {
Scalar operator[](Rate rate_type) const
{
switch (rate_type) {
case Rate::oil:
return this->oil;
@ -158,46 +173,49 @@ protected:
}
}
double oil, gas, water;
Scalar oil, gas, water;
bool bhp_is_limited;
};
struct LimitedRates : public BasicRates
{
enum class LimitType {well, group, none};
LimitedRates(
double oil_, double gas_, double water_,
bool oil_is_limited_, bool gas_is_limited_,
bool water_is_limited_, bool bhp_is_limited_,
LimitedRates(Scalar oil_,
Scalar gas_,
Scalar water_,
bool oil_is_limited_,
bool gas_is_limited_,
bool water_is_limited_,
bool bhp_is_limited_,
std::optional<Rate> oil_limiting_target_,
std::optional<Rate> water_limiting_target_
) :
BasicRates(oil_, gas_, water_, bhp_is_limited_),
oil_is_limited{oil_is_limited_},
gas_is_limited{gas_is_limited_},
water_is_limited{water_is_limited_},
oil_limiting_target{oil_limiting_target_},
water_limiting_target{water_limiting_target_}
std ::optional<Rate> water_limiting_target_)
: BasicRates(oil_, gas_, water_, bhp_is_limited_)
, oil_is_limited{oil_is_limited_}
, gas_is_limited{gas_is_limited_}
, water_is_limited{water_is_limited_}
, oil_limiting_target{oil_limiting_target_}
, water_limiting_target{water_limiting_target_}
{
set_initial_limit_type_();
}
LimitedRates(
const BasicRates& rates,
bool oil_is_limited_, bool gas_is_limited_,
bool water_is_limited_
) :
BasicRates(rates),
oil_is_limited{oil_is_limited_},
gas_is_limited{gas_is_limited_},
water_is_limited{water_is_limited_}
LimitedRates(const BasicRates& rates,
bool oil_is_limited_,
bool gas_is_limited_,
bool water_is_limited_)
: BasicRates(rates)
, oil_is_limited{oil_is_limited_}
, gas_is_limited{gas_is_limited_}
, water_is_limited{water_is_limited_}
{
set_initial_limit_type_();
}
bool limited() const {
bool limited() const
{
return oil_is_limited || gas_is_limited || water_is_limited;
}
// For a given ALQ value, were the rates limited due to group targets
// or due to well targets?
LimitType limit_type;
@ -206,145 +224,221 @@ protected:
bool water_is_limited;
std::optional<Rate> oil_limiting_target;
std::optional<Rate> water_limiting_target;
private:
void set_initial_limit_type_() {
void set_initial_limit_type_()
{
limit_type = limited() ? LimitType::well : LimitType::none;
}
};
struct OptimizeState
{
OptimizeState( GasLiftSingleWellGeneric& parent_, bool increase_ ) :
parent{parent_},
increase{increase_},
it{0},
stop_iteration{false},
bhp{-1}
OptimizeState( GasLiftSingleWellGeneric& parent_, bool increase_ )
: parent{parent_}
, increase{increase_}
, it{0}
, stop_iteration{false}
, bhp{-1}
{}
GasLiftSingleWellGeneric& parent;
bool increase;
int it;
bool stop_iteration;
double bhp;
Scalar bhp;
std::pair<std::optional<double>,bool> addOrSubtractAlqIncrement(double alq);
double calcEcoGradient(double oil_rate, double new_oil_rate,
double gas_rate, double new_gas_rate);
bool checkAlqOutsideLimits(double alq, double oil_rate);
bool checkEcoGradient(double gradient);
bool checkOilRateExceedsTarget(double oil_rate);
std::pair<std::optional<Scalar>,bool> addOrSubtractAlqIncrement(Scalar alq);
Scalar calcEcoGradient(Scalar oil_rate,
Scalar new_oil_rate,
Scalar gas_rate,
Scalar new_gas_rate);
bool checkAlqOutsideLimits(Scalar alq, Scalar oil_rate);
bool checkEcoGradient(Scalar gradient);
bool checkOilRateExceedsTarget(Scalar oil_rate);
bool checkRatesViolated(const LimitedRates& rates) const;
void debugShowIterationInfo(double alq);
double getBhpWithLimit();
void warn_(std::string msg) {parent.displayWarning_(msg);}
};
bool checkGroupALQrateExceeded(double delta_alq, const std::string& gr_name_dont_limit = "") const;
bool checkGroupTotalRateExceeded(double delta_alq, double delta_gas_rate) const;
std::pair<std::optional<double>, bool> addOrSubtractAlqIncrement_(
double alq, bool increase) const;
double calcEcoGradient_(double oil_rate, double new_oil_rate,
double gas_rate, double new_gas_rate, bool increase) const;
bool checkALQequal_(double alq1, double alq2) const;
bool checkGroupTargetsViolated(
const BasicRates& rates, const BasicRates& new_rates) const;
bool checkInitialALQmodified_(double alq, double initial_alq) const;
void debugShowIterationInfo(Scalar alq);
Scalar getBhpWithLimit();
void warn_(const std::string& msg) { parent.displayWarning_(msg); }
};
bool checkGroupALQrateExceeded(Scalar delta_alq,
const std::string& gr_name_dont_limit = "") const;
bool checkGroupTotalRateExceeded(Scalar delta_alq,
Scalar delta_gas_rate) const;
std::pair<std::optional<Scalar>, bool>
addOrSubtractAlqIncrement_(Scalar alq, bool increase) const;
Scalar calcEcoGradient_(Scalar oil_rate, Scalar new_oil_rate,
Scalar gas_rate, Scalar new_gas_rate, bool increase) const;
bool checkALQequal_(Scalar alq1, Scalar alq2) const;
bool checkGroupTargetsViolated(const BasicRates& rates,
const BasicRates& new_rates) const;
bool checkInitialALQmodified_(Scalar alq, Scalar initial_alq) const;
virtual bool checkThpControl_() const = 0;
virtual std::optional<double> computeBhpAtThpLimit_(double alq, bool debug_output = true) const = 0;
std::pair<std::optional<double>,double> computeConvergedBhpAtThpLimitByMaybeIncreasingALQ_() const;
std::pair<std::optional<BasicRates>,double> computeInitialWellRates_() const;
std::optional<LimitedRates> computeLimitedWellRatesWithALQ_(double alq) const;
virtual BasicRates computeWellRates_(double bhp, bool bhp_is_limited, bool debug_output = true) const = 0;
std::optional<BasicRates> computeWellRatesWithALQ_(double alq) const;
void debugCheckNegativeGradient_(double grad, double alq, double new_alq,
double oil_rate, double new_oil_rate,
double gas_rate, double new_gas_rate,
virtual std::optional<Scalar > computeBhpAtThpLimit_(Scalar alq,
bool debug_output = true) const = 0;
std::pair<std::optional<Scalar>,Scalar>
computeConvergedBhpAtThpLimitByMaybeIncreasingALQ_() const;
std::pair<std::optional<BasicRates>,Scalar>
computeInitialWellRates_() const;
std::optional<LimitedRates>
computeLimitedWellRatesWithALQ_(Scalar alq) const;
virtual BasicRates computeWellRates_(Scalar bhp,
bool bhp_is_limited,
bool debug_output = true) const = 0;
std::optional<BasicRates> computeWellRatesWithALQ_(Scalar alq) const;
void debugCheckNegativeGradient_(Scalar grad, Scalar alq, Scalar new_alq,
Scalar oil_rate, Scalar new_oil_rate,
Scalar gas_rate, Scalar new_gas_rate,
bool increase) const;
void debugPrintWellStateRates() const;
void debugShowAlqIncreaseDecreaseCounts_();
void debugShowBhpAlqTable_();
void debugShowLimitingTargets_(const LimitedRates& rates) const;
void debugShowProducerControlMode() const;
void debugShowStartIteration_(double alq, bool increase, double oil_rate);
void debugShowStartIteration_(Scalar alq, bool increase, Scalar oil_rate);
void debugShowTargets_();
void displayDebugMessage_(const std::string& msg) const override;
void displayWarning_(const std::string& warning);
std::pair<double, bool> getBhpWithLimit_(double bhp) const;
std::pair<double, bool> getGasRateWithLimit_(
const BasicRates& rates) const;
std::pair<double, bool> getGasRateWithGroupLimit_(
double new_gas_rate, double gas_rate, const std::string& gr_name_dont_limit) const;
std::pair<std::optional<LimitedRates>,double> getInitialRatesWithLimit_() const;
std::pair<Scalar, bool> getBhpWithLimit_(Scalar bhp) const;
std::pair<Scalar, bool> getGasRateWithLimit_(const BasicRates& rates) const;
std::pair<Scalar, bool> getGasRateWithGroupLimit_(Scalar new_gas_rate,
Scalar gas_rate,
const std::string& gr_name_dont_limit) const;
std::pair<std::optional<LimitedRates>,Scalar >
getInitialRatesWithLimit_() const;
LimitedRates getLimitedRatesFromRates_(const BasicRates& rates) const;
std::tuple<double,double,bool,bool> getLiquidRateWithGroupLimit_(
const double new_oil_rate, const double oil_rate,
const double new_water_rate, const double water_rate, const std::string& gr_name_dont_limit) const;
std::pair<double, bool> getOilRateWithGroupLimit_(
double new_oil_rate, double oil_rate, const std::string& gr_name_dont_limit) const;
std::pair<double, bool> getOilRateWithLimit_(const BasicRates& rates) const;
std::pair<double, std::optional<Rate>> getOilRateWithLimit2_(
const BasicRates& rates) const;
double getProductionTarget_(Rate rate) const;
double getRate_(Rate rate_type, const BasicRates& rates) const;
std::pair<double, std::optional<Rate>> getRateWithLimit_(
Rate rate_type, const BasicRates& rates) const;
std::tuple<double, const std::string*, double> getRateWithGroupLimit_(
Rate rate_type, const double new_rate, const double old_rate, const std::string& gr_name_dont_limit) const;
std::pair<double, bool> getWaterRateWithGroupLimit_(
double new_water_rate, double water_rate, const std::string& gr_name_dont_limit) const;
std::pair<double, bool> getWaterRateWithLimit_(const BasicRates& rates) const;
std::pair<double, std::optional<Rate>> getWaterRateWithLimit2_(
const BasicRates& rates) const;
std::tuple<Scalar,Scalar,bool,bool>
getLiquidRateWithGroupLimit_(const Scalar new_oil_rate,
const Scalar oil_rate,
const Scalar new_water_rate,
const Scalar water_rate,
const std::string& gr_name_dont_limit) const;
std::pair<Scalar, bool>
getOilRateWithGroupLimit_(Scalar new_oil_rate,
Scalar oil_rate,
const std::string& gr_name_dont_limit) const;
std::pair<Scalar, bool> getOilRateWithLimit_(const BasicRates& rates) const;
std::pair<Scalar, std::optional<Rate>>
getOilRateWithLimit2_(const BasicRates& rates) const;
Scalar getProductionTarget_(Rate rate) const;
Scalar getRate_(Rate rate_type, const BasicRates& rates) const;
std::pair<Scalar, std::optional<Rate>>
getRateWithLimit_(Rate rate_type, const BasicRates& rates) const;
std::tuple<Scalar, const std::string*, Scalar>
getRateWithGroupLimit_(Rate rate_type,
const Scalar new_rate,
const Scalar old_rate,
const std::string& gr_name_dont_limit) const;
std::pair<Scalar, bool>
getWaterRateWithGroupLimit_(Scalar new_water_rate,
Scalar water_rate,
const std::string& gr_name_dont_limit) const;
std::pair<Scalar, bool> getWaterRateWithLimit_(const BasicRates& rates) const;
std::pair<Scalar, std::optional<Rate>>
getWaterRateWithLimit2_(const BasicRates& rates) const;
BasicRates getWellStateRates_() const;
bool hasProductionControl_(Rate rate) const;
std::pair<LimitedRates, double> increaseALQtoPositiveOilRate_(
double alq, const LimitedRates& orig_rates) const;
std::pair<LimitedRates, double> increaseALQtoMinALQ_(
double alq, const LimitedRates& orig_rates) const;
void logSuccess_(double alq,
std::pair<LimitedRates, Scalar>
increaseALQtoPositiveOilRate_(Scalar alq,
const LimitedRates& orig_rates) const;
std::pair<LimitedRates, Scalar>
increaseALQtoMinALQ_(Scalar alq,
const LimitedRates& orig_rates) const;
void logSuccess_(Scalar alq,
const int iteration_idx);
std::pair<LimitedRates, double> maybeAdjustALQbeforeOptimizeLoop_(
const LimitedRates& rates, double alq, bool increase) const;
std::pair<LimitedRates, double> reduceALQtoGroupAlqLimits_(
double alq, const LimitedRates& rates) const;
std::pair<LimitedRates, double> reduceALQtoGroupTarget(
double alq, const LimitedRates& rates) const;
std::pair<LimitedRates, double> reduceALQtoWellTarget_(
double alq, const LimitedRates& rates) const;
std::unique_ptr<GasLiftWellState<double>> runOptimize1_();
std::unique_ptr<GasLiftWellState<double>> runOptimize2_();
std::unique_ptr<GasLiftWellState<double>> runOptimizeLoop_(bool increase);
std::pair<LimitedRates, Scalar>
maybeAdjustALQbeforeOptimizeLoop_(const LimitedRates& rates,
Scalar alq,
bool increase) const;
std::pair<LimitedRates, Scalar>
reduceALQtoGroupAlqLimits_(Scalar alq,
const LimitedRates& rates) const;
std::pair<LimitedRates, Scalar>
reduceALQtoGroupTarget(Scalar alq,
const LimitedRates& rates) const;
std::pair<LimitedRates, Scalar>
reduceALQtoWellTarget_(Scalar alq,
const LimitedRates& rates) const;
std::unique_ptr<GasLiftWellState<Scalar>> runOptimize1_();
std::unique_ptr<GasLiftWellState<Scalar>> runOptimize2_();
std::unique_ptr<GasLiftWellState<Scalar>> runOptimizeLoop_(bool increase);
void setAlqMinRate_(const GasLiftWell& well);
std::unique_ptr<GasLiftWellState<double>> tryIncreaseLiftGas_();
std::unique_ptr<GasLiftWellState<double>> tryDecreaseLiftGas_();
void updateGroupRates_(
const LimitedRates& rates,
std::unique_ptr<GasLiftWellState<Scalar>> tryIncreaseLiftGas_();
std::unique_ptr<GasLiftWellState<Scalar>> tryDecreaseLiftGas_();
void updateGroupRates_(const LimitedRates& rates,
const LimitedRates& new_rates,
double delta_alq) const;
LimitedRates updateRatesToGroupLimits_(
const BasicRates& rates, const LimitedRates& new_rates, const std::string& gr_name = "") const;
Scalar delta_alq) const;
LimitedRates
updateRatesToGroupLimits_(const BasicRates& rates,
const LimitedRates& new_rates,
const std::string& gr_name = "") const;
void updateWellStateAlqFixedValue_(const GasLiftWell& well);
bool useFixedAlq_(const GasLiftWell& well);
void debugInfoGroupRatesExceedTarget(
Rate rate_type, const std::string& gr_name, double rate, double target) const;
void debugInfoGroupRatesExceedTarget(Rate rate_type,
const std::string& gr_name,
Scalar rate,
Scalar target) const;
void warnMaxIterationsExceeded_();
const Well& ecl_well_;
const SummaryState& summary_state_;
GasLiftGroupInfo<double>& group_info_;
GasLiftGroupInfo<Scalar>& group_info_;
const PhaseUsage& phase_usage_;
GLiftSyncGroups& sync_groups_;
const WellProductionControls controls_;
double increment_;
double max_alq_;
double min_alq_;
double orig_alq_;
Scalar increment_;
Scalar max_alq_;
Scalar min_alq_;
Scalar orig_alq_;
double alpha_w_;
double alpha_g_;
double eco_grad_;
Scalar alpha_w_;
Scalar alpha_g_;
Scalar eco_grad_;
int gas_pos_;
int oil_pos_;

View File

@ -44,7 +44,7 @@ GasLiftSingleWell(const WellInterface<TypeTag> &well,
)
// The parent class GasLiftSingleWellGeneric contains all stuff
// that is not dependent on TypeTag
: GasLiftSingleWellGeneric(
: GasLiftSingleWellGeneric<Scalar>(
deferred_logger,
well_state,
group_state,
@ -61,9 +61,9 @@ GasLiftSingleWell(const WellInterface<TypeTag> &well,
, simulator_{simulator}
, well_{well}
{
const auto& gl_well = *gl_well_;
if(useFixedAlq_(gl_well)) {
updateWellStateAlqFixedValue_(gl_well);
const auto& gl_well = *this->gl_well_;
if (this->useFixedAlq_(gl_well)) {
this->updateWellStateAlqFixedValue_(gl_well);
this->optimize_ = false; // lift gas supply is fixed
}
else {
@ -78,13 +78,13 @@ GasLiftSingleWell(const WellInterface<TypeTag> &well,
// default value is used.
this->orig_alq_ = this->well_state_.getALQ(this->well_name_);
if(this->optimize_) {
setAlqMinRate_(gl_well);
this->setAlqMinRate_(gl_well);
// NOTE: According to item 4 in WLIFTOPT, this value does not
// have to be positive.
// TODO: Does it make sense to have a negative value?
this->alpha_w_ = gl_well.weight_factor();
if (this->alpha_w_ <= 0 ) {
displayWarning_("Nonpositive value for alpha_w ignored");
this->displayWarning_("Nonpositive value for alpha_w ignored");
this->alpha_w_ = 1.0;
}
@ -107,11 +107,11 @@ GasLiftSingleWell(const WellInterface<TypeTag> &well,
****************************************/
template<typename TypeTag>
GasLiftSingleWellGeneric::BasicRates
typename GasLiftSingleWell<TypeTag>::BasicRates
GasLiftSingleWell<TypeTag>::
computeWellRates_( double bhp, bool bhp_is_limited, bool debug_output ) const
{
std::vector<double> potentials(NUM_PHASES, 0.0);
std::vector<double> potentials(this->NUM_PHASES, 0.0);
this->well_.computeWellRatesWithBhp(
this->simulator_, bhp, potentials, this->deferred_logger_);
if (debug_output) {
@ -119,7 +119,7 @@ computeWellRates_( double bhp, bool bhp_is_limited, bool debug_output ) const
"oil: {}, gas: {}, water: {}", bhp,
-potentials[this->oil_pos_], -potentials[this->gas_pos_],
-potentials[this->water_pos_]);
displayDebugMessage_(msg);
this->displayDebugMessage_(msg);
}
for (auto& potential : potentials) {
@ -150,7 +150,7 @@ computeBhpAtThpLimit_(double alq, bool debug_output) const
" Using bhp limit instead",
*bhp_at_thp_limit, this->controls_.bhp_limit, alq
);
displayDebugMessage_(msg);
this->displayDebugMessage_(msg);
}
bhp_at_thp_limit = this->controls_.bhp_limit;
}
@ -159,7 +159,7 @@ computeBhpAtThpLimit_(double alq, bool debug_output) const
else {
const std::string msg = fmt::format(
"Failed in getting converged bhp potential from thp limit (ALQ = {})", alq);
displayDebugMessage_(msg);
this->displayDebugMessage_(msg);
}
return bhp_at_thp_limit;
}
@ -198,9 +198,9 @@ setupPhaseVariables_()
}
}
assert(num_phases_ok);
this->oil_pos_ = pu.phase_pos[Oil];
this->gas_pos_ = pu.phase_pos[Gas];
this->water_pos_ = pu.phase_pos[Water];
this->oil_pos_ = pu.phase_pos[this->Oil];
this->gas_pos_ = pu.phase_pos[this->Gas];
this->water_pos_ = pu.phase_pos[this->Water];
}
template<typename TypeTag>
@ -240,7 +240,7 @@ checkThpControl_() const
thp_control = thp_control || well.thpLimitViolatedButNotSwitched();
if (this->debug) {
if (!thp_control) {
displayDebugMessage_("Well is not under THP control, skipping iteration..");
this->displayDebugMessage_("Well is not under THP control, skipping iteration..");
}
}
return thp_control;

View File

@ -322,7 +322,7 @@ GasLiftStage2::getGroupMaxTotalGas_(const Group &group)
// NOTE: This means that wells are located at the leaf nodes of the tree, and
// groups are located at the other nodes (not leaf nodes) of the tree
//
std::vector<GasLiftSingleWellGeneric*>
std::vector<GasLiftSingleWellGeneric<double>*>
GasLiftStage2::
getGroupGliftWells_(const Group &group)
{

View File

@ -43,13 +43,13 @@ class WellInterfaceGeneric;
template<class Scalar> class WellState;
class GasLiftStage2 : public GasLiftCommon<double> {
using GasLiftSingleWell = GasLiftSingleWellGeneric;
using GasLiftSingleWell = GasLiftSingleWellGeneric<double>;
using GLiftOptWells = std::map<std::string,std::unique_ptr<GasLiftSingleWell>>;
using GLiftProdWells = std::map<std::string,const WellInterfaceGeneric*>;
using GLiftWellStateMap = std::map<std::string,std::unique_ptr<GasLiftWellState<double>>>;
using GradPair = std::pair<std::string, double>;
using GradPairItr = std::vector<GradPair>::iterator;
using GradInfo = typename GasLiftSingleWellGeneric::GradInfo;
using GradInfo = typename GasLiftSingleWellGeneric<double>::GradInfo;
using GradMap = std::map<std::string, GradInfo>;
using MPIComm = typename Dune::MPIHelper::MPICommunicator;
static const int Water = BlackoilPhases::Aqua;

View File

@ -80,6 +80,7 @@ public:
using Grid = GetPropType<TypeTag, Properties::Grid>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using Indices = GetPropType<TypeTag, Properties::Indices>;
using IntensiveQuantities = GetPropType<TypeTag, Properties::IntensiveQuantities>;
@ -91,9 +92,7 @@ public:
using GLiftProdWells = typename BlackoilWellModel<TypeTag>::GLiftProdWells;
using GLiftWellStateMap =
typename BlackoilWellModel<TypeTag>::GLiftWellStateMap;
using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using GLiftSyncGroups = typename GasLiftSingleWellGeneric<Scalar>::GLiftSyncGroups;
using VectorBlockType = Dune::FieldVector<Scalar, Indices::numEq>;
using MatrixBlockType = Dune::FieldMatrix<Scalar, Indices::numEq, Indices::numEq>;

View File

@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(G1)
using StdWell = Opm::StandardWell<TypeTag>;
using GasLiftSingleWell = Opm::GasLiftSingleWell<TypeTag>;
using GasLiftGroupInfo = Opm::GasLiftGroupInfo<double>;
using GasLiftSingleWellGeneric = Opm::GasLiftSingleWellGeneric;
using GasLiftSingleWellGeneric = Opm::GasLiftSingleWellGeneric<double>;
using GLiftEclWells = typename GasLiftGroupInfo::GLiftEclWells;
const std::string filename = "GLIFT1.DATA";
using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups;