mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
InjectionTargetCalculator: template Scalar type
This commit is contained in:
@@ -154,15 +154,17 @@ TargetCalculator<Scalar>::guideTargetMode() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InjectionTargetCalculator::InjectionTargetCalculator(const Group::InjectionCMode& cmode,
|
template<class Scalar>
|
||||||
const PhaseUsage& pu,
|
InjectionTargetCalculator<Scalar>::
|
||||||
const std::vector<double>& resv_coeff,
|
InjectionTargetCalculator(const Group::InjectionCMode& cmode,
|
||||||
const std::string& group_name,
|
const PhaseUsage& pu,
|
||||||
const double sales_target,
|
const std::vector<Scalar>& resv_coeff,
|
||||||
const GroupState<double>& group_state,
|
const std::string& group_name,
|
||||||
const Phase& injection_phase,
|
const Scalar sales_target,
|
||||||
const bool use_gpmaint,
|
const GroupState<Scalar>& group_state,
|
||||||
DeferredLogger& deferred_logger)
|
const Phase& injection_phase,
|
||||||
|
const bool use_gpmaint,
|
||||||
|
DeferredLogger& deferred_logger)
|
||||||
: cmode_(cmode)
|
: cmode_(cmode)
|
||||||
, pu_(pu)
|
, pu_(pu)
|
||||||
, resv_coeff_(resv_coeff)
|
, resv_coeff_(resv_coeff)
|
||||||
@@ -199,8 +201,10 @@ InjectionTargetCalculator::InjectionTargetCalculator(const Group::InjectionCMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Scalar>
|
||||||
double InjectionTargetCalculator::groupTarget(const std::optional<Group::InjectionControls>& ctrl, Opm::DeferredLogger& deferred_logger) const
|
Scalar InjectionTargetCalculator<Scalar>::
|
||||||
|
groupTarget(const std::optional<Group::InjectionControls>& ctrl,
|
||||||
|
DeferredLogger& deferred_logger) const
|
||||||
{
|
{
|
||||||
if (!ctrl && !use_gpmaint_) {
|
if (!ctrl && !use_gpmaint_) {
|
||||||
OPM_DEFLOG_THROW(std::logic_error,
|
OPM_DEFLOG_THROW(std::logic_error,
|
||||||
@@ -210,32 +214,32 @@ double InjectionTargetCalculator::groupTarget(const std::optional<Group::Injecti
|
|||||||
}
|
}
|
||||||
switch (cmode_) {
|
switch (cmode_) {
|
||||||
case Group::InjectionCMode::RATE:
|
case Group::InjectionCMode::RATE:
|
||||||
if(use_gpmaint_ && this->group_state_.has_gpmaint_target(this->group_name_))
|
if (use_gpmaint_ && this->group_state_.has_gpmaint_target(this->group_name_))
|
||||||
return this->group_state_.gpmaint_target(this->group_name_);
|
return this->group_state_.gpmaint_target(this->group_name_);
|
||||||
|
|
||||||
return ctrl->surface_max_rate;
|
return ctrl->surface_max_rate;
|
||||||
case Group::InjectionCMode::RESV:
|
case Group::InjectionCMode::RESV:
|
||||||
if(use_gpmaint_ && this->group_state_.has_gpmaint_target(this->group_name_))
|
if (use_gpmaint_ && this->group_state_.has_gpmaint_target(this->group_name_))
|
||||||
return this->group_state_.gpmaint_target(this->group_name_) / resv_coeff_[pos_];
|
return this->group_state_.gpmaint_target(this->group_name_) / resv_coeff_[pos_];
|
||||||
|
|
||||||
return ctrl->resv_max_rate / resv_coeff_[pos_];
|
return ctrl->resv_max_rate / resv_coeff_[pos_];
|
||||||
case Group::InjectionCMode::REIN: {
|
case Group::InjectionCMode::REIN: {
|
||||||
double production_rate = this->group_state_.injection_rein_rates(ctrl->reinj_group)[pos_];
|
Scalar production_rate = this->group_state_.injection_rein_rates(ctrl->reinj_group)[pos_];
|
||||||
return ctrl->target_reinj_fraction * production_rate;
|
return ctrl->target_reinj_fraction * production_rate;
|
||||||
}
|
}
|
||||||
case Group::InjectionCMode::VREP: {
|
case Group::InjectionCMode::VREP: {
|
||||||
const std::vector<double>& group_injection_reductions = this->group_state_.injection_reduction_rates(this->group_name_);
|
const std::vector<Scalar>& group_injection_reductions = this->group_state_.injection_reduction_rates(this->group_name_);
|
||||||
double voidage_rate = group_state_.injection_vrep_rate(ctrl->voidage_group) * ctrl->target_void_fraction;
|
Scalar voidage_rate = group_state_.injection_vrep_rate(ctrl->voidage_group) * ctrl->target_void_fraction;
|
||||||
double inj_reduction = 0.0;
|
Scalar inj_reduction = 0.0;
|
||||||
if (ctrl->phase != Phase::WATER)
|
if (ctrl->phase != Phase::WATER)
|
||||||
inj_reduction += group_injection_reductions[pu_.phase_pos[BlackoilPhases::Aqua]]
|
inj_reduction += group_injection_reductions[pu_.phase_pos[BlackoilPhases::Aqua]]
|
||||||
* resv_coeff_[pu_.phase_pos[BlackoilPhases::Aqua]];
|
* resv_coeff_[pu_.phase_pos[BlackoilPhases::Aqua]];
|
||||||
if (ctrl->phase != Phase::OIL)
|
if (ctrl->phase != Phase::OIL)
|
||||||
inj_reduction += group_injection_reductions[pu_.phase_pos[BlackoilPhases::Liquid]]
|
inj_reduction += group_injection_reductions[pu_.phase_pos[BlackoilPhases::Liquid]]
|
||||||
* resv_coeff_[pu_.phase_pos[BlackoilPhases::Liquid]];
|
* resv_coeff_[pu_.phase_pos[BlackoilPhases::Liquid]];
|
||||||
if (ctrl->phase != Phase::GAS)
|
if (ctrl->phase != Phase::GAS)
|
||||||
inj_reduction += group_injection_reductions[pu_.phase_pos[BlackoilPhases::Vapour]]
|
inj_reduction += group_injection_reductions[pu_.phase_pos[BlackoilPhases::Vapour]]
|
||||||
* resv_coeff_[pu_.phase_pos[BlackoilPhases::Vapour]];
|
* resv_coeff_[pu_.phase_pos[BlackoilPhases::Vapour]];
|
||||||
voidage_rate -= inj_reduction;
|
voidage_rate -= inj_reduction;
|
||||||
return voidage_rate / resv_coeff_[pos_];
|
return voidage_rate / resv_coeff_[pos_];
|
||||||
}
|
}
|
||||||
@@ -243,7 +247,7 @@ double InjectionTargetCalculator::groupTarget(const std::optional<Group::Injecti
|
|||||||
assert(pos_ == pu_.phase_pos[BlackoilPhases::Vapour]);
|
assert(pos_ == pu_.phase_pos[BlackoilPhases::Vapour]);
|
||||||
// Gas injection rate = Total gas production rate + gas import rate - gas consumption rate - sales rate;
|
// Gas injection rate = Total gas production rate + gas import rate - gas consumption rate - sales rate;
|
||||||
// Gas import and consumption is already included in the REIN rates
|
// Gas import and consumption is already included in the REIN rates
|
||||||
double inj_rate = group_state_.injection_rein_rates(this->group_name_)[pos_];
|
Scalar inj_rate = group_state_.injection_rein_rates(this->group_name_)[pos_];
|
||||||
inj_rate -= sales_target_;
|
inj_rate -= sales_target_;
|
||||||
return inj_rate;
|
return inj_rate;
|
||||||
}
|
}
|
||||||
@@ -255,7 +259,9 @@ double InjectionTargetCalculator::groupTarget(const std::optional<Group::Injecti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GuideRateModel::Target InjectionTargetCalculator::guideTargetMode() const
|
template<class Scalar>
|
||||||
|
GuideRateModel::Target
|
||||||
|
InjectionTargetCalculator<Scalar>::guideTargetMode() const
|
||||||
{
|
{
|
||||||
return target_;
|
return target_;
|
||||||
}
|
}
|
||||||
@@ -264,6 +270,7 @@ GuideRateModel::Target InjectionTargetCalculator::guideTargetMode() const
|
|||||||
template __VA_ARGS__ TargetCalculator<double>::calcModeRateFromRates<__VA_ARGS__>(const __VA_ARGS__* rates) const;
|
template __VA_ARGS__ TargetCalculator<double>::calcModeRateFromRates<__VA_ARGS__>(const __VA_ARGS__* rates) const;
|
||||||
|
|
||||||
template class TargetCalculator<double>;
|
template class TargetCalculator<double>;
|
||||||
|
template class InjectionTargetCalculator<double>;
|
||||||
|
|
||||||
INSTANCE_TARGET_CALCULATOR(double)
|
INSTANCE_TARGET_CALCULATOR(double)
|
||||||
INSTANCE_TARGET_CALCULATOR(DenseAd::Evaluation<double,3,0>)
|
INSTANCE_TARGET_CALCULATOR(DenseAd::Evaluation<double,3,0>)
|
||||||
|
|||||||
@@ -76,15 +76,16 @@ private:
|
|||||||
|
|
||||||
/// Based on a group control mode, extract or calculate rates, and
|
/// Based on a group control mode, extract or calculate rates, and
|
||||||
/// provide other conveniences.
|
/// provide other conveniences.
|
||||||
|
template<class Scalar>
|
||||||
class InjectionTargetCalculator
|
class InjectionTargetCalculator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InjectionTargetCalculator(const Group::InjectionCMode& cmode,
|
InjectionTargetCalculator(const Group::InjectionCMode& cmode,
|
||||||
const PhaseUsage& pu,
|
const PhaseUsage& pu,
|
||||||
const std::vector<double>& resv_coeff,
|
const std::vector<Scalar>& resv_coeff,
|
||||||
const std::string& group_name,
|
const std::string& group_name,
|
||||||
const double sales_target,
|
const Scalar sales_target,
|
||||||
const GroupState<double>& group_state,
|
const GroupState<Scalar>& group_state,
|
||||||
const Phase& injection_phase,
|
const Phase& injection_phase,
|
||||||
const bool use_gpmaint,
|
const bool use_gpmaint,
|
||||||
DeferredLogger& deferred_logger);
|
DeferredLogger& deferred_logger);
|
||||||
@@ -95,17 +96,18 @@ public:
|
|||||||
return rates[pos_];
|
return rates[pos_];
|
||||||
}
|
}
|
||||||
|
|
||||||
double groupTarget(const std::optional<Group::InjectionControls>& ctrl, Opm::DeferredLogger& deferred_logger) const;
|
Scalar groupTarget(const std::optional<Group::InjectionControls>& ctrl,
|
||||||
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
GuideRateModel::Target guideTargetMode() const;
|
GuideRateModel::Target guideTargetMode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Group::InjectionCMode cmode_;
|
Group::InjectionCMode cmode_;
|
||||||
const PhaseUsage& pu_;
|
const PhaseUsage& pu_;
|
||||||
const std::vector<double>& resv_coeff_;
|
const std::vector<Scalar>& resv_coeff_;
|
||||||
const std::string& group_name_;
|
const std::string& group_name_;
|
||||||
double sales_target_;
|
Scalar sales_target_;
|
||||||
const GroupState<double>& group_state_;
|
const GroupState<Scalar>& group_state_;
|
||||||
bool use_gpmaint_;
|
bool use_gpmaint_;
|
||||||
int pos_;
|
int pos_;
|
||||||
GuideRateModel::Target target_;
|
GuideRateModel::Target target_;
|
||||||
|
|||||||
Reference in New Issue
Block a user