Timeline
Definition of main Timeline class.
This module defines the Timeline class, which provides an interface for the simulation kernel and drives event execution. All entities are required to have an attached timeline for simulation.
- class sequence.kernel.timeline.Timeline(stop_time: int = 100000000000000000000000, formalism: str = None, truncation: int = 1)
Class for a simulation timeline.
Timeline holds entities, which are configured before the simulation. Before the start of simulation, the timeline must initialize all controlled entities. The initialization of entities may schedule events. The timeline pushes these events to its event list. The timeline starts simulation by popping the top event in the event list repeatedly. The time of popped event becomes current simulation time of the timeline. The process of popped event is executed. The simulation stops if the timestamp on popped event is equal or larger than the stop time, or if the eventlist is empty.
To monitor the progress of simulation, the Timeline.show_progress attribute can be modified to show/hide a progress bar.
- time
current simulation time (picoseconds). The smallest amount of time in the simulation timeline is 1 picosecond
- Type:
int
- stop_time
the stop (simulation) time of the simulation.
- Type:
int
- schedule_counter
the counter of scheduled events
- Type:
int
- run_counter
the counter of executed events
- Type:
int
- is_running
records if the simulation has stopped executing events.
- Type:
bool
- show_progress
show/hide the progress bar of simulation.
- Type:
bool
- quantum_manager
quantum state manager.
- Type:
- init() None
Method to initialize all simulated entities.
- now() int
Returns current simulation time.
- static ns_to_human_time(nanoseconds: float) str
Returns a string in the form [D day[s], ][H]H:MM:SS[.UUUUUU]
- progress_bar()
Method to draw progress bar.
Progress bar will display the execution time of simulation, as well as the current simulation time.
- run() None
Main simulation method.
The run method begins simulation of events. Events are continuously popped and executed, until the simulation time limit is reached or events are exhausted. A progress bar may also be displayed, if the show_progress flag is set.
- static seed(seed: int) None
Sets random seed for simulation.
- stop() None
Method to stop simulation.