aquakin.Event#

class aquakin.Event(cond_fn=None, at_times=None, direction=0, apply=None, terminal=False, name=None)[source]#

Bases: object

A located discontinuity in a solve: a time or state trigger + a reset.

Exactly one trigger must be given:

  • at_times – a sequence of times (in the solve’s time unit) at which the event fires. AD-safe: the segment boundaries are static.

  • cond_fn – a scalar function cond_fn(t, y, args) whose zero crossing (in direction) is the event. Located by a root find; forward-simulation only (the firing count is data-dependent).

Parameters:
  • cond_fn (callable, optional) – Root-crossing condition cond_fn(t, y, args) -> scalar. y is the full state vector (the reactor concentration vector, or the flat plant state); args is the solve’s parameter argument.

  • at_times (sequence of float, optional) – Times at which a time event fires.

  • direction (int, optional) – For a cond_fn event: +1 fires only on an upward crossing (negative→positive), -1 only downward, 0 (default) either way.

  • apply (callable, optional) – State reset apply(t, y, args) -> y_new producing the post-event state (same shape as y). None (default) leaves the state unchanged – useful for a pure terminal detector.

  • terminal (bool, optional) – If True, the solve stops when this event fires (after applying apply).

  • name (str, optional) – Label for the event log (defaults to event{i}).

__init__(cond_fn=None, at_times=None, direction=0, apply=None, terminal=False, name=None)#
Parameters:
  • cond_fn (Callable | None)

  • at_times (Sequence[float] | None)

  • direction (int)

  • apply (Callable | None)

  • terminal (bool)

  • name (str | None)

Return type:

None

Methods

__init__([cond_fn, at_times, direction, ...])

Attributes

apply

at_times

cond_fn

direction

is_time_event

name

terminal