我有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没有太多有用的注释。所以我可以使用一些建议来解决我的问题。
发布于 2015-12-05 00:14:30
scipy.integrate.odeint接受一个函数来进行积分,因变量( u,v,w)的初始值和时间值的网格。函数需要的任何额外参数(如a、b和c)都作为args传递。
您定义的函数应该接受一个值的向量,比如X (您可以将其解包为u、v和w)、它们所对应的时间点以及任何其他参数,并且应该返回X相对于该时间点的一阶导数。
可视化的洛伦兹吸引子是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()

https://stackoverflow.com/questions/34091445
复制相似问题