Integrators Utilities
The utils module provides shared Numba-compatible helpers for integrators.
Event Functions
- hiten.algorithms.integrators.utils._event_crossed()[source]
Return True if a crossing consistent with direction occurred.
Accepts endpoint zeros (g_new == 0.0) to catch exact hits at the right endpoint. direction: 0 -> any; >0 -> increasing; <0 -> decreasing.
- hiten.algorithms.integrators.utils._crossed_direction()[source]
Return True if the sign change from left to mid matches direction.
This variant is used inside in-step refinement where bracket endpoints are maintained as [a,b] mapped to [g_left, g_right]. Endpoint zeros are handled by the caller using a |g_mid| <= gtol test.
- hiten.algorithms.integrators.utils._bisection_update()[source]
Update bracket [a,b] and left value using a classic bisection step.
- Parameters:
a (float) – Current bracket endpoints with a < b.
b (float) – Current bracket endpoints with a < b.
g_left (float) – Function value at the left endpoint (corresponding to ‘a’).
mid (float) – Midpoint (0.5 * (a + b)).
g_mid (float) – Function value at the midpoint.
crossed (bool) – Whether a sign-consistent crossing was found in [a, mid].
- Returns:
a_new, b_new, g_left_new – Updated bracket and left endpoint value consistent with the choice.
- Return type:
Step Control Functions
- hiten.algorithms.integrators.utils._select_initial_step()[source]
Heuristic initial step selection used by adaptive RK methods.
Matches the pattern used across RK45/DOP853: small fixed step for tiny norms, otherwise 0.01 * d0 / d1, clamped to [min_step, max_step].
- hiten.algorithms.integrators.utils._clamp_step()[source]
Clamp step size into [min_step, max_step].
PI Controller Functions
- hiten.algorithms.integrators.utils._pi_accept_factor()[source]
Compute PI controller factor after an accepted step.
Uses Hairer-style PI control with alpha = 0.4/(order+1) and beta = 1/(order+1). Returns a factor clamped to [_MIN_FACTOR, _MAX_FACTOR] with finite fallback.