pub struct AdaptiveConfig {
pub dt_init: f64,
pub dt_min: f64,
pub dt_max: f64,
pub reltol: f64,
pub abstol: f64,
}Expand description
Parameters for [lte_attempt]’s local-truncation-error step-size control.
reltol/abstol together form the per-unknown error scale abstol + reltol * max(|x_trapezoidal|, |x_backward_euler|) a step’s estimated error is normalized against
(the same RELTOL/ABSTOL idea every SPICE-family tool exposes) — reltol alone isn’t
enough because it degenerates to zero right where many circuit unknowns spend a lot of
their time (an AC-coupled voltage or an inductor current crossing zero), so abstol is the
floor that keeps step control meaningful there. This crate uses one scalar abstol for
every unknown regardless of whether it’s a voltage or a current — a real simplification
relative to SPICE’s own separate voltage/current tolerances (VNTOL/ABSTOL), noted
directly rather than silently: pick abstol relative to the smaller-magnitude unknowns in
your own circuit if the defaults reject too aggressively.
Fields§
§dt_init: f64The very first trial step size.
dt_min: f64Never shrink below this, no matter how large the estimated error — accept whatever
result comes out instead of looping forever (a run that only converges below dt_min
needs a smaller dt_min or looser tolerances, not an infinite retry loop).
dt_max: f64Never grow above this, even if the estimated error says a step could be much larger —
the same role TSTEP/a .tran step ceiling plays in a real SPICE deck: without it, a
long quiet stretch could grow the step past the resolution needed to catch the next
fast event at all.
reltol: f64Relative error tolerance (dimensionless, e.g. 1e-3 for 0.1%).
abstol: f64Absolute error tolerance (same units as the circuit’s own unknowns — volts/amps).
Implementations§
Source§impl AdaptiveConfig
impl AdaptiveConfig
Sourcepub fn from_t_final(t_final: f64) -> Self
pub fn from_t_final(t_final: f64) -> Self
A reasonable default derived from t_final alone, for when the caller hasn’t measured
their own circuit’s time constants — the same situation a real SPICE .tran line is
in when only TSTOP is meaningfully chosen by the user and the internal step is left to
the tool. dt_max = t_final/1000 (a 1000-point default resolution, comparable to a
typical SPICE run’s point count), dt_init = dt_max/100 (start conservatively, like
every real tool’s own small first step, then grow once the solution’s behavior is
actually known), dt_min = dt_max*1e-9.