mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Refactor out the solving algorithm of bhp from thp via VFP to make it usable for injectors
This commit is contained in:
parent
1001d35418
commit
ec08f80405
@ -649,13 +649,39 @@ computeBhpAtThpLimitProdCommon(const std::function<std::vector<double>(const dou
|
|||||||
"find bhp-point where production becomes non-zero for well " + this->name());
|
"find bhp-point where production becomes non-zero for well " + this->name());
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
const std::array<double, 2> range {controls.bhp_limit, *bhp_max};
|
||||||
|
return computeBhpAtThpLimitCommon(frates, fbhp, range, deferred_logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<double>
|
||||||
|
WellInterfaceGeneric::
|
||||||
|
computeBhpAtThpLimitCommon(const std::function<std::vector<double>(const double)>& frates,
|
||||||
|
const std::function<double(const std::vector<double>)>& fbhp,
|
||||||
|
const std::array<double, 2> range,
|
||||||
|
DeferredLogger& deferred_logger) const
|
||||||
|
{
|
||||||
|
// Given a VFP function returning bhp as a function of phase
|
||||||
|
// rates and thp:
|
||||||
|
// fbhp(rates, thp),
|
||||||
|
// a function extracting the particular flow rate used for VFP
|
||||||
|
// lookups:
|
||||||
|
// flo(rates)
|
||||||
|
// and the inflow function (assuming the reservoir is fixed):
|
||||||
|
// frates(bhp)
|
||||||
|
// we want to solve the equation:
|
||||||
|
// fbhp(frates(bhp, thplimit)) - bhp = 0
|
||||||
|
// for bhp.
|
||||||
|
//
|
||||||
|
// This may result in 0, 1 or 2 solutions. If two solutions,
|
||||||
|
// the one corresponding to the lowest bhp (and therefore
|
||||||
|
// highest rate) should be returned.
|
||||||
|
|
||||||
// Define the equation we want to solve.
|
// Define the equation we want to solve.
|
||||||
auto eq = [&fbhp, &frates](double bhp) {
|
auto eq = [&fbhp, &frates](double bhp) {
|
||||||
return fbhp(frates(bhp)) - bhp;
|
return fbhp(frates(bhp)) - bhp;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Find appropriate brackets for the solution.
|
// Find appropriate brackets for the solution.
|
||||||
const std::array<double, 2> range {controls.bhp_limit, *bhp_max};
|
|
||||||
std::optional<double> approximate_solution;
|
std::optional<double> approximate_solution;
|
||||||
double low, high;
|
double low, high;
|
||||||
// trying to use bisect way to locate a bracket
|
// trying to use bisect way to locate a bracket
|
||||||
|
@ -184,6 +184,9 @@ public:
|
|||||||
const double alq_value,
|
const double alq_value,
|
||||||
DeferredLogger& deferred_logger
|
DeferredLogger& deferred_logger
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool getAllowCrossFlow() const;
|
bool getAllowCrossFlow() const;
|
||||||
double mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const;
|
double mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const;
|
||||||
@ -198,6 +201,13 @@ protected:
|
|||||||
const double vfp_flo_front,
|
const double vfp_flo_front,
|
||||||
DeferredLogger& deferred_logger) const;
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
|
std::optional<double> computeBhpAtThpLimitCommon(
|
||||||
|
const std::function<std::vector<double>(const double)>& frates,
|
||||||
|
const std::function<double(const std::vector<double>)>& fbhp,
|
||||||
|
const std::array<double, 2> range,
|
||||||
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
|
|
||||||
bool bruteForceBracket(const std::function<double(const double)>& eq,
|
bool bruteForceBracket(const std::function<double(const double)>& eq,
|
||||||
const std::array<double, 2>& range,
|
const std::array<double, 2>& range,
|
||||||
double& low, double& high,
|
double& low, double& high,
|
||||||
|
Loading…
Reference in New Issue
Block a user