Lorenz Attractor
Simulation of the famous Lorenz attractor, a chaotic dynamical system.
You can also find this example as a single file in the GitHub repository.
The Lorenz System
The system consists of three coupled nonlinear ODEs:
MATHDISPLAY0ENDMATH MATHDISPLAY1ENDMATH MATHDISPLAY2ENDMATH
Where the parameters are:
- MATHINLINE3ENDMATH (Prandtl number)
- MATHINLINE4ENDMATH (Rayleigh number)
- MATHINLINE5ENDMATH (geometric factor)
Chaotic Behavior
For these parameters, the system exhibits sensitive dependence on initial conditions - tiny changes in starting values lead to completely different trajectories. Despite being deterministic, the system appears random and unpredictable over long timescales.
Building the System in PathSim
We'll construct the Lorenz system using basic blocks (integrators, amplifiers, multipliers, adders) to show PathSim's block-diagram approach to ODEs.
The Lorenz system is built using basic blocks like Integrator, Multiplier, and Adder to demonstrate PathSim\'s block-diagram approach.
System Parameters and Initial Conditions
Block Diagram
We create blocks for each equation:
For dx/dt = σ(y - x):
- Compute (y - x) with an adder
- Multiply by σ
- Integrate to get x
For dy/dt = x(ρ - z) - y:
- Compute (ρ - z)
- Multiply by x
- Subtract y
- Integrate to get y
For dz/dt = xy - βz:
- Multiply x and y
- Subtract βz
- Integrate to get z
Connections
The connections wire up the differential equations according to the Lorenz system.
Simulation Setup
We use an adaptive Runge-Kutta solver (RKBS32) with specified tolerances to handle the complex dynamics efficiently.
12:43:49 - INFO - LOGGING (log: True) 12:43:49 - INFO - BLOCKS (total: 13, dynamic: 3, static: 10, eventful: 0) 12:43:49 - INFO - GRAPH (nodes: 13, edges: 20, alg. depth: 4, loop depth: 0, runtime: 0.141ms) 12:43:49 - INFO - STARTING -> TRANSIENT (Duration: 50.00s) 12:43:49 - INFO - -------------------- 1% | 0.0s<3.8s | 1523.7 it/s 12:43:50 - INFO - ####---------------- 20% | 0.4s<1.3s | 1684.8 it/s 12:43:50 - INFO - ########------------ 40% | 1.0s<1.2s | 1491.0 it/s 12:43:51 - INFO - ############-------- 60% | 1.7s<1.5s | 1572.8 it/s 12:43:52 - INFO - ################---- 80% | 2.5s<0.6s | 1397.2 it/s 12:43:52 - INFO - #################### 100% | 3.0s<--:-- | 3011.4 it/s 12:43:52 - INFO - FINISHED -> TRANSIENT (total steps: 4669, successful: 4057, runtime: 2998.76 ms)
Results: Time Series
First, let's look at how x, y, and z evolve over time. Notice the irregular, non-repeating patterns characteristic of chaos.
The Famous Butterfly Shape - 3D Attractor
The true beauty of the Lorenz attractor emerges in 3D phase space. The trajectory traces out a distinctive "butterfly" or "owl face" shape with two lobes. The system orbits chaotically around two unstable fixed points.
2D Projections
We can also view 2D projections of the attractor to see its structure from different angles.