#!/usr/bin/python -Wall # ================================================================ # John Kerl # kerl at math dot arizona dot edu # 2009-10-08 # Please see http://math.arizona.edu/~kerl/doc/python-talk.pdf for # more information. # ================================================================ import sys # ---------------------------------------------------------------- # Simulation parameters tmax = 10.0 h = 0.002 N = int(tmax/h) # Or: # h = 0.002 # N = 5000 # tmax = h * N # ---------------------------------------------------------------- # Initial conditions x0 = 10.0 y0 = 0.0 z0 = 10.0 # ---------------------------------------------------------------- # Functional parameters s = 10.0 r = 28.0 b = 2.666667 # ---------------------------------------------------------------- # Output parameters if len(sys.argv) == 2: h = float(sys.argv[1]) N = int(tmax/h) # ---------------------------------------------------------------- # Integration x = x0; y = y0; z = z0 t = 0 while t <= tmax: print '%11.8f %11.8f %11.8f' % (x, y, z) # Cheesy Euler integrator. xp = s * (y - x) yp = r * x - y - x * z zp = x * y - b * z x += h * xp y += h * yp z += h * zp t += h