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.

258 CHAPTER 13. CONTINUOUS FIELD MODELS I: MODELINGglobal a, b, nexta, nextbfor x in xrange(n):for y in xrange(n):# state-transition functionaC, aR, aL, aU, aD = a[x,y], a[(x+1)%n,y], a[(x-1)%n,y], \a[x,(y+1)%n], a[x,(y-1)%n]bC, bR, bL, bU, bD = b[x,y], b[(x+1)%n,y], b[(x-1)%n,y], \b[x,(y+1)%n], b[x,(y-1)%n]bLapNum = bR + bL + bU + bD - 4 * bCnexta[x,y] = aC + mu_a * ((aR-aL)*(bR-bL)+(aU-aD)*(bU-bD)+4*aC*bLapNum) * Dt/(4*Dh**2)nextb[x,y] = bC + mu_b * bLapNum * Dt/(Dh**2)a, nexta = nexta, ab, nextb = nextb, bimport pycxsimula<strong>to</strong>rpycxsimula<strong>to</strong>r.GUI(stepSize = 50).start(func=[initialize, observe, update])Note that <strong>the</strong> observe function now uses subplot <strong>to</strong> show two scalar fields for a <strong>and</strong> b.The result is shown in Fig. 13.16.0a0b0a0b0a0b2020202020204040404040406060606060608080808080800 20 40 60 800 20 40 60 800 20 40 60 800 20 40 60 800 20 40 60 800 20 40 60 80Figure 13.16: Visual output <strong>of</strong> Code 13.7. Time flows from left <strong>to</strong> right.Exercise 13.15 Modify Code 13.7 so that both species diffuse <strong>and</strong> try <strong>to</strong> escapefrom each o<strong>the</strong>r. Run simulations <strong>to</strong> see how <strong>the</strong> system behaves.

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

Saved successfully!

Ooh no, something went wrong!