Nugroho's blog.: Lorenz Attractor using Python 2.7 and Vpython Module on Mac OS X Lion

## Monday, December 12, 2011

### Lorenz Attractor using Python 2.7 and Vpython Module on Mac OS X Lion

 From Blogsy Photos
Lorenz attractor's generated by three nonlinear simultaneous equation.

x1=x0+h*a*(y0-x0)
y1=y0+h*(x0*(b-z0)-y0)
z1=z0+h*(x0*y0-c*z0)

where

a=10
b=28
c=8./4.

We can play with a,b and c to see the effect.

Here the code to visualize Lorenz attractor on Python. We need VPython module to visualize it.

`from visual import *from operator import modjl=1.h=0.01a=10b=28c=8./4.x0=0.1y0=0z0=0n=10000.r=1.while jl < n:    rate(1000)    rd=mod(n,jl)/1000    sphere(pos=(x0,y0,z0),radius=r, color=(rd,1,rd))    x1=x0+h*a*(y0-x0)    y1=y0+h*(x0*(b-z0)-y0)    z1=z0+h*(x0*y0-c*z0)    jl=jl+1    x0=x1    y0=y1    z0=z1    `

Since Vpython's not support 64bit platform, we must execute the code using 32-bit python like this

Nugrohos-MacBook-Pro:cellular nugroho\$ python2.7-32 lorenz.py

Here the result
 From Blogsy Photos