4441
Lorenz Attractor in IDL
This IDL program creates a interactive 3D plot of the Lorenz Attractor, one of the classic symbols of complexity theory. Its unpredictable yet coherent behavior is complex in apprearance - but easy to create.
The Lorenz equation was published in 1963 by a meteorologist and mathematician from MIT called Edward N. Lorenz. The paper containing the equation was titled "Deterministic non-periodic flows'' and was published in the Journal of Atmospheric Science. What drove Lorenz to find the set of three dimentional ordinary differential equations was the search for an equation that would "model some of the unpredictable behavior which we normally associate with the weather''. The Lorenz equation represents the convective motion of a fluid cell which is warmed from below and cooled from above. The same system can also apply to dynamos and lasers. In addition, some of its popularity can be attributed to the beauty of its solution. It is also important to state that the Lorenz equation has enough properties and interesting behavior that whole books are written analyzing results.
Code example:
FUNCTION dfdt,t,f
; The Lorenz system of ODEs
df=fltarr(3,/nozero)
df(0) = 10.*(f(1)-f(0))
df(1) = -f(0)*f(2) + 28.*f(0) - f(1)
df(2) = f(0)*f(1) - (8./3.)*f(2)
return,df
END
PRO rk4,t,dt,f
; The classical Runge-Kutta Method
dt1= 0.5*dt
d1 = dfdt(t, f)
f1 = f + dt1*d1
d2 = dfdt(t+dt1, f1)
f2 = f + dt1*d2
d3 = dfdt(t+dt1, f2)
f3 = f + dt*d3
d4 = dfdt(t+dt, f3)
f = f + (dt/6.)*(d1+d2+d2+d3+d3+d4)
t = t + dt
END
FUNCTION Lorenz,n,f0=f0,dt=dt,t=t
; Return a solution of the Lorenz system
if n_elements(n ) eq 0 then n=1000
if n_elements(dt) eq 0 then dt=0.01
if n_elements(f0) eq 0 then f0=[10.,10.,10.]
t=0.0
f=fltarr(3,n)
f(*,0)=f0
ff=f0
for it=1,n-1 do begin
rk4,t,dt,ff
f(*,it)=ff
end
t = dt*indgen(n)
return,f
END
PRO Lorenz_Test
a=fltarr(3000,3)
a=lorenz(3000, f0=[1.,10.,10.],dt=0.01,t=1000)
xplot3d, reform(a[0,*]), reform(a[1,*]), reform(a[2,*]), color=[0,0,255], $
xtitle='X(t)', ytitle='Y(t)', ztitle='Z(t)'
END