15.08.2015 Views

Introduction to the Modeling and Analysis of Complex Systems

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

252 CHAPTER 13. CONTINUOUS FIELD MODELS I: MODELINGCode 13.5: transport-ca.pyimport matplotlibmatplotlib.use(’TkAgg’)from pylab import *from mpl_<strong>to</strong>olkits.mplot3d import Axes3Dn = 100 # size <strong>of</strong> grid: n * nDh = 1. / n # spatial resolution, assuming space is [0,1] * [0,1]Dt = 0.01 # temporal resolutionwx, wy = -0.01, 0.03 # constant velocity <strong>of</strong> movementxvalues, yvalues = meshgrid(arange(0, 1, Dh), arange(0, 1, Dh))def initialize():global config, nextconfig# initial configurationconfig = exp(-((xvalues - 0.5)**2 + (yvalues - 0.5)**2) / (0.2**2))nextconfig = zeros([n, n])def observe():global config, nextconfigax = gca(projection = ’3d’)ax.cla()ax.plot_surface(xvalues, yvalues, config, rstride = 5, cstride = 5)ax.grid(False)ax.set_zlim(0, 1)show() #

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!