Skip to content

A comprehensive implementation of the Lorenz system demonstrating chaos theory through interactive visualizations and animations with extensive customization options.

License

Notifications You must be signed in to change notification settings

vaibhawvipul/lorenz-attractor-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lorenz Attractor Simulation

A comprehensive Python implementation of the famous Lorenz equations that demonstrates chaos theory through interactive visualizations and animations.

What is the Lorenz Attractor?

The Lorenz attractor is a set of chaotic solutions to the Lorenz system of differential equations, discovered by Edward Lorenz in 1963. It's one of the most famous examples of chaos theory and demonstrates how small changes in initial conditions can lead to vastly different outcomes - the so-called "butterfly effect."

The system models simplified atmospheric convection and is described by three coupled differential equations:

dx/dt = σ(y - x)
dy/dt = x(ρ - z) - y
dz/dt = xy - βz

Where:

  • σ (sigma) = Prandtl number (ratio of viscosity to thermal diffusivity)
  • ρ (rho) = Rayleigh number (ratio of buoyancy to viscous forces)
  • β (beta) = Geometric factor (related to aspect ratio of convection cells)

Lorenz Attractor Lorenz Attractor

Installation

Prerequisites

pip install -r requirements.txt

Usage

Run the program:

python lorenz_attractor.py

Technical Details

Numerical Integration

The system uses the 4th-order Runge-Kutta method (RK4) for solving the differential equations:

k1 = h * f(yn, tn)
k2 = h * f(yn + k1/2, tn + h/2)
k3 = h * f(yn + k2/2, tn + h/2)
k4 = h * f(yn + k3, tn + h)
yn+1 = yn + (k1 + 2*k2 + 2*k3 + k4) / 6

This provides 4th-order accuracy and excellent stability for chaotic systems.

Default Parameters

  • σ = 10.0: Standard Prandtl number
  • ρ = 28.0: Rayleigh number (above critical value ~24.74 for chaos)
  • β = 8/3 ≈ 2.667: Geometric factor from Lorenz's original paper
  • Initial conditions: (1.0, 1.0, 1.0)
  • Time step: 0.01 (adjustable)

Animation Features

  • Butterfly Effect Animation:
    • Compares trajectories starting at (1,1,1) and (1,1,1.001)
    • Shows complete trajectory history (no trailing erasure)
    • Displays real-time distance between trajectories
    • Fast animation with 10ms frame intervals

Mathematical Background

Chaos Theory Concepts Demonstrated

  1. Sensitive Dependence on Initial Conditions: Tiny differences (0.001) grow exponentially
  2. Strange Attractor: Non-periodic, bounded trajectories
  3. Deterministic Chaos: Predictable equations producing unpredictable behavior
  4. Fractal Geometry: Self-similar structure at different scales

Parameter Regimes

  • ρ < 1: System decays to origin
  • 1 < ρ < 24.74: Stable fixed points (periodic)
  • ρ > 24.74: Chaotic behavior begins
  • ρ = 28: Classic chaotic regime

Customization

Modifying Parameters

# Create custom Lorenz system
lorenz = LorenzAttractor(sigma=15.0, rho=35.0, beta=3.0)

# Simulate with different conditions
initial_state = np.array([2.0, 3.0, 4.0])
t, trajectory = lorenz.simulate(initial_state, t_span=100, dt=0.005)

Animation Speed Control

  • Decrease interval parameter for faster animation
  • Increase dt for larger time steps
  • Modify frame skipping in animation functions

Visualization Options

  • Adjust linewidth for thicker/thinner lines
  • Change alpha for transparency effects
  • Modify markersize for point sizes
  • Customize colors and styles

Performance Notes

  • Memory Usage: Scales with simulation time and time step
  • Computation Time: RK4 method provides good accuracy/speed balance
  • Animation Performance: Optimized with frame skipping and efficient updates
  • Large Simulations: Consider increasing dt for very long time spans

About

A comprehensive implementation of the Lorenz system demonstrating chaos theory through interactive visualizations and animations with extensive customization options.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages