Skip to content

agalzh/lorenz-attr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation


Lorenz Attractor — Chaotic Dynamics Visualized (C++ Simulations)

This project is an exploration of the Lorenz system, one of the most iconic chaotic dynamical systems.
Using C++, I simulate the attractor in different ways:

  • clean 2D projection

  • velocity-colored rendering

  • parameter sweeps over σ, ρ, β

Every program outputs frames or images in PPM format, which can be turned into PNGs or GIF animations.

Folder Structure

lorenz_attr/
│
├── lorenz_attr_clean/
│   ├── main.cpp
│   └── lorenz.ppm
│
├── lorenz_attr_vel/
│   ├── main.cpp
│   └── lorenz_speed.ppm
│
└── lorenz_attr_sweep/
    ├── beta_sweep/
    │   ├── main.cpp
    │   └── frame_000.ppm ...
    ├── rho_sweep/
    │   ├── main.cpp
    │   └── frame_000.ppm ...
    └── sigma_sweep/
        ├── main.cpp
        └── frame_000.ppm ...

Each folder contains one fully standalone simulation. .ppm files replaced by .png or .gif for easy viewing, they can still be generated by running the code.


What the Lorenz System Represents

The Lorenz system is defined by:

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

This simple set of equations produces:

  • butterfly-shaped attractors

  • sensitivity to initial conditions

  • chaotic switching between “wings”

  • fractal interior structures

  • emergent order inside chaos

Every visualization in this repo is a different lens on the same underlying physics.


Included Programs

1. lorenz_attr_clean

Simple 2D projection (x vs z).
Shows the pure shape of the attractor with white pixels on black background.

2. lorenz_attr_vel

Colors each point by instantaneous speed ‖dx/dt‖.
Reveals fast and slow regions of the dynamics.

3. lorenz_attr_sweep

Three sub-projects that animate the attractor as:

  • σ varies

  • ρ varies

  • β varies

This produces a morphing butterfly — a visual story of how chaos emerges as parameters change.


🔧 Build & Run

All programs follow the same pattern:

Compile

g++ -O2 main.cpp -o lorenz

Run

./lorenz

The program will output .ppm image(s).


🎞 Converting Frames → GIF

If you generate animation frames (from parameter sweeps),
use ImageMagick:

magick -delay 6 -loop 0 frame_*.ppm lorenz.gif

Notes

  • All simulations use Euler integration unless otherwise noted.

  • No external libraries required — everything is pixel-by-pixel rendered.

  • The PPM format is used intentionally for simplicity and speed.

  • These programs are part of a broader exploration of chaotic systems, numerical ODEs, and scientific visualization.


About

C++ simulations of lorenz attractors under different conditions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages