Zero-Crossing Events¶
- class pathsim.events.zerocrossing.ZeroCrossing(func_evt=None, func_act=None, tolerance=0.0001)[source]¶
Bases:
EventSubclass of base ‘Event’ that triggers if the event function crosses zero. This is a bidirectional zero-crossing detector.
Monitors system state by evaluating an event function (func_evt) with scalar output and testing for zero crossings (sign changes).
func_evt(time) -> event?
If an event is detected, some action (func_act) is performed on the system state.
func_evt(time) == 0 -> event -> func_act(time)
Example
Initialize a zero-crossing event handler like this:
# define the event function def evt(t): # here we have a zero-crossing at 't==10' return t - 10 # define the action function (callback) def act(t): # do something at event resolution pass # initialize the event manager E = ZeroCrossing( func_evt=evt, # the event function func_act=act # the action function )
- Parameters:
func_evt (callable) – event function, where zeros are events
func_act (callable) – action function for event resolution
tolerance (float) – tolerance to check if detection is close to actual event
- class pathsim.events.zerocrossing.ZeroCrossingUp(func_evt=None, func_act=None, tolerance=0.0001)[source]¶
Bases:
EventModification of standard ‘ZeroCrossing’ event where events are only triggered if the event function changes sign from negative to positive (up). Also called unidirectional zero-crossing.
- class pathsim.events.zerocrossing.ZeroCrossingDown(func_evt=None, func_act=None, tolerance=0.0001)[source]¶
Bases:
EventModification of standard ‘ZeroCrossing’ event where events are only triggered if the event function changes sign from positive to negative (down). Also called unidirectional zero-crossing.