python - Chua的电路使用python和绘图
问题描述
我尝试使用 Python 实现 Chua 系统。但是图表与我们需要的非常不同。用这样的系统实现
我在互联网上没有找到任何地方并尝试自己做。但是在python中我仍然没有什么经验。
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
a,b,e,x2=2.8,3,0.03,9
def f(y, t):
y1, y2, y3 = y
return [(-a/b)*(y2-y1),
(-1/b)*((y2-y1)+y3)+(e/b)*(x2-y2),
(b*y2)]
t = np.linspace(0,20,2001)
y0 = [1, -1, 10]
[y1,y2,y3]=odeint(f, y0, t, full_output=False).T
fig = plt.figure(facecolor='white')
ax=Axes3D(fig)
ax.plot(y1,y2,y3,linewidth=2)
plt.xlabel('y1')
plt.ylabel('y2')
plt.title("primary: y0 = [1, -1, 10]")
y0 = [1.0001, -1, 10]
[y1,y2,y3]=odeint(f, y0, t, full_output=False).T
fig = plt.figure(facecolor='white')
ax=Axes3D(fig)
ax.plot(y1,y2,y3,linewidth=2)
plt.xlabel('y1')
plt.ylabel('y2')
plt.title("primary: y0 = [1.0001, -1, 10]")
plt.show()
解决方案
由于我不太了解 Chua 的振荡器,除非我弄错了,否则我确实认为您的 ODE 系统定义中存在错误。
简单地基于蔡氏电路的维基百科英文页面。您似乎未能提供f
描述非线性电阻器电响应的函数表达式。所以,从给定的方程和表达式开始f
,这是我的尝试odeint
:
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# parameters
alpha = 15.395
beta = 28
R = -1.143
C_2 = -0.714
def chua(u, t):
x, y, z = u
# electrical response of the nonlinear resistor
f_x = C_2*x + 0.5*(R-C_2)*(abs(x+1)-abs(x-1))
dudt = [alpha*(y-x-f_x), x - y + z, -beta * y]
return dudt
# time discretization
t_0 = 0
dt = 1e-3
t_final = 300
t = np.arange(t_0, t_final, dt)
# initial conditions
u0 = [0.1,0,0]
# integrate ode system
sol = odeint(chua, u0, t)
# 3d-plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.plot(sol[:,0],sol[:,1],sol[:,2])
这给出了 3d 中预期的混乱行为:
这个在 xy 平面上的美好时光演变:
希望这有助于使用您自己的参数集解决您的问题。
推荐阅读
- java - 使用 ClassLoader 和 Maven Surefire 加载资源的单元测试
- sonarqube - SonarPLSQL-试用版
- javascript - 如何使用 CSS/Reactjs 禁用 YouTube 视频上的观看和分享按钮
- java - 我在哪里可以找到 Linux 服务器上的“java 二进制文件的完整路径”?
- javascript - 在 HTML Wordpress 上具有自定义背景 CSS 的图像幻灯片
- arrays - Swift 和 JSON 问题
- cookies - 如何在赛普拉斯测试中设置 cookie?
- vue.js - 是否可以从布局中的组件监听事件
- excel - 添加缺少的日期和缺少的项目 vba excel
- javascript - 无法连接到 Spotify Api:错误 URI 响应无效