mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Removed calculateGuideRates and made all guide rate dependent code calculate the guide rate dynamically
This commit is contained in:
parent
fe51b96a7e
commit
da85405dfa
@ -109,13 +109,6 @@ namespace Opm
|
||||
return true;
|
||||
}
|
||||
|
||||
void WellCollection::calculateGuideRates()
|
||||
{
|
||||
for(size_t i = 0; i < roots_.size(); i++) {
|
||||
roots_[i]->calculateGuideRates();
|
||||
}
|
||||
}
|
||||
|
||||
void WellCollection::setWellsPointer(Wells* wells) {
|
||||
for(size_t i = 0; i < leaf_nodes_.size(); i++) {
|
||||
leaf_nodes_[i]->setWellsPointer(wells, i);
|
||||
|
@ -75,11 +75,6 @@ namespace Opm
|
||||
/// \return A set of pointers to every well in the collection
|
||||
const std::vector<WellNode*>& getLeafNodes() const;
|
||||
|
||||
/// This will, for each group \f$G\f$ for each well \f$w\in G\f$ calculate
|
||||
/// the new guide rate \f$\tilde{g}_w\f$ for each well as
|
||||
/// \f[ \tilde{g}_w := \frac{g_w}{\sum_{w'\in G} g_{w'}}\f]
|
||||
void calculateGuideRates();
|
||||
|
||||
/// Finds the group with the given name.
|
||||
/// \param[in] the name of the group
|
||||
/// \return the pointer to the group if found, NULL otherwise
|
||||
|
@ -247,22 +247,6 @@ namespace Opm
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void WellsGroup::calculateGuideRates()
|
||||
{
|
||||
double inj_guide_rate_sum = 0.0;
|
||||
double prod_guide_rate_sum = 0.0;
|
||||
for (size_t i = 0; i < children_.size(); i++) {
|
||||
children_[i]->calculateGuideRates();
|
||||
inj_guide_rate_sum += children_[i]->injSpec().guide_rate_;
|
||||
prod_guide_rate_sum += children_[i]->prodSpec().guide_rate_;
|
||||
}
|
||||
injSpec().guide_rate_ = inj_guide_rate_sum;
|
||||
prodSpec().guide_rate_ = prod_guide_rate_sum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Sets the current active control to the provided one for all injectors within the group.
|
||||
/// After this call, the combined rate (which rate depending on control_mode) of the group
|
||||
/// shall be equal to target.
|
||||
@ -272,9 +256,11 @@ namespace Opm
|
||||
const double target,
|
||||
const bool forced)
|
||||
{
|
||||
if (forced || injSpec().control_mode_ == InjectionSpecification::FLD) {
|
||||
if (forced || injSpec().control_mode_ == InjectionSpecification::FLD
|
||||
|| injSpec().control_mode_ == InjectionSpecification::NONE) {
|
||||
const double my_guide_rate = injectionGuideRate(!forced);
|
||||
for (size_t i = 0; i < children_.size(); ++i) {
|
||||
const double child_target = target * children_[i]->injSpec().guide_rate_ / injSpec().guide_rate_;
|
||||
const double child_target = target * children_[i]->injectionGuideRate(!forced) / my_guide_rate;
|
||||
children_[i]->applyInjGroupControl(control_mode, child_target, true);
|
||||
}
|
||||
injSpec().control_mode_ = InjectionSpecification::FLD;
|
||||
@ -290,10 +276,11 @@ namespace Opm
|
||||
const double target,
|
||||
const bool forced)
|
||||
{
|
||||
if (forced
|
||||
|| (prodSpec().control_mode_ == ProductionSpecification::FLD || prodSpec().control_mode_ == ProductionSpecification::NONE)) {
|
||||
if (forced || (prodSpec().control_mode_ == ProductionSpecification::FLD
|
||||
|| prodSpec().control_mode_ == ProductionSpecification::NONE)) {
|
||||
const double my_guide_rate = productionGuideRate(!forced);
|
||||
for (size_t i = 0; i < children_.size(); ++i) {
|
||||
const double child_target = target * children_[i]->prodSpec().guide_rate_ / prodSpec().guide_rate_;
|
||||
const double child_target = target * children_[i]->productionGuideRate(!forced) / my_guide_rate;
|
||||
children_[i]->applyProdGroupControl(control_mode, child_target, true);
|
||||
}
|
||||
prodSpec().control_mode_ = ProductionSpecification::FLD;
|
||||
@ -443,12 +430,12 @@ namespace Opm
|
||||
case ProductionSpecification::LRAT:
|
||||
case ProductionSpecification::RESV:
|
||||
{
|
||||
const double my_guide_rate = prodSpec().guide_rate_;
|
||||
const double my_guide_rate = productionGuideRate(true);
|
||||
for (size_t i = 0; i < children_.size(); ++i ) {
|
||||
// Apply for all children.
|
||||
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
||||
// as that would check if we're under group control, something we're not.
|
||||
const double children_guide_rate = children_[i]->prodSpec().guide_rate_;
|
||||
const double children_guide_rate = productionGuideRate(true);
|
||||
children_[i]->applyProdGroupControl(prod_mode,
|
||||
(my_guide_rate / children_guide_rate) * getTarget(prod_mode),
|
||||
false);
|
||||
@ -474,12 +461,12 @@ namespace Opm
|
||||
case InjectionSpecification::RATE:
|
||||
case InjectionSpecification::RESV:
|
||||
{
|
||||
const double my_guide_rate = injSpec().guide_rate_;
|
||||
const double my_guide_rate = injectionGuideRate(true);
|
||||
for (size_t i = 0; i < children_.size(); ++i ) {
|
||||
// Apply for all children.
|
||||
// Note, we do _not_ want to call the applyProdGroupControl in this object,
|
||||
// as that would check if we're under group control, something we're not.
|
||||
const double children_guide_rate = children_[i]->injSpec().guide_rate_;
|
||||
const double children_guide_rate = children_[i]->injectionGuideRate(true);
|
||||
children_[i]->applyInjGroupControl(inj_mode,
|
||||
(my_guide_rate / children_guide_rate) * getTarget(inj_mode),
|
||||
false);
|
||||
@ -498,6 +485,30 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
double WellsGroup::productionGuideRate(bool only_group)
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (size_t i = 0; i < children_.size(); ++i) {
|
||||
sum += children_[i]->productionGuideRate(only_group);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
double WellsGroup::injectionGuideRate(bool only_group)
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (size_t i = 0; i < children_.size(); ++i) {
|
||||
sum += children_[i]->injectionGuideRate(only_group);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ============== WellNode members ============
|
||||
@ -614,11 +625,6 @@ namespace Opm
|
||||
self_index_ = self_index;
|
||||
}
|
||||
|
||||
void WellNode::calculateGuideRates()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
int WellNode::numberOfLeafNodes()
|
||||
{
|
||||
return 1;
|
||||
@ -788,6 +794,29 @@ namespace Opm
|
||||
// Empty
|
||||
}
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
double WellNode::productionGuideRate(bool only_group)
|
||||
{
|
||||
if (only_group || prodSpec().control_mode_ == ProductionSpecification::GRUP) {
|
||||
return prodSpec().guide_rate_;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
double WellNode::injectionGuideRate(bool only_group)
|
||||
{
|
||||
if (only_group || injSpec().control_mode_ == InjectionSpecification::GRUP) {
|
||||
return injSpec().guide_rate_;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -89,10 +89,6 @@ namespace Opm
|
||||
/// Gets the parent of the group, NULL if no parent.
|
||||
const WellsGroupInterface* getParent() const;
|
||||
|
||||
/// Recursively calculate the guide rate for each member of the well group.
|
||||
/// This should be called after the guide rates are set to the non-normalized values.
|
||||
virtual void calculateGuideRates() = 0;
|
||||
|
||||
/// Calculates the number of leaf nodes in the given group.
|
||||
/// A leaf node is defined to have one leaf node in its group.
|
||||
virtual int numberOfLeafNodes() = 0;
|
||||
@ -173,6 +169,16 @@ namespace Opm
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyInjGroupControls() = 0;
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double productionGuideRate(bool only_group) = 0;
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double injectionGuideRate(bool only_group) = 0;
|
||||
|
||||
protected:
|
||||
/// Calculates the correct rate for the given ProductionSpecification::ControlMode
|
||||
double rateByMode(const double* res_rates,
|
||||
@ -212,9 +218,6 @@ namespace Opm
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
WellPhasesSummed& summed_phases);
|
||||
|
||||
|
||||
virtual void calculateGuideRates();
|
||||
|
||||
virtual int numberOfLeafNodes();
|
||||
virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
|
||||
const std::vector<double>& well_surfacerates_phase,
|
||||
@ -246,6 +249,16 @@ namespace Opm
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyInjGroupControls();
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double productionGuideRate(bool only_group);
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double injectionGuideRate(bool only_group);
|
||||
|
||||
private:
|
||||
std::vector<std::tr1::shared_ptr<WellsGroupInterface> > children_;
|
||||
};
|
||||
@ -270,7 +283,6 @@ namespace Opm
|
||||
|
||||
void setWellsPointer(Wells* wells, int self_index);
|
||||
|
||||
virtual void calculateGuideRates();
|
||||
virtual int numberOfLeafNodes();
|
||||
|
||||
// Shuts the well (in the well struct)
|
||||
@ -306,6 +318,15 @@ namespace Opm
|
||||
/// If no group control is set, this is called recursively to the children.
|
||||
virtual void applyInjGroupControls();
|
||||
|
||||
/// Calculates the production guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double productionGuideRate(bool only_group);
|
||||
|
||||
/// Calculates the injection guide rate for the group.
|
||||
/// \param[in] only_group If true, will only accumelate guide rates for
|
||||
/// wells under group control
|
||||
virtual double injectionGuideRate(bool only_group);
|
||||
|
||||
private:
|
||||
Wells* wells_;
|
||||
|
@ -620,7 +620,6 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
}
|
||||
well_collection_.calculateGuideRates();
|
||||
well_collection_.setWellsPointer(w_);
|
||||
well_collection_.applyGroupControls();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user