coupled map lattice in python

  • Last Update :
  • Techknowledgy :

I essentially modified your program a little to make it vectorized: I removed the for loop over p, which made the whole thing run almost instantaneously. This enabled me to use a much denser sampling for p, and allowed me to plot horizontal lines.

from __future__
import print_function, division

import numpy as np
import matplotlib.pyplot as plt

L = 60 # no.of lattice sites
eps = 0.6 # diffusive coupling strength
r = 4.0 # control parameter r

np.random.seed(1010)
ic = np.random.uniform(0.1, 0.9, L) # random initial condition betn.(0, 1)

nTransients = 100 # The iterates we 'll throw away
nIterates = 100 # This sets how much the attractor is filled in
   nSteps = 4000 # This sets how dense the bifurcation diagram will be

pLow = -0.4
pHigh = 0.0
pInc = (pHigh - pLow) / nSteps

def LM(p, x):
   x_new = np.empty(x.shape)
for i in range(L):
   if i == 0:
   x_new[i] = ((1 - eps) * (r * x[i] * (1 - x[i])) + 0.5 * eps * (r * x[L - 1] * (1 - x[L - 1]) + r * x[i + 1] * (1 - x[i + 1])) + p)
elif i == L - 1:
   x_new[i] = ((1 - eps) * (r * x[i] * (1 - x[i])) + 0.5 * eps * (r * x[i - 1] * (1 - x[i - 1]) + r * x[0] * (1 - x[0])) + p)
elif i > 0 and i < L - 1:
   x_new[i] = ((1 - eps) * (r * x[i] * (1 - x[i])) + 0.5 * eps * (r * x[i - 1] * (1 - x[i - 1]) + r * x[i + 1] * (1 - x[i + 1])) + p)
return x_new

p = np.arange(pLow, pHigh, pInc)
state = np.tile(ic[: , np.newaxis], (1, p.size))

# set initial conditions
#
throw away the transient iterations
for i in range(nTransients):
   state = LM(p, state)

# now store the next batch of iterates
x = np.empty((p.size, nIterates)) # store iterates
for i in range(nIterates):
   state = LM(p, state)
x[: , i] = state[L // 2 - 1]

      # Plot the list of (r, x) pairs as pixels plt.plot(p, x, c = (0, 0, 0, 0.1)) plt.xlabel('Pinning Strength p') plt.ylabel('X(L/2)')

      # Display plot in window plt.show()

Suggestion : 2

A simple python model of 2D Coupled Map Lattice Model (reference: https://en.wikipedia.org/wiki/Coupled_map_lattice)., 2D Coupled Map Lattice Model , 2D Coupled Map Lattice Model ,Von Neumann neighborhood

python main.py
python main.py - d - mat gaussian 256 - o - nit 20 - c 0.1 - map logistic 4.0

Suggestion : 3

Published 31 May 2000

Coupled maps with local and global interactions.

@article {
   Ouchi2000CoupledMW,
   title = {
      Coupled maps with local and global interactions.
   },
   author = {
      Noriyuki B.Ouchi and Kunihiko Kaneko
   },
   journal = {
      Chaos
   },
   year = {
      2000
   },
   volume = {
      10 2
   },
   pages = {
      359 - 365
   }
}