mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
making bruteforce bracket as a function
for better readbility.
This commit is contained in:
parent
3273f310e3
commit
5824acbf92
@ -612,28 +612,8 @@ computeBhpAtThpLimitProd(const std::function<std::vector<double>(const double)>&
|
|||||||
|
|
||||||
if (!finding_bracket) {
|
if (!finding_bracket) {
|
||||||
deferred_logger.debug(" trying the brute force way for last attempt ");
|
deferred_logger.debug(" trying the brute force way for last attempt ");
|
||||||
// resetting the high and low
|
const std::array<double, 2> range {controls.bhp_limit, bhp_max};
|
||||||
low = controls.bhp_limit;
|
finding_bracket = this->bruteForcingBracket(eq, range, low, high, deferred_logger);
|
||||||
high = bhp_max;
|
|
||||||
const int sample_number = 100;
|
|
||||||
const double interval = (high - low) / sample_number;
|
|
||||||
double eq_low = eq(low);
|
|
||||||
double eq_high;
|
|
||||||
for (int i = 0; i < sample_number + 1; ++i) {
|
|
||||||
high = controls.bhp_limit + interval * i;
|
|
||||||
eq_high = eq(high);
|
|
||||||
if (eq_high * eq_low <= 0.) {
|
|
||||||
finding_bracket = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
low = high;
|
|
||||||
eq_low = eq_high;
|
|
||||||
}
|
|
||||||
if (finding_bracket) {
|
|
||||||
deferred_logger.debug(
|
|
||||||
" brute force solve found low " + std::to_string(low) + " with eq_low " + std::to_string(eq_low) +
|
|
||||||
" high " + std::to_string(high) + " with eq_high " + std::to_string(eq_high));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!finding_bracket) {
|
if (!finding_bracket) {
|
||||||
@ -656,6 +636,39 @@ computeBhpAtThpLimitProd(const std::function<std::vector<double>(const double)>&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Scalar>
|
||||||
|
bool
|
||||||
|
MultisegmentWellGeneric<Scalar>::
|
||||||
|
bruteForcingBracket(const std::function<double(const double)>& eq,
|
||||||
|
const std::array<double, 2>& range,
|
||||||
|
double& low, double& high,
|
||||||
|
DeferredLogger& deferred_logger) const
|
||||||
|
{
|
||||||
|
bool finding_bracket = false;
|
||||||
|
low = range[0];
|
||||||
|
high = range[1];
|
||||||
|
const int sample_number = 100;
|
||||||
|
const double interval = (high - low) / sample_number;
|
||||||
|
double eq_low = eq(low);
|
||||||
|
double eq_high;
|
||||||
|
for (int i = 0; i < sample_number + 1; ++i) {
|
||||||
|
high = range[0] + interval * i;
|
||||||
|
eq_high = eq(high);
|
||||||
|
if (eq_high * eq_low <= 0.) {
|
||||||
|
finding_bracket = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
low = high;
|
||||||
|
eq_low = eq_high;
|
||||||
|
}
|
||||||
|
if (finding_bracket) {
|
||||||
|
deferred_logger.debug(
|
||||||
|
" brute force solve found low " + std::to_string(low) + " with eq_low " + std::to_string(eq_low) +
|
||||||
|
" high " + std::to_string(high) + " with eq_high " + std::to_string(eq_high));
|
||||||
|
}
|
||||||
|
return finding_bracket;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Scalar>
|
template<typename Scalar>
|
||||||
bool
|
bool
|
||||||
MultisegmentWellGeneric<Scalar>::
|
MultisegmentWellGeneric<Scalar>::
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
@ -75,6 +76,11 @@ protected:
|
|||||||
const double rho,
|
const double rho,
|
||||||
DeferredLogger& deferred_logger) const;
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
|
bool bruteForcingBracket(const std::function<double(const double)>& eq,
|
||||||
|
const std::array<double, 2>& range,
|
||||||
|
double& low, double& high,
|
||||||
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
/// Detect oscillation or stagnation based on the residual measure history
|
/// Detect oscillation or stagnation based on the residual measure history
|
||||||
void detectOscillations(const std::vector<double>& measure_history,
|
void detectOscillations(const std::vector<double>& measure_history,
|
||||||
const int it,
|
const int it,
|
||||||
|
Loading…
Reference in New Issue
Block a user