There are different systems that can be used in a simulation. The standard building block is a c++ system, but there are also cython and python systems that fill the same role, but are much slower. All of these systems are based on something called a commonsystem.
Systems used for simulation.
Base classes for systems. They are inherited by
- class pysim.commonsystem.CommonSystem
Common base class for systems that are editable from Python.
The parameters, can be set before the simulation starts.
The connections from this system to other systems
Add a break that will be activated if the value of the variable or state is larger than the value supplied as argument.
name (str) – Name of the variable to watch.
value (float) – If the variable is below this value then break
Add a break that will be activated if the value of the variable or state is smaller than the value supplied as argument.
name (str) – Name of the variable to watch
value (double) – If the variable is below this value then break
Set the store interval of this system.
By default the store interval for all systems in a simulation is set by the simulation, typically for the step length for fixed step algorithms. By calling this function the store interval for this system is set differently.
interval (float) – The time between stores, in seconds.
Store a input, output or state in the system.
name (str) – Name of the variable to store.
Store all inputs, outputs, states and ders in the system.
- class pysim.commonsystem.Parameters
Contains all the parameters for the system.
- class pysim.commonsystem.PysimVars
Contains all the variables for the system.
Each attribute of this class correspond to a variable of the system.
- class pysim.commonsystem.Results
Class containing the results of a simulation.
The results are stored as attributes and returned as numpy arrays. They can be scalars, vectors or matrices.
- class pysim.cppsystem.Sys
Represents a System, to be added to an Simulation for evaluation. Each System consists of parameters, inputs set prior to the simulation, States and State derivatives, and Variables, that may be stored during a simulation
This module contains functionality for creating a cython or python system for pysim. Both cython and python systems can inherit from the Sys class in this module and then be added to a simulation.
- class pysim.cythonsystem.Sys
This class is meant to be inherited by python and cython systems. They can then be set up and after that used in a simulation together with other systems, both c++, python and cython systems.
Connections between systems
- class pysim.connections.Connections
The connections of the system. The connections are either from an output or a state of a system. To add a new connection use the function add_connection.
Connect the outputs from this system to the inputs of another.
The systems that are to be connected must be derived from a CommonSystem, e.g. CppSystems and CythonSystems, or be a CompositeSystem.
outputname (str) – The name of the output of this system
inputsys (CommonSystem) – The system that is to be connected, that will receive the signals.
inputname (str) – The name of the input that will receive the signal
(optional) (output_index) – The index of a vector to use if connecting to a scalar
ValueError – If inputname or outputname are not inputs, outputs members of the system.