整合混沌系统

时间:2015-12-04 15:12:56

标签: python scipy integration chaos lorenz-system

我有3个方程式如下

u'= -a*(u-v)

v'= c*u-v-u*w

w'= -b*w+u*v
a=5.0 b=0.9 and c=8.2

我试图使用scipy.integrate.odeint解决从t = 0到t = 10 我的初始条件是u(0)= 0,v(0)= 1.0和w(0)= 2.0 我对scipy.integrate.odeint没有太多有用的注释。所以可以使用这个模块来解决我的问题。

1 个答案:

答案 0 :(得分:1)

scipy.integrate.odeint采用函数来集成因变量的初始值(您的uvw)和时间值网格。您的函数需要的任何额外参数(例如abc)都将作为args传递。

您定义的函数应采用值向量,例如X,(您可以解压缩到uvw),时间点它们对应于,以及任何其他参数,并且应该返回X关于该时间点的时间的第一个导数。

可视化Lorenz吸引子是a subject of one of the Matplotlib gallery examples

import numpy as np
from scipy.integrate import odeint

a, b, c = 5, 0.9, 8.2
u0, v0, w0 = 0, 1, 2

def lorenz(X, t, a, b, c):
    u, v, w = X
    up = -a*(u - v)
    vp = c*u - v - u*w
    wp = -b*w + u*v
    return up, vp, wp

t = np.linspace(0, 100, 10000)
f = odeint(lorenz, (u0, v0, w0), t, args=(a, b, c))
x, y, z = f.T

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.gca(projection='3d')

ax.plot(x, y, z)
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")
ax.set_zlabel("Z Axis")
ax.set_title("Lorenz Attractor")

plt.show()

enter image description here

相关问题