Linear Feedback System
Simulation of a simple linear feedback system with step response.
You can also find this example as a single file in the GitHub repository.

The block diagramm above can be translated to a netlist by using the blocks and the connection class provided by PathSim. First lets import the Simulation and Connection classes and the required blocks from the block library:
Then lets define the system parameters such as the initial value x0 of the integrator, the linear feedback gain a and the time dependend source function s(t).
Now we can construct the system by instantiating the blocks we need with their corresponding prameters and collect them together in a list:
Afterwards, the connections between the blocks can be defined. The first argument of the Connection class is the source block and its port (Src[0] would be port 0 of the instance of the Source block, which is also the default port).
Finally we can instantiate the Simulation with the blocks, connections and some additional parameters such as the timestep. In this case, no special ODE solver is specified, so PathSim uses the default SSPRK22 integrator which is a fixed step 2nd order explicit Runge-Kutta method. A good starting point. Then we can run the simulation for some duration which is set as 4*tau in this example.
12:43:48 - INFO - LOGGING (log: True) 12:43:48 - INFO - BLOCKS (total: 5, dynamic: 1, static: 4, eventful: 0) 12:43:48 - INFO - GRAPH (nodes: 5, edges: 6, alg. depth: 3, loop depth: 0, runtime: 0.080ms) 12:43:48 - INFO - STARTING -> TRANSIENT (Duration: 12.00s) 12:43:48 - INFO - -------------------- 1% | 0.0s<0.1s | 9684.6 it/s 12:43:48 - INFO - ####---------------- 20% | 0.0s<0.1s | 10902.0 it/s 12:43:48 - INFO - ########------------ 40% | 0.1s<0.1s | 10596.7 it/s 12:43:48 - INFO - ############-------- 60% | 0.1s<0.0s | 11032.5 it/s 12:43:48 - INFO - ################---- 80% | 0.1s<0.0s | 9766.8 it/s 12:43:48 - INFO - #################### 100% | 0.1s<--:-- | 11188.2 it/s 12:43:48 - INFO - FINISHED -> TRANSIENT (total steps: 1201, successful: 1201, runtime: 132.12 ms)
Due to the object oriented and decentralized nature of PathSim, the Scope block holds the recorded time series data from the simulation internally. It can be accessed by its read method
or plotted directly in an external matplotlib window using the plot method