Skip to content

examples: Lorenz attractor integrated on the engine #175

Description

@sbryngelson

A small scientific showpiece to sit alongside examples/heat_equation.py, examples/poisson_spectral.py, and examples/nbody.py: integrate the Lorenz attractor on the engine and plot the butterfly.

Approach:

  • State is the 3-vector (x, y, z); the Lorenz vector field dx=sigma*(y-x), dy=x*(rho-z)-y, dz=x*y-beta*z is a handful of elementwise ops.
  • One RK4 step is a small graph (four field evaluations + the weighted combine). Roll out N steps, dispatching the step each iteration, collecting the trajectory host-side.
  • Render the trajectory (e.g. x-z projection) to a PNG with matplotlib or PIL, matching how the other scientific demos save their figures.

Deliverable: examples/lorenz.py (one file, module docstring), plus an examples/README.md entry.

Testing: compare the first ~100 steps against a numpy RK4 reference (chaotic systems diverge later, so check the short-horizon trajectory, not the endpoint). Requires any Apple Silicon Mac. _common.py has the env/scaffolding; nbody.py is a good structural template for an on-engine integrator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions