pub struct RootProblem {
pub lo: f64,
pub hi: f64,
pub guess: f64,
}Expand description
One bracketed root problem: an interval believed to contain a root, plus an optional starting iterate for the Newton solver.
§Fields and valid ranges
lo,hi— the bracket. Both must be finite. They may be given in either order; the solvers do not requirelo < hi. The residual must have opposite signs at the two ends (or be exactly zero at one of them), otherwise the lane reportsRootStatus::NotBracketedrather than guessing.guess— the initial iterate forsolve_newton_batch. Ignored bysolve_bracketed_batch, which is driven entirely by the bracket. A non-finite guess, or one outside[lo, hi], is replaced by the bracket midpoint rather than rejected — a bad guess is a performance problem, not a correctness one, because the Newton solver is bracket-safeguarded.
§Units
Dimensionless f64 in whatever units the caller’s abscissa carries — kelvin
for a temperature inversion, dimensionless for a compressibility factor. See
the module-level “Units” section.
§Example
use outram_foam_basic_lib::math::parallel::RootProblem;
// Bracket only; the Newton guess defaults to the midpoint.
let p = RootProblem::new(300.0, 3000.0);
assert_eq!(p.guess, 1650.0);
// Or seed Newton from the previous timestep's answer.
let q = RootProblem::with_guess(300.0, 3000.0, 812.5);
assert_eq!(q.guess, 812.5);Fields§
§lo: f64One end of the bracket. Finite; need not be less than hi.
hi: f64The other end of the bracket. Finite; need not be greater than lo.
guess: f64Starting iterate for solve_newton_batch; ignored by
solve_bracketed_batch.
Implementations§
Source§impl RootProblem
impl RootProblem
Sourcepub fn new(lo: f64, hi: f64) -> Self
pub fn new(lo: f64, hi: f64) -> Self
A problem bracketed on [lo, hi], with the Newton guess set to the
bracket midpoint.
§Arguments
lo,hi— the bracket ends, finite, in either order.
Sourcepub fn with_guess(lo: f64, hi: f64, guess: f64) -> Self
pub fn with_guess(lo: f64, hi: f64, guess: f64) -> Self
A problem bracketed on [lo, hi] with an explicit Newton starting
iterate.
Seeding from the previous timestep’s converged value is the usual reason to reach for this: it typically halves the iteration count of a per-cell thermodynamic inversion.
§Arguments
lo,hi— the bracket ends, finite, in either order.guess— starting iterate. Silently replaced by the midpoint if it is non-finite or outside the bracket.