pathsim.events.schedule module¶
- class pathsim.events.schedule.Schedule(t_start=0, t_end=None, t_period=1, func_act=None, tolerance=1e-16)[source]¶
Bases:
EventSubclass of base ‘Event’ that triggers dependent on the evaluation time.
Monitors time in every timestep and triggers periodically (period). This event does not have an event function as the event condition only depends on time.
time == next_schedule_time -> event
Example
Initialize a scheduled event handler like this:
#define the action function (callback) def act(t): #do something at event resolution pass #initialize the event manager E = Schedule( t_start=0, #starting at t=0 t_end=None, #never ending t_period=3, #triggering every 3 time units func_act=act #resulting in a callback )
- Parameters:
- detect(t)[source]¶
Check if the event condition is satisfied, i.e. if the time period switch is within the current timestep.
- Parameters:
t (float) – evaluation time for detection
- Returns:
detected (bool) – was an event detected?
close (bool) – are we close to the event?
ratio (float) – interpolated event location ratio in timestep
- class pathsim.events.schedule.ScheduleList(times_evt, func_act=None, tolerance=1e-16)[source]¶
Bases:
ScheduleSubclass of base ‘Schedule’ that triggers dependent on the evaluation time.
Monitors time in every timestep and triggers at the next event time from the time list. This event does not have an event function as the event condition only depends on time.
time == next_scheduled_time -> event
Example
Initialize a scheduled event handler like this:
#define the action function (callback) def act(t): #do something at event resolution pass #initialize the event manager E = ScheduleList( times_evt=[1, 5, 12, 300], #event times where to trigger func_act=act #resulting in a callback )
- Parameters:
- detect(t)[source]¶
Check if the event condition is satisfied, i.e. if the time period switch is within the current timestep.
- Parameters:
t (float) – evaluation time for detection
- Returns:
detected (bool) – was an event detected?
close (bool) – are we close to the event?
ratio (float) – interpolated event location ratio in timestep