aquakin.Event#
- class aquakin.Event(cond_fn=None, at_times=None, direction=0, apply=None, terminal=False, name=None)[source]#
Bases:
objectA 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 functioncond_fn(t, y, args)whose zero crossing (indirection) 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.yis the full state vector (the reactor concentration vector, or the flat plant state);argsis the solve’s parameter argument.at_times (sequence of float, optional) – Times at which a time event fires.
direction (int, optional) – For a
cond_fnevent:+1fires only on an upward crossing (negative→positive),-1only downward,0(default) either way.apply (callable, optional) – State reset
apply(t, y, args) -> y_newproducing the post-event state (same shape asy).None(default) leaves the state unchanged – useful for a pureterminaldetector.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
applyat_timescond_fndirectionis_time_eventnameterminal