Lorenz attractor


Author: GC

Date: June 28, 2016

Previous Rössler attractor

Next Bi colored graph


We consider the Lorenz system, defined by: \[ \begin{cases} \dot{x} = s(y-x) \\ \dot{y} = r x - y - x z \\ \dot{z} = x y - b z \end{cases}. \] We compute the orbit stemming from $(0,~1,~1.05)$ with $s=10$, $r=28$ and $b=2.667$.



Lorenz attractor




Source code

#!/usr/bin/env python3

"""
Program to plot Lorenz attractor
"""

# scientific libraries
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.integrate import odeint

# parameters
s = 10
r = 28
b = 2.667

# Lorenz system
def lorenz(X, t):
    x, y, z = X
    dx = s*(y - x)
    dy = r*x - y - x*z
    dz = x*y - b*z
    return [dx, dy, dz]

# numerical integration
X0 = [0, 1, 1.05]
time = np.arange(0, 200, 0.005)
orbit = odeint(lorenz, X0, time)
x, y, z = orbit.T

# figure
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(x, y, z, '#7f007f', linewidth=0.1)
ax.set_xlim(-18, 18)
ax.set_ylim(-18, 18)
ax.set_zlim(12, 38)
ax.set_axis_off()
plt.savefig('lorenz.png', dpi=200)
plt.show()


Previous Rössler attractor

Next Bi colored graph