# siconos.kernel.EventsManager (Python class)¶

class siconos.kernel.EventsManager(*args)[source]

Bases: object

Tools to handle a set of Events for the Simulation.

The EventsManager handles a set of events (from user time-discretisation, sensors, non-smooth …), and is supposed to provide to the simulation the values of “current” and “next” events to define the time-integration interval.

Events:

• currentEvent: starting time for integration. Initialized with t0 of the simulation time-discretisation.
• ETD: corresponds to the instant t[k+1] of the Simulation (user) TimeDiscretisation.
• ENonSmooth: for EventDriven simulation only. Present only if one or more non-smooth events have been detected between currentEvent and the next event.
• Sensor or Actuators Events. To each Sensor or Actuator declared in the ControlManager, corresponds an Event in the manager. When this event is processed, its time value is increased to next instant in the time- discretisation of the sensor/actuator.

Examples:

• for a TimeStepping, with one Sensor, the EventsManager looks like: {currentEvent(tk), ESensor(tsensor), ETD(tk+1)}
• for an EventDriven, with one actuator, an non-smooth event detected at time tns: {currentEvent(tk), EActuator(tact), ENonSmooth(tns), ETD(tk+1)}.

After each process, the time values of each event are updated and nextEvent points to the first event after currentEvent. Main functions * initialize(): process all events which have the same time as currentEvent * processEvents(): process all events simultaneous to nextEvent, increment

them to next step, update index sets, increment currentEvent.

Generated class (swig), based on C++ header Program listing for file kernel/src/simulationTools/EventsManager.hpp.

Constructors

EventsManager(TimeDiscretisation td)

default constructor

Parameters: td – the TimeDiscretisation used in the Simulation
currentEvent() → Event[source]

get the current event

Returns: a pointer to Event
currentTimeStep() → double[source]

Get current timestep.

Returns: the current timestep
display() → None[source]

display EventsManager data

events() → EventsContainer[source]

return all the events

Returns: a reference to the events set
getGapLimitEvents() → long int[source]

Get the gap limit between two events.

Returns: the gap limit
getTk() → double[source]
getTkp1() → double[source]

get time instant k+1 of the time discretisation

Returns: a double. If the simulation is near the end (t_{k+1} >= T), it returns NaN.
getTkp2() → double[source]

get time instant k+2 of the time discretisation

Returns: a double. If the simulation is near the end (t_{k+2} >= T), it returns NaN.
getTkp3() → double[source]

get time instant k+3 of the time discretisation.

It is used when we have to reschedule a TD Event in scheduleNonSmoothEvent

Returns: a double. If the simulation is near the end (t_{k+3} >= T), it returns NaN.
hasNextEvent() → bool[source]

check if there are some unprocessed events

Returns: true if there are unprocessed events
initialize(double T) → None[source]

Initialize: just set the final time.

Parameters: T – the final time of the Simulation
insertEvent(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

insertEvent(int type, double time) → Event[source]

insert an event of a certain type.

The event is created on the fly.

Parameters: type – the type of the event time – the time of the event a reference to the Event
insertEvent(int type, TimeDiscretisation td) → Event[source]

insert an event of a certain type.

The event is created on the fly, and the SP::TimeDiscretisation given in argument is stored inside

Parameters: type – the type of the event td – a TimeDiscretisation for the Event a reference to the Event
needsIntegration() → bool[source]

is an integration step required ? The current event and the next one may have the same time instant in which case no integration as to be performed

Returns: true if the simulation needs to be integrate, no otherwise
nextEvent() → Event[source]

get the next event to be processed.

Returns: a pointer to Event
nextTime() → double[source]

get the time of next event, in double format

Returns: the time of the next events
noSaveInMemory(Simulation sim) → None[source]

Change TimeDiscretisationEvent to TimeDiscretisationEventNoSaveInMemory.

Warning: use this at your own risk, many integrators needs previous values
to integrate properly
Parameters: sim – the Simulation that owns this EventsManager
preUpdate(Simulation sim) → None[source]

Function to be called once after initialization.

It is used to process NonSmoothEvents at the beginning of the Simulation, if there is any.

Parameters: sim – the simulation that owns this EventsManager
processEvents(Simulation sim) → None[source]

Process the next event, update the indexSets if necessary.

Parameters: sim – the simulation that owns this EventsManager
scheduleNonSmoothEvent(Simulation sim, double time, bool yes_update=True) → None[source]

add a new Event in the allEvents list and update nextEvent value

Parameters: sim – the simulation that owns this EventsManager time – the time (double format) of occurence of the event yes_update – indicator to update or not the next event (default value is true)
setGapLimitEvents(long int var) → None[source]

Set the gap limit between two events.

Parameters: var – the new _GapLimit2Events
startingTime() → double[source]

get the time of current event, in double format

Returns: the time of the last processed events
timeDiscretisation() → TimeDiscretisation[source]

get TimeDiscretisation

Returns: the TimeDiscretisation in use for the time integration
updateT(double T) → None[source]

update final time

Parameters: T – the new final time