Skip to content

Stepsize controller

In order to adjust the time stepping during integrating we provide torchdde.AdaptiveStepSizeController for adaptive methods (like torchdde.Dopri5) and torchdde.ConstantStepSizeController for constant stepsive methods (like torchdde.RK4).

torchdde.ConstantStepSizeController ¤

Constant step size controller that always returns the same step size.

The user must define dt0 via torchdde.integrate.integrate

torchdde.AdaptiveStepSizeController ¤

Adapts the step size to produce a solution accurate to a given tolerance. The tolerance is calculated as atol + rtol * y for the evolving solution y.

Steps are adapted using a PID controller.

Choosing tolerances

The choice of rtol and atol are used to determine how accurately you would like the numerical approximation to your equation. If you are solving a problem "harder" problem then you probably need to raise the tolerances to get an appropriate solution.

Default values usually are rtol=1e-3 and atol=1e-6.

Choosing PID coefficients

We refer the reader to Diffrax clear explanation here.

__init__(self, atol, rtol, safety = 0.9, pcoeff = 0.0, icoeff = 1.0, dcoeff = 0.0, factormax = 10.0, dtmin = None, dtmax = None) ¤

Arguments:

  • atol: Absolute tolerance.
  • rtol: Relative tolerance.
  • safety: Multiplicative safety factor.
  • pcoeff: The coefficient of the proportional part of the step size control.
  • icoeff: The coefficient of the integral part of the step size control.
  • dcoeff: The coefficient of the derivative part of the step size control.
  • factormax: Maximum amount a step size can be increased relative to the previous step.
  • dtmin: Minimum step size. The step size is either clipped to this value, or an error raised if the step size decreases below this, depending on force_dtmin.
  • dtmax: Maximum step size; the step size is clipped to this value.