TimeManager

About the TimeManager class

The WaveBlocks Project

@author: R. Bourquin @copyright: Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016 R. Bourquin @license: Modified BSD License

Inheritance diagram

Inheritance diagram of TimeManager

Class documentation

class WaveBlocksND.TimeManager(parameters)[source]

This class performs several computations with time, timesteps and so forth.

The important quantities here are:

Quantity Parameter Name Description
T T the fixed simulation end time
\tau dt the size of the timestep
N nsteps the overall number of timesteps.
t   an unspecified time in the interval [0, T]
n   an unspecified timestep in the interval [0, N]

The important relations that hold are T = N \tau and in analogy t = n \tau. There are also conversion routines for t and n.

The simulation parameters handed over to the constructor must contain at least two out of the three values T, \tau and N. If all three are given, the user is responsible for compatible values.

Additionally the class contains some routines for determining if and when some events (for example saving data) should occur.

add_to_eventlist(alist)[source]

Add a list of times and/or timesteps to the list of times when irregular events get triggered.

Parameters:alist – A list with integers (interpreted as timesteps) and/or floats (interpreted as times)

Note that the times and timesteps can be mixed and need not to be given in monotone order.

compute_endtime()[source]

Computes the simulation endtime T.

Returns:The endtime T.
compute_number_events()[source]

Compute the number of events we will perform during the simulation. This can for example be used to determine how much space to allocate in the output files if the events are times at which simulation data is saved.

Returns:The number of events.
compute_number_timesteps()[source]

Computes the number n of time steps we will perform.

Returns:the number n of timesteps.
compute_time(n)[source]

Compute the time t from a timestep n such that t = n \tau holds.

Parameters:n – The timestep n of which we want to find the corresponding time.
Returns:The corresponding time t.
compute_timestep(t)[source]

Compute the timestep n from a time t such that t = n \tau holds.

Parameters:t – The time t of which we want to find the timestep number.
Returns:The corresponding timestep n.

Note that the user has to ensure that time t is an integral multiple of \tau.

compute_timestep_size()[source]

Computes the simulation timestep size \tau.

Returns:The timestep \tau.
get_T()[source]

Set the simulation endtime T.

Returns:The endtime T.
get_dt()[source]

Get the simulation timestep size \tau.

Returns:The timestep \tau.
get_nsteps()[source]

Get the number n of timesteps the simulation runs.

Returns:the number n of timesteps.
is_event(n)[source]

Determine if an event occurs right now.

Parameters:n – The current timestep in question.
Returns:True or False.
set_T(T)[source]

Set the simulation endtime T.

Parameters:T – The simulation end time.
set_dt(dt)[source]

Set the simulation timestep size \tau.

Parameters:dt – The simulation timestep size.
set_interval(interval)[source]

Set the interval for regular events.

Parameters:interval – The interval at which regular events get triggered.

Note that a value of 0 means there are no regular events.

set_nsteps(nsteps)[source]

Set the number of timesteps the simulation runs.

Parameters:nsteps – The number n timesteps we do.