2 chaotic Lorenz dynamical systems get synchronized with time. (Notice 2 y and 2 z values start differently but approach each other later.)
I used the x variable as the synchronization signal but y or z can also be used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # Synchronized Chaos using Lorenz Attractor
# FB - 201108011
import random
delta = float(10) # Prandtl number
r = float(28)
b = float(8) / 3
h = 1e-3 # time step
def Lorenz(x, y, z):
dx_dt = delta * (y - x)
dy_dt = r * x - y - x * z
dz_dt = x * y - b * z
x += dx_dt * h
y += dy_dt * h
z += dz_dt * h
return (x, y, z)
maxIt = 2000
size = 30
# initial state of the driver system
x = random.random() * size * 2 - 1
y = random.random() * size * 2 - 1
z = random.random() * size * 2 - 1
# initial state of the sub-system
# x1 = random.random() * size * 2 - 1
y1 = random.random() * size * 2 - 1
z1 = random.random() * size * 2 - 1
for i in range(maxIt):
(x, y, z) = Lorenz(x, y, z)
# x variable of the driver is chosen as driver signal
(x1, y1, z1) = Lorenz(x, y1, z1)
# 2 y and 2 z values should become synched w/ time
print '(%04i, %+07.3f, %+07.3f, %+07.3f, %+07.3f)' % (i, y, y1, z, z1)
|