# Events¤

Events allow for interrupting a differential equation solve, and changing its internal state, or terminating the solve before t1 is reached.

At the moment a single kind of event is supported: discrete events which are checked at the end of every step, and which halt the integration once they become true.

diffrax.AbstractDiscreteTerminatingEvent

####  diffrax.AbstractDiscreteTerminatingEvent ¤

Evaluated at the end of each integration step. If true then the solve is stopped at that time.

##### __call__(self, state, **kwargs) abstractmethod ¤

Arguments:

• state: a dataclass of the evolving state of the system, including in particular the solution state.y at time state.tprev.
• **kwargs: the integration options held constant throughout the solve are passed as keyword arguments: terms, solver, args. etc.

Returns

A boolean. If true then the solve is terminated.

####  diffrax.DiscreteTerminatingEvent (AbstractDiscreteTerminatingEvent) ¤

Terminates the solve if its condition is ever active.

##### __init__(self, cond_fn: Callable[..., bool])¤

Arguments:

• cond_fn: A function (state, **kwargs) -> bool that is evaluated on every step of the differential equation solve. If it returns True then the solve is finished at that timestep. state is a dataclass of the evolving state of the system, including in particular the solution state.y at time state.tprev. Passed as keyword arguments are the terms, solver, args etc. that are constant throughout the solve.

####  diffrax.SteadyStateEvent (AbstractDiscreteTerminatingEvent) ¤

Terminates the solve once it reaches a steady state.

##### __init__(self, rtol: Optional[float] = None, atol: Optional[float] = None, norm: Callable[[PyTree], Scalar] = <function rms_norm>)¤

Arguments:

• rtol: The relative tolerance for determining convergence. Defaults to the same rtol as passed to an adaptive step controller if one is used.
• atol: The absolute tolerance for determining convergence. Defaults to the same atol as passed to an adaptive step controller if one is used.
• norm: A function PyTree -> Scalar, which is called to determine whether the vector field is close to zero.