-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support instantaneous flow rates in extended network (WEFAC and GEFAC item 3) #4094
Conversation
jenkins build this opm-simulators=5410 please |
jenkins build this opm-simulators=5410 please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a lot of code, but I do feel it can be tricky. I left some comments for your consideration.
opm/input/eclipse/Schedule/Well/WellPropertiesKeywordHandlers.cpp
Outdated
Show resolved
Hide resolved
@@ -205,6 +212,36 @@ void ExtNetwork::update_node(Node node) | |||
this->m_nodes.insert_or_assign(name, std::move(node) ); | |||
} | |||
|
|||
bool ExtNetwork::needs_instantaneous_rates(const Opm::Schedule& schedule, const int report_step) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the usage of this function in OPM/opm-simulators#5410, it basically indicates whether we are handling network flow with extended network with "NO" in the item 3 in WEFAC or GEFAC.
Or more simply, we can use true
for extended network and use false
for standard network and group calculation. If we can introduce a flag to mark whether the network is extended network, we do not need this function anymore. And use_efficiency_in_ext_network
will take care whether we will use instantaneous rate.
What do you think? I can understand this part wrong. Please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can certainly be skipped, but the intention is to save some computation in opm-simulators in the quite common situation with default value (YES) for all instances of WEFAC/GEFAC with wells/groups in the network.
One complication I see is action handling (i.e., if item3 is updated through actions), will need to ensure the check is performed again in this case. Can have a quick look, or we just drop this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this now.
jenkins build this opm-simulators=5410 please |
a5c4c31
to
e1f9c8d
Compare
jenkins build this opm-simulators=5410 please |
e1f9c8d
to
9102c16
Compare
jenkins build this opm-simulators=5410 please |
1 similar comment
jenkins build this opm-simulators=5410 please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks generally good to me. I only have some minor comments for you to address.
bool add_gas_lift_gas() const; | ||
const std::optional<std::string>& target_group() const; | ||
|
||
void terminal_pressure(double pressure); | ||
void add_gas_lift_gas(bool add_gas); | ||
void as_choke(const std::string& target_group); | ||
void set_efficiency(const double& efficiency); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reference &
here is not necessary.
children.push(branch.downtree_node()); | ||
} | ||
} | ||
assert(children.empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with while (!children.empty())
, the assertion here is not necessary.
std::stack<std::string> children; | ||
children.push(root.get().name()); | ||
while (!children.empty()) { | ||
const auto node = children.top(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nittpicking, const auto& node
can be used here.
And leaf_nodes.emplace(node)
can be used in the code below instead of insert()
.
double Well::getEfficiencyFactor() const | ||
{ | ||
double Well::getEfficiencyFactor(bool network) const { | ||
if (network && (!this->use_efficiency_in_network)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(!this->use_efficiency_in_network)
, the bracket is not necessary with a !
operator when coming to improving the readability.
return this->efficiency_factor; | ||
} | ||
|
||
double Well::getSolventFraction() const | ||
{ | ||
bool Well::useEfficiencyInNetwork() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function does not look like used.
@@ -517,7 +518,7 @@ class Well { | |||
bool updateWellGuideRate(bool available, double guide_rate, GuideRateTarget guide_phase, double scale_factor); | |||
bool updateWellGuideRate(double guide_rate); | |||
bool updateAvailableForGroupControl(bool available); | |||
bool updateEfficiencyFactor(double efficiency_factor); | |||
bool updateEfficiencyFactor(double efficiency_factor, bool se_efficiency_in_network = true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value for bool se_efficiency_in_network = true
is not very useful, since the only usage of the function is for parsing keyword WEFAC, the default behavoir is specified through the definition of the keyword WEFAC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, updated a test instead.
@@ -235,5 +239,29 @@ std::vector<std::string> ExtNetwork::node_names() const | |||
{ | |||
return this->insert_indexed_node_names; | |||
} | |||
|
|||
std::set<std::string> ExtNetwork::leaf_nodes() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function looks correct to me. From the usage in the opm-simulators, it looks like it will be called many times. Ideally, it will be nice if we can save the results somehow to avoid repeating the process.
This can be done in a following up PR if it turns out to be costly and needs to be optimized.
@@ -2038,6 +2052,7 @@ bool Well::cmp_structure(const Well& other) const | |||
&& (this->udq_undefined == other.udq_undefined) | |||
&& (this->getPreferredPhase() == other.getPreferredPhase()) // wellType() | |||
&& (this->getEfficiencyFactor() == other.getEfficiencyFactor()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not matter for the current usage since the argument is false by default, but it might be better to compare the value
this->efficiency_factor == other.efficiency_factor
now, since the function getEfficiencyFactor()
uses use_efficiency_in_network
and it is a little more complex function now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not matter for the current usage since the argument is false by default, but it might be better to compare the value
this->efficiency_factor == other.efficiency_factor
now, since the functiongetEfficiencyFactor()
usesuse_efficiency_in_network
and it is a little more complex function now.
Arguably, two wells aren't equal if their use_efficiency_in_network
differ so I think it actually makes sense to continue to use getEfficiencyFactor()
for this criterion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
In the current form of the function double getEfficiencyFactor(bool network)
, it is fine and it is equivalent to compare with the efficiency_factor
. But I do feel that it is safer (and slightly faster) to compare with the member variable directly.
In a more general setting, for example, the function double getEfficiencyFactor(bool network)
evolves somehow it might not reflect the value of efficiency_factor
, then a bug can be introduced. Or we might need to compare both getEfficiencyFactor(true)
and getEfficiencyFactor(false)
.
As said, I think it does not make much difference for the current code, but I do think compare with the member variable itself is safer generally.
9102c16
to
20734b9
Compare
Thank you for the review. I have now tried to update accordingly. |
jenkins build this opm-simulators=5410 please |
Thanks for the update. It looks good to me and I am getting it in now. |
No restart support here - will come in a separate PR.