mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-14 04:01:55 -06:00
GasLiftWellState: template Scalar type
This commit is contained in:
parent
56dbfde657
commit
25de745dab
@ -55,7 +55,7 @@ namespace Opm {
|
||||
class EclipseState;
|
||||
template<class Scalar> class GasLiftGroupInfo;
|
||||
class GasLiftSingleWellGeneric;
|
||||
class GasLiftWellState;
|
||||
template<class Scalar> class GasLiftWellState;
|
||||
class Group;
|
||||
class GuideRateConfig;
|
||||
class ParallelWellInfo;
|
||||
@ -85,7 +85,7 @@ public:
|
||||
// --------- Types ---------
|
||||
using GLiftOptWells = std::map<std::string, std::unique_ptr<GasLiftSingleWellGeneric>>;
|
||||
using GLiftProdWells = std::map<std::string, const WellInterfaceGeneric*>;
|
||||
using GLiftWellStateMap = std::map<std::string, std::unique_ptr<GasLiftWellState>>;
|
||||
using GLiftWellStateMap = std::map<std::string, std::unique_ptr<GasLiftWellState<Scalar>>>;
|
||||
|
||||
BlackoilWellModelGeneric(Schedule& schedule,
|
||||
const SummaryState& summaryState,
|
||||
|
@ -131,10 +131,10 @@ GasLiftSingleWellGeneric::calcIncOrDecGradient( double oil_rate,
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<GasLiftWellState>
|
||||
std::unique_ptr<GasLiftWellState<double>>
|
||||
GasLiftSingleWellGeneric::runOptimize(const int iteration_idx)
|
||||
{
|
||||
std::unique_ptr<GasLiftWellState> state;
|
||||
std::unique_ptr<GasLiftWellState<double>> state;
|
||||
if (this->optimize_) {
|
||||
if (this->debug_limit_increase_decrease_) {
|
||||
state = runOptimize1_();
|
||||
@ -1154,12 +1154,12 @@ GasLiftSingleWellGeneric::reduceALQtoWellTarget_(const double orig_alq, const Li
|
||||
//
|
||||
// - return value: a new GasLiftWellState or nullptr
|
||||
//
|
||||
std::unique_ptr<GasLiftWellState>
|
||||
std::unique_ptr<GasLiftWellState<double>>
|
||||
GasLiftSingleWellGeneric::runOptimizeLoop_(bool increase)
|
||||
{
|
||||
if (this->debug)
|
||||
debugShowProducerControlMode();
|
||||
std::unique_ptr<GasLiftWellState> ret_value; // nullptr initially
|
||||
std::unique_ptr<GasLiftWellState<double>> ret_value; // nullptr initially
|
||||
auto [rates, cur_alq] = getInitialRatesWithLimit_();
|
||||
if (!rates)
|
||||
return ret_value;
|
||||
@ -1252,22 +1252,22 @@ GasLiftSingleWellGeneric::runOptimizeLoop_(bool increase)
|
||||
} else {
|
||||
increase_opt = std::nullopt;
|
||||
}
|
||||
ret_value = std::make_unique<GasLiftWellState>(new_rates.oil,
|
||||
new_rates.oil_is_limited,
|
||||
new_rates.gas,
|
||||
new_rates.gas_is_limited,
|
||||
cur_alq,
|
||||
alq_is_limited,
|
||||
new_rates.water,
|
||||
new_rates.water_is_limited,
|
||||
increase_opt);
|
||||
ret_value = std::make_unique<GasLiftWellState<double>>(new_rates.oil,
|
||||
new_rates.oil_is_limited,
|
||||
new_rates.gas,
|
||||
new_rates.gas_is_limited,
|
||||
cur_alq,
|
||||
alq_is_limited,
|
||||
new_rates.water,
|
||||
new_rates.water_is_limited,
|
||||
increase_opt);
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
std::unique_ptr<GasLiftWellState>
|
||||
std::unique_ptr<GasLiftWellState<double>>
|
||||
GasLiftSingleWellGeneric::runOptimize1_()
|
||||
{
|
||||
std::unique_ptr<GasLiftWellState> state;
|
||||
std::unique_ptr<GasLiftWellState<double>> state;
|
||||
int inc_count = this->well_state_.gliftGetAlqIncreaseCount(this->well_name_);
|
||||
int dec_count = this->well_state_.gliftGetAlqDecreaseCount(this->well_name_);
|
||||
if (dec_count == 0 && inc_count == 0) {
|
||||
@ -1285,10 +1285,10 @@ GasLiftSingleWellGeneric::runOptimize1_()
|
||||
return state;
|
||||
}
|
||||
|
||||
std::unique_ptr<GasLiftWellState>
|
||||
std::unique_ptr<GasLiftWellState<double>>
|
||||
GasLiftSingleWellGeneric::runOptimize2_()
|
||||
{
|
||||
std::unique_ptr<GasLiftWellState> state;
|
||||
std::unique_ptr<GasLiftWellState<double>> state;
|
||||
state = tryIncreaseLiftGas_();
|
||||
if (!state || !(state->alqChanged())) {
|
||||
state = tryDecreaseLiftGas_();
|
||||
@ -1296,13 +1296,13 @@ GasLiftSingleWellGeneric::runOptimize2_()
|
||||
return state;
|
||||
}
|
||||
|
||||
std::unique_ptr<GasLiftWellState>
|
||||
std::unique_ptr<GasLiftWellState<double>>
|
||||
GasLiftSingleWellGeneric::tryDecreaseLiftGas_()
|
||||
{
|
||||
return runOptimizeLoop_(/*increase=*/false);
|
||||
}
|
||||
|
||||
std::unique_ptr<GasLiftWellState>
|
||||
std::unique_ptr<GasLiftWellState<double>>
|
||||
GasLiftSingleWellGeneric::tryIncreaseLiftGas_()
|
||||
{
|
||||
return runOptimizeLoop_(/*increase=*/true);
|
||||
|
@ -38,7 +38,7 @@ namespace Opm
|
||||
|
||||
class DeferredLogger;
|
||||
class GasLiftWell;
|
||||
class GasLiftWellState;
|
||||
template<class Scalar> class GasLiftWellState;
|
||||
class Schedule;
|
||||
class SummaryState;
|
||||
class WellInterfaceGeneric;
|
||||
@ -97,7 +97,7 @@ public:
|
||||
bool debug_output = true
|
||||
) const;
|
||||
|
||||
std::unique_ptr<GasLiftWellState> runOptimize(const int iteration_idx);
|
||||
std::unique_ptr<GasLiftWellState<double>> runOptimize(const int iteration_idx);
|
||||
|
||||
virtual const WellInterfaceGeneric& getWell() const = 0;
|
||||
|
||||
@ -312,12 +312,12 @@ protected:
|
||||
double alq, const LimitedRates& rates) const;
|
||||
std::pair<LimitedRates, double> reduceALQtoWellTarget_(
|
||||
double alq, const LimitedRates& rates) const;
|
||||
std::unique_ptr<GasLiftWellState> runOptimize1_();
|
||||
std::unique_ptr<GasLiftWellState> runOptimize2_();
|
||||
std::unique_ptr<GasLiftWellState> runOptimizeLoop_(bool increase);
|
||||
std::unique_ptr<GasLiftWellState<double>> runOptimize1_();
|
||||
std::unique_ptr<GasLiftWellState<double>> runOptimize2_();
|
||||
std::unique_ptr<GasLiftWellState<double>> runOptimizeLoop_(bool increase);
|
||||
void setAlqMinRate_(const GasLiftWell& well);
|
||||
std::unique_ptr<GasLiftWellState> tryIncreaseLiftGas_();
|
||||
std::unique_ptr<GasLiftWellState> tryDecreaseLiftGas_();
|
||||
std::unique_ptr<GasLiftWellState<double>> tryIncreaseLiftGas_();
|
||||
std::unique_ptr<GasLiftWellState<double>> tryDecreaseLiftGas_();
|
||||
void updateGroupRates_(
|
||||
const LimitedRates& rates,
|
||||
const LimitedRates& new_rates,
|
||||
|
@ -109,7 +109,7 @@ addOrRemoveALQincrement_(GradMap &grad_map, const std::string& well_name, bool a
|
||||
if (it == this->well_state_map_.end())
|
||||
return;
|
||||
|
||||
GasLiftWellState &state = *(it->second.get());
|
||||
GasLiftWellState<double>& state = *(it->second.get());
|
||||
const GradInfo &gi = grad_map.at(well_name);
|
||||
if (this->debug) {
|
||||
auto new_alq = gi.alq;
|
||||
@ -145,7 +145,7 @@ calcIncOrDecGrad_(
|
||||
// only applies to wells in the well_state_map (i.e. wells on this rank)
|
||||
if(this->well_state_map_.count(well_name) == 0)
|
||||
return std::nullopt;
|
||||
GasLiftWellState &state = *(this->well_state_map_.at(well_name).get());
|
||||
GasLiftWellState<double>& state = *(this->well_state_map_.at(well_name).get());
|
||||
if (checkRateAlreadyLimited_(well_name, state, increase)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -181,7 +181,9 @@ calcIncOrDecGrad_(
|
||||
|
||||
bool
|
||||
GasLiftStage2::
|
||||
checkRateAlreadyLimited_(const std::string& well_name, GasLiftWellState &state, bool increase)
|
||||
checkRateAlreadyLimited_(const std::string& well_name,
|
||||
GasLiftWellState<double>& state,
|
||||
bool increase)
|
||||
{
|
||||
auto current_increase = state.increase();
|
||||
bool do_check = false;
|
||||
@ -1082,7 +1084,7 @@ computeDelta(const std::string &well_name)
|
||||
// compute the delta on wells on own rank
|
||||
if (this->parent.well_state_map_.count(well_name) > 0) {
|
||||
const GradInfo &gi = this->parent.dec_grads_.at(well_name);
|
||||
GasLiftWellState &state = *(this->parent.well_state_map_.at(well_name).get());
|
||||
GasLiftWellState<double>& state = *(this->parent.well_state_map_.at(well_name).get());
|
||||
GasLiftSingleWell &gs_well = *(this->parent.stage1_wells_.at(well_name).get());
|
||||
const WellInterfaceGeneric &well = gs_well.getWell();
|
||||
// only get deltas for wells owned by this rank
|
||||
|
@ -35,7 +35,7 @@ namespace Opm
|
||||
|
||||
class DeferredLogger;
|
||||
class GasLiftOpt;
|
||||
class GasLiftWellState;
|
||||
template<class Scalar> class GasLiftWellState;
|
||||
class Group;
|
||||
template<class Scalar> class GroupState;
|
||||
class Schedule;
|
||||
@ -46,7 +46,7 @@ class GasLiftStage2 : public GasLiftCommon<double> {
|
||||
using GasLiftSingleWell = GasLiftSingleWellGeneric;
|
||||
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>>;
|
||||
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;
|
||||
@ -76,7 +76,9 @@ protected:
|
||||
GradMap& grad_map, const std::string& well_name, bool add);
|
||||
std::optional<GradInfo> calcIncOrDecGrad_(
|
||||
const std::string name, const GasLiftSingleWell& gs_well, const std::string& gr_name_dont_limit, bool increase);
|
||||
bool checkRateAlreadyLimited_(const std::string& well_name, GasLiftWellState& state, bool increase);
|
||||
bool checkRateAlreadyLimited_(const std::string& well_name,
|
||||
GasLiftWellState<double>& state,
|
||||
bool increase);
|
||||
GradInfo deleteDecGradItem_(const std::string& name);
|
||||
GradInfo deleteIncGradItem_(const std::string& name);
|
||||
GradInfo deleteGrad_(const std::string& name, bool increase);
|
||||
|
@ -25,39 +25,50 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template<class Scalar>
|
||||
class GasLiftWellState
|
||||
{
|
||||
public:
|
||||
//GasLiftWellState() { }
|
||||
GasLiftWellState(double oil_rate, bool oil_is_limited,
|
||||
double gas_rate, bool gas_is_limited,
|
||||
double alq, bool alq_is_limited, double water_rate, bool water_is_limited, std::optional<bool> increase) :
|
||||
oil_rate_{oil_rate},
|
||||
oil_is_limited_{oil_is_limited},
|
||||
gas_rate_{gas_rate},
|
||||
gas_is_limited_{gas_is_limited},
|
||||
alq_{alq},
|
||||
alq_is_limited_{alq_is_limited},
|
||||
water_rate_{water_rate},
|
||||
water_is_limited_{water_is_limited},
|
||||
increase_{increase}
|
||||
GasLiftWellState(Scalar oil_rate,
|
||||
bool oil_is_limited,
|
||||
Scalar gas_rate,
|
||||
bool gas_is_limited,
|
||||
Scalar alq,
|
||||
bool alq_is_limited,
|
||||
Scalar water_rate,
|
||||
bool water_is_limited,
|
||||
std::optional<bool> increase)
|
||||
: oil_rate_{oil_rate}
|
||||
, oil_is_limited_{oil_is_limited}
|
||||
, gas_rate_{gas_rate}
|
||||
, gas_is_limited_{gas_is_limited}
|
||||
, alq_{alq}
|
||||
, alq_is_limited_{alq_is_limited}
|
||||
, water_rate_{water_rate}
|
||||
, water_is_limited_{water_is_limited}
|
||||
, increase_{increase}
|
||||
{}
|
||||
double alq() const { return alq_; }
|
||||
|
||||
Scalar alq() const { return alq_; }
|
||||
bool alqChanged() { return increase_.has_value(); }
|
||||
bool alqIsLimited() const { return alq_is_limited_; }
|
||||
bool gasIsLimited() const { return gas_is_limited_; }
|
||||
double gasRate() const { return gas_rate_; }
|
||||
std::pair<double, double> getRates() { return {oil_rate_, gas_rate_}; }
|
||||
Scalar gasRate() const { return gas_rate_; }
|
||||
std::pair<Scalar, Scalar> getRates() { return {oil_rate_, gas_rate_}; }
|
||||
std::optional<bool> increase() const { return increase_; }
|
||||
bool oilIsLimited() const { return oil_is_limited_; }
|
||||
double oilRate() const { return oil_rate_; }
|
||||
double waterRate() const { return water_rate_; }
|
||||
Scalar oilRate() const { return oil_rate_; }
|
||||
Scalar waterRate() const { return water_rate_; }
|
||||
bool waterIsLimited() const { return water_is_limited_; }
|
||||
void update(double oil_rate, bool oil_is_limited,
|
||||
double gas_rate, bool gas_is_limited,
|
||||
double alq, bool alq_is_limited, double water_rate,
|
||||
double water_is_limited,
|
||||
bool increase)
|
||||
void update(Scalar oil_rate,
|
||||
bool oil_is_limited,
|
||||
Scalar gas_rate,
|
||||
bool gas_is_limited,
|
||||
Scalar alq,
|
||||
bool alq_is_limited,
|
||||
Scalar water_rate,
|
||||
Scalar water_is_limited,
|
||||
bool increase)
|
||||
{
|
||||
oil_rate_ = oil_rate;
|
||||
oil_is_limited_ = oil_is_limited;
|
||||
@ -69,14 +80,15 @@ public:
|
||||
water_is_limited_ = water_is_limited;
|
||||
increase_ = increase;
|
||||
}
|
||||
|
||||
private:
|
||||
double oil_rate_;
|
||||
Scalar oil_rate_;
|
||||
bool oil_is_limited_;
|
||||
double gas_rate_;
|
||||
Scalar gas_rate_;
|
||||
bool gas_is_limited_;
|
||||
double alq_;
|
||||
Scalar alq_;
|
||||
bool alq_is_limited_;
|
||||
double water_rate_;
|
||||
Scalar water_rate_;
|
||||
bool water_is_limited_;
|
||||
std::optional<bool> increase_;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user