@XF
2016-11-06T15:30:18.000000Z
字数 5883
阅读 111
本次作业主要是研究非线性单摆在加入阻尼和驱动力等因素下产生的混沌现象,并在相空间里对其分析与研究。
混沌理论:混沌理论(Chaos theory)是关于非线性系统在一定参数条件下展现分岔(bifurcation)、周期运动与非周期运动相互纠缠,以至于通向某种非周期有序运动的理论。在耗散系统和保守系统中,混沌运动有不同表现,前者有吸引子,后者无(也称含混吸引子)。
对于一个单摆,考虑阻尼和驱动力,并且其不再做小角度运动,由此我们可以得到:
import mathimport pylab as pl#初始化各个值,以及计算单摆的运功轨迹,展示结果曲线图像class pendulums_basis:def __init__(self, F_D = 1.2, total_time = 60, init_theta = 0.2, q = 0.5, l = 9.8, g = 9.8, Omega_D = 2/3, time_step = 0.04):self.omega = [0]self.theta = [init_theta]self.t = [0]self.dt = time_stepself.total_time = total_timeself.q = qself.l = lself.g = gself.Omega_D = Omega_Dself.F_D = F_Ddef calculate(self):i = 0loop_calculate = Truewhile(loop_calculate):self.omega.append(self.omega[i] + ((-self.g / self.l) * math.sin(self.theta[i]) - self.q * self.omega[i] + self.F_D * math.sin(self.Omega_D * self.t[i])) * self.dt)self.theta.append(self.theta[i] + self.omega[i + 1] * self.dt)self.t.append(self.t[i] + self.dt)if self.theta[i + 1] < -math.pi:self.theta[i + 1] = self.theta[i + 1] + 2 * math.piif self.theta[i + 1] > math.pi:self.theta[i + 1] = self.theta[i + 1] - 2 * math.pii += 1if self.t[i] > self.total_time:loop_calculate = Falsedef show_results(self):pl.plot(self.t, self.theta)pl.title("$\\theta$ versus $t$ $F_D=%.1f$"%self.F_D, fontsize=20)pl.xlabel('time(s)', fontsize=20)pl.ylabel('$\\theta$(radians)', fontsize=20)pl.show()#计算两个几乎相同的摆,只是初始的$\theta$有微小的差异,每个时间点对应的$\Delta t=|\theta_1-\theta_2|$与时间$t$的关系曲线class pendulums_comparison(pendulums_basis):def compare(self):pendulum_1 = pendulums_comparison(self.F_D, self.total_time, self.theta[0], 0.5)pendulum_1.calculate()pendulum_2 = pendulums_comparison(self.F_D, self.total_time, self.theta[0], 0.501)pendulum_2.calculate()dtheta = []loop_compare = Truei = 0while(loop_compare):dtheta.append(abs(pendulum_1.theta[i] - pendulum_2.theta[i]))i += 1if i == len(pendulum_1.t):loop_compare = Falsepl.semilogy(pendulum_1.t, dtheta)pl.title("$\\Delta\\theta$ versus $t$ $F_D=%.1f$"%self.F_D, fontsize=20)pl.xlabel('time(s)', fontsize=20)pl.ylabel('$\\Delta\\theta$(radians)', fontsize=20)pl.show()#展示$\omega$与$\theta$的关系曲线class omega_versus_theta(pendulums_basis):def show_results(self):pl.plot(self.theta, self.omega, '.',)pl.title("$\\omega$ versus $\\theta$ $F_D=%.1f$"%self.F_D, fontsize=20)pl.xlabel('$\\theta$(radians)', fontsize=20)pl.ylabel('$\\omega$(radians/s)', fontsize=20)pl.show()#展示在满足一定相位条件的$t$下$\omega$与$\theta$的关系曲线class poincare_section(pendulums_basis):def calculate(self):i = 0n = 1self.ps_omega = []self.ps_theta = []loop_calculate = Truewhile(loop_calculate):self.omega.append(self.omega[i] + ((-self.g / self.l) * math.sin(self.theta[i]) - self.q * self.omega[i] + self.F_D * math.sin(self.Omega_D * self.t[i])) * self.dt)self.theta.append(self.theta[i] + self.omega[i + 1] * self.dt)self.t.append(self.t[i] + self.dt)if self.theta[i + 1] < -math.pi:self.theta[i + 1] = self.theta[i + 1] + 2 * math.piif self.theta[i + 1] > math.pi:self.theta[i + 1] = self.theta[i + 1] - 2 * math.pi#$\Omega_Dt=2n\pi$if abs(self.t[i + 1] - 2 * n * math.pi / self.Omega_D) < self.dt / 2:self.ps_omega.append(self.omega[-1])self.ps_theta.append(self.theta[-1])n += 1# #$\Omega_Dt=n\pi-\pi/2$# if abs(self.t[i + 1] - (n * math.pi - 0.5 * math.pi) / self.Omega_D) < self.dt / 2:# self.ps_omega.append(self.omega[-1])# self.ps_theta.append(self.theta[-1])# n += 1# #$\Omega_Dt=2n\pi+\pi/4$# if abs(self.t[i + 1] - (2 * n * math.pi + math.pi / 4) / self.Omega_D) < self.dt / 2:# self.ps_omega.append(self.omega[-1])# self.ps_theta.append(self.theta[-1])# n += 1i += 1if self.t[i] > self.total_time:loop_calculate = Falsedef show_results(self):pl.plot(self.ps_theta, self.ps_omega, '.')pl.xlabel('$\\theta$(radians)', fontsize=20)pl.ylabel('$\\omega$(radians/s)', fontsize=20)pl.title('$\\omega$ versus $\\theta$ $F_D=1.2$', fontsize=20)pl.show()#按需求运行程序start_1 = pendulums_basis(0, 60)start_1.calculate()start_1.show_results()start_2 = pendulums_basis(0.5, 60)start_2.calculate()start_2.show_results()start_3 = pendulums_basis(1.2, 60)start_3.calculate()start_3.show_results()#start_comparison_1 = pendulums_comparison(0.5, 50)#start_comparison_1.compare()#start_comparison_2 = pendulums_comparison(1.2, 50)#start_comparison_2.compare()#start_ovt_1 = omega_versus_theta(0.5, 40)#start_ovt_1.calculate()#start_ovt_1.show_results()#start_ovt_2 = omega_versus_theta(1.2, 200)#start_ovt_2.calculate()#start_ovt_2.show_results()#start_ps = poincare_section(1.2, 7000)#start_ps.calculate()#start_ps.show_results()
versus ,=1.2,=2n
q=,l=g=9.8,,,,
versus ,=1.2,
q=,l=g=9.8,,,,
versus ,=1.2,
q=,l=g=9.8,,,,
versus t,=0.5
versus t,=1.2
versus t,=0.5
q_1=0.5, q_2=0.501, l=g=9.8, \Omega_D=2/3, dt=0.04, \theta(0)=0.2, \omega(0)=0
此处本应有图,显不出来(;°○° ) 我努力了
versus t,=1.2
q_1=0.5, q_2=0.501, l=g=9.8, \Omega_D=2/3, dt=0.04, \theta(0)=0.2, \omega(0)=0
此处本应有图,显不出来(ง •̀_•́)ง 还是要加强知识水平。唉!
3.12:
得到的图像与预期的结果相符。
3.13:
图像可知在时系统运动是有规则的且收敛,曲线的渐近线很好的符合指数规律,指数<0. 但是当时情况发生了改变,一开始还是稳定的但是之后就变得无规则不可预测,进入了混沌状态,曲线渐近线近似符合指数规律,指数>0。
3.14:
由图可知,单摆的差异为,当时,系统最终稳定在一个常数系统的Lyapunov指数不再存在,当时曲线近似符合指数规律,指数>0,系统仍然是混乱的。
感谢张盛同学的细心教导还有张然带我了解liunx,还有蔡浩老师的指导。