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 = using GLiftWellStateMap =
typename BlackoilWellModelGeneric<Scalar>::GLiftWellStateMap; typename BlackoilWellModelGeneric<Scalar>::GLiftWellStateMap;
using GLiftEclWells = typename GasLiftGroupInfo<Scalar>::GLiftEclWells; 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; constexpr static std::size_t pressureVarIndex = GetPropType<TypeTag, Properties::Indices>::pressureSwitchIdx;
typedef typename BaseAuxiliaryModule<TypeTag>::NeighborSet NeighborSet; typedef typename BaseAuxiliaryModule<TypeTag>::NeighborSet NeighborSet;

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -80,6 +80,7 @@ public:
using Grid = GetPropType<TypeTag, Properties::Grid>; using Grid = GetPropType<TypeTag, Properties::Grid>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>; using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>; using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using Indices = GetPropType<TypeTag, Properties::Indices>; using Indices = GetPropType<TypeTag, Properties::Indices>;
using IntensiveQuantities = GetPropType<TypeTag, Properties::IntensiveQuantities>; using IntensiveQuantities = GetPropType<TypeTag, Properties::IntensiveQuantities>;
@ -91,9 +92,7 @@ public:
using GLiftProdWells = typename BlackoilWellModel<TypeTag>::GLiftProdWells; using GLiftProdWells = typename BlackoilWellModel<TypeTag>::GLiftProdWells;
using GLiftWellStateMap = using GLiftWellStateMap =
typename BlackoilWellModel<TypeTag>::GLiftWellStateMap; typename BlackoilWellModel<TypeTag>::GLiftWellStateMap;
using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups; using GLiftSyncGroups = typename GasLiftSingleWellGeneric<Scalar>::GLiftSyncGroups;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using VectorBlockType = Dune::FieldVector<Scalar, Indices::numEq>; using VectorBlockType = Dune::FieldVector<Scalar, Indices::numEq>;
using MatrixBlockType = Dune::FieldMatrix<Scalar, Indices::numEq, 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 StdWell = Opm::StandardWell<TypeTag>;
using GasLiftSingleWell = Opm::GasLiftSingleWell<TypeTag>; using GasLiftSingleWell = Opm::GasLiftSingleWell<TypeTag>;
using GasLiftGroupInfo = Opm::GasLiftGroupInfo<double>; using GasLiftGroupInfo = Opm::GasLiftGroupInfo<double>;
using GasLiftSingleWellGeneric = Opm::GasLiftSingleWellGeneric; using GasLiftSingleWellGeneric = Opm::GasLiftSingleWellGeneric<double>;
using GLiftEclWells = typename GasLiftGroupInfo::GLiftEclWells; using GLiftEclWells = typename GasLiftGroupInfo::GLiftEclWells;
const std::string filename = "GLIFT1.DATA"; const std::string filename = "GLIFT1.DATA";
using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups; using GLiftSyncGroups = typename GasLiftSingleWellGeneric::GLiftSyncGroups;