Auto

Contents

Auto#

Switches a system between Tsit5 and Rodas5P as it turns stiff and back. Pass method=modax.Auto() to modax.solve(). See Switching methods for how the switch decides.

class modax.Auto(nonstiff: Tsit5 = Tsit5(gains=None), stiff: Rodas5P = Rodas5P(lu_precision=None, gains=None, ordering=None, stage_loop=None, fuse_stages=None), maxstiffstep: int = 10, maxnonstiffstep: int = 3, nonstifftol: float = 0.9, stifftol: float = 0.9, dtfac: float = 2.0, stiff_first: bool = False)[source]#

Bases: object

Explicit while the system is not stiff, implicit while it is.

The switch follows OrdinaryDiffEq.jl’s AutoSwitch. After every attempted step, accepted or rejected, the solver estimates the largest eigenvalue magnitude of its Jacobian. An explicit step gets it for free as max_j |k7_j - k6_j| / |y_new,j - g6_j| over the two stages Tsit5 evaluates at the step’s end (Hairer and Wanner II, p. 22, in the infinity norm). An implicit step uses ||J||_inf, the largest absolute row sum of the Jacobian it already has. A step counts as stiff when estimate * h_next exceeds stifftol (nonstifftol while explicit) times Tsit5’s stability size, 3.5068, because an explicit step that long would be unstable.

On the GPU the warp chooses, not the lane. Each lane votes, and the warp steps implicitly when any active lane wants to, so a warp never runs both methods back to back. The implicit method is always a valid step for a lane that would rather be explicit, but not the other way round.

Parameters:
  • nonstiff – The explicit method, a Tsit5.

  • stiff – The implicit method, a Rodas5P.

  • maxstiffstep – Switch to stiff after more than this many stiff steps in a row, multiplying the step by dtfac. Defaults to 10.

  • maxnonstiffstep – Switch back to nonstiff after more than this many non-stiff steps in a row, dividing the step by dtfac. Defaults to 3.

  • nonstifftol – The stiffness threshold while explicit. Defaults to 0.9.

  • stifftol – The stiffness threshold while implicit. Defaults to 0.9.

  • dtfac – The step factor applied on a switch. Defaults to 2.0.

  • stiff_first – Start implicit. Defaults to False.

Raises: