simulation

Introduction

The simulation module contains a Sim object that represents the simulation. The systems added to the Sim object will be used when the simulation is used. The module also contains a number of solvers that the Sim object can use.

Simulation

class pysim.simulation.Sim

This class represents an entire simulation. Each simulation consists of one or more Systems that can be added to this class

systems

The systems added to the simulation

Type

OrderedDict

add_system()

Add a system that will participate in this simulation

get_time()

Get the current time of the simulation. Before any simulation has been run this is 0, but after each simulation run it is increased

load_config()

Loads a number of systems and their input values from a file. The file is loaded from the path supplied as an argument to the function

save_config()

Stores the simulations systems and their input values to a file. The path for the file to be stored at is given by the arguement’ “filepath”. This file can later be read with the function “load_config”.

simulate()

Start or continue a simulation for duration seconds. The default ODE-solver used is the classic fixed steplength Runge Kutta 4 (rk4), but it is also possible to use other solvers by supplying the solver in the argument “solver”. For fixed lenght algorithms the default time step is 0.1 seconds.

Solvers

There is currently three solvers that can be used by the Sim class to solve the differential equations. The default is the Runge Kutta 4 algorithm which uses a fixed steplength. But there is two addional solvers with variable step length that can be used.

class pysim.simulation.Runge_Kutta_4

A Runge Kutta 4 solver that can be used when calculating a simulation

class pysim.simulation.Cash_Karp

An adaptive steplength solver that can be used when calculating a simulation

class pysim.simulation.Dormand_Prince_5

An adaptive steplength solver that can be used when calculating a simulation