MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ solve_pressure_flow()

template<typename FlowLaw>
requires std::invocable<FlowLaw&, double> && std::convertible_to<std::invoke_result_t<FlowLaw&, double>, FlowSample>
std::tuple< double, double, RootStatus > MayaFlux::Kinesis::Acoustics::solve_pressure_flow ( FlowLaw law,
double gain,
double target,
double lower,
double upper,
double guess,
const RootOptions & options = {} )
nodiscard

Solve a coupling for any flow law.

Parameters
lawCallable returning a FlowSample for a pressure difference
gainFrom flow_coupling_gain
targetFrom flow_coupling_target
lowerLower end of a bracket holding the solution
upperUpper end of the bracket
guessStarting difference, usually the previous sample's
optionsStopping rule, see bracketed_newton
Returns
The pressure difference, the flow there, and the search status

A flow whose magnitude never exceeds F brackets the solution in [target - gain F, target + gain F]. The bracket must contain a sign change of d + gain * flow(d) - target, which the search checks unless options.check_bracket is off.

Definition at line 86 of file PressureFlowSolve.hpp.

88 {})
89{
90 const auto equation = [&](double difference) -> RootSample {
91 const auto [flow, slope] = static_cast<FlowSample>(law(difference));
92 return { difference + gain * flow - target, 1.0 + gain * slope };
93 };
94
95 const auto [difference, status] = bracketed_newton(equation, lower, upper, guess, options);
96 return { difference, static_cast<FlowSample>(law(difference)).first, status };
97}
std::pair< double, double > FlowSample
Flow through a coupling, then its slope against the pressure difference.
RootResult bracketed_newton(Function function, double lower, double upper, double guess, const RootOptions &options={})
Root of an increasing function by Newton steps kept inside a bracket.
std::pair< double, double > RootSample
Value and slope of a function at one point.