GasLiftSingleWell: use Scalar type

This commit is contained in:
Arne Morten Kvarving
2024-02-20 09:05:09 +01:00
parent 4feebaba4f
commit ec90ca1736
2 changed files with 36 additions and 34 deletions

View File

@@ -28,8 +28,6 @@
#include <opm/simulators/wells/WellInterface.hpp>
#include <optional>
#include <vector>
#include <utility>
namespace Opm {
@@ -56,16 +54,18 @@ public:
const WellInterfaceGeneric& getWell() const override { return well_; }
private:
std::optional<double>
computeBhpAtThpLimit_(double alq, bool debug_ouput=true) const override;
std::optional<Scalar>
computeBhpAtThpLimit_(Scalar alq,
bool debug_ouput = true) const override;
BasicRates computeWellRates_(double bhp, bool bhp_is_limited,
BasicRates computeWellRates_(Scalar bhp,
bool bhp_is_limited,
bool debug_output = true) const override;
void setAlqMaxRate_(const GasLiftWell& well);
void setupPhaseVariables_();
bool checkThpControl_() const override;
const Simulator& simulator_;
const WellInterface<TypeTag>& well_;
};

View File

@@ -27,37 +27,37 @@
#include <opm/input/eclipse/Schedule/GasLiftOpt.hpp>
#include <fmt/format.h>
#include <string>
#include <vector>
namespace Opm {
template<typename TypeTag>
GasLiftSingleWell<TypeTag>::
GasLiftSingleWell(const WellInterface<TypeTag> &well,
GasLiftSingleWell(const WellInterface<TypeTag>& well,
const Simulator& simulator,
const SummaryState &summary_state,
DeferredLogger &deferred_logger,
const SummaryState& summary_state,
DeferredLogger& deferred_logger,
WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
GasLiftGroupInfo<Scalar>& group_info,
GLiftSyncGroups &sync_groups,
const Parallel::Communication& comm,
bool glift_debug
)
bool glift_debug)
// The parent class GasLiftSingleWellGeneric contains all stuff
// that is not dependent on TypeTag
: GasLiftSingleWellGeneric<Scalar>(
deferred_logger,
well_state,
group_state,
well.wellEcl(),
summary_state,
group_info,
well.phaseUsage(),
simulator.vanguard().schedule(),
simulator.episodeIndex(),
sync_groups,
comm,
glift_debug
)
: GasLiftSingleWellGeneric<Scalar>(deferred_logger,
well_state,
group_state,
well.wellEcl(),
summary_state,
group_info,
well.phaseUsage(),
simulator.vanguard().schedule(),
simulator.episodeIndex(),
sync_groups,
comm,
glift_debug)
, simulator_{simulator}
, well_{well}
{
@@ -77,7 +77,7 @@ GasLiftSingleWell(const WellInterface<TypeTag> &well,
// If gas lift optimization has not been applied to this well yet, the
// default value is used.
this->orig_alq_ = this->well_state_.getALQ(this->well_name_);
if(this->optimize_) {
if (this->optimize_) {
this->setAlqMinRate_(gl_well);
// NOTE: According to item 4 in WLIFTOPT, this value does not
// have to be positive.
@@ -109,11 +109,13 @@ GasLiftSingleWell(const WellInterface<TypeTag> &well,
template<typename TypeTag>
typename GasLiftSingleWell<TypeTag>::BasicRates
GasLiftSingleWell<TypeTag>::
computeWellRates_( double bhp, bool bhp_is_limited, bool debug_output ) const
computeWellRates_(Scalar bhp, bool bhp_is_limited, bool debug_output ) const
{
std::vector<double> potentials(this->NUM_PHASES, 0.0);
this->well_.computeWellRatesWithBhp(
this->simulator_, bhp, potentials, this->deferred_logger_);
std::vector<Scalar> potentials(this->NUM_PHASES, 0.0);
this->well_.computeWellRatesWithBhp(this->simulator_,
bhp,
potentials,
this->deferred_logger_);
if (debug_output) {
const std::string msg = fmt::format("computed well potentials given bhp {}, "
"oil: {}, gas: {}, water: {}", bhp,
@@ -123,7 +125,7 @@ computeWellRates_( double bhp, bool bhp_is_limited, bool debug_output ) const
}
for (auto& potential : potentials) {
potential = std::min(0.0, potential);
potential = std::min(Scalar{0.0}, potential);
}
return {-potentials[this->oil_pos_],
-potentials[this->gas_pos_],
@@ -133,9 +135,9 @@ computeWellRates_( double bhp, bool bhp_is_limited, bool debug_output ) const
}
template<typename TypeTag>
std::optional<double>
std::optional<typename GasLiftSingleWell<TypeTag>::Scalar>
GasLiftSingleWell<TypeTag>::
computeBhpAtThpLimit_(double alq, bool debug_output) const
computeBhpAtThpLimit_(Scalar alq, bool debug_output) const
{
auto bhp_at_thp_limit = this->well_.computeBhpAtThpLimitProdWithAlq(
this->simulator_,
@@ -206,7 +208,7 @@ setupPhaseVariables_()
template<typename TypeTag>
void
GasLiftSingleWell<TypeTag>::
setAlqMaxRate_(const GasLiftWell &well)
setAlqMaxRate_(const GasLiftWell& well)
{
auto& max_alq_optional = well.max_rate();
if (max_alq_optional) {