# siconos.kernel.TimeDiscretisation (Python class)¶

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

Bases: object

A time discretisation scheme.

A TimeDiscretisation object is used to discretized a given time interval. TimeDiscretisation are used:

• in the simulation, as a user-input to discretized [t0,T]
• in Sensor and Actuator, to define the set of time instants where the sensor or actuator must operate.

A TimeDiscretisation is defined with a starting time (t0), a time step size (h, non necessarily constant), the number of the current time step (k). The time instant values are saved in a vector tk. Depending on the way of construction of the TimeDiscretisation, all or only current and next times are saved in tk. The difference is just a question of saving memory.

Note that the TimeDiscretisation is not linked to the Model. It’s up to the

user to check that the way he builds his time-discretisation fits with the t0 and T given in the model. Main functions: * setCurrentTimeStep(), to set current h. This value will be used for all

future time steps, until next change.
• increment(), shift to next time step (increment k, and shift t[k] and t[k+1])
• currentTime(), return t[k]

Construction * input = the complete vector tk. This defines t0, T, number of time steps and

time step size (which is not necessarily constant). In this case, the whole vector is saved in the memory.
• inputs = number of time steps, t0 and T. size h is computed with t0,T and nSteps. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time.
• inputs = h and t0. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time.
• inputs = t0 and h. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time.

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

Constructors

TimeDiscretisation(TkVector newTk)

constructor with tk vector of instant times values.

Parameters: newTk – a TkVector describing the discretisation
TimeDiscretisation(double t0, double h)

constructor with the size of the default time step and t0

Parameters: t0 – initial time value h – the time step
TimeDiscretisation(int nSteps, double t0, double T)

constructor with the number of steps, t0 and T

Parameters: nSteps – the number of steps t0 – initial time value T – the final time
TimeDiscretisation(double t0, str str)

Constructor with the size of the default timestep and t0.

It creates a TimeDiscretisation using GMP for all its computation

Parameters: t0 – initial time value str – the time step in form of a string
TimeDiscretisation(TimeDiscretisation td)

Copy constructor.

Parameters: td – the TimeDiscretisation to copy
currentTimeStep(*args)[source]

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

currentTimeStep(int k) → double[source]

get the timestep $$t_{k+1} - t_k$$

Parameters: k – the index of the timestep the current time step
currentTimeStep() → mpf_t *[source]

get the timestep in gmp format

Returns: a pointer to the timestep in mpf_t format
display() → None[source]

print the discretisation data to the screen

getTk(int indx) → double[source]

get the value of tk at step k

Parameters: indx – the step a double
getTkVector() → TkVector[source]

get the TkVector _tkV

Returns: a reference to the TkVector _tkV
hConst() → bool[source]

determine whether the timestep is constant

Returns: true if the timestep is constant
hGmp() → bool[source]

determine whether the TimeDiscretisation is using GMP

Returns: true if the TimeDiscretisation is using GMP
setT0(double val) → None[source]

change t0 before the simulation starts (useful for delays)

Parameters: val – the new value for t0
setTkVector(TkVector newTk) → None[source]

set the TkVector _tkV

Parameters: newTk – the new value for _tkV