[关闭]
@XF 2016-11-06T15:30:18.000000Z 字数 5883 阅读 111

第七次作业

1.摘要

本次作业主要是研究非线性单摆在加入阻尼和驱动力等因素下产生的混沌现象,并在相空间里对其分析与研究。

2.背景

混沌理论:混沌理论(Chaos theory)是关于非线性系统在一定参数条件下展现分岔(bifurcation)、周期运动与非周期运动相互纠缠,以至于通向某种非周期有序运动的理论。在耗散系统和保守系统中,混沌运动有不同表现,前者有吸引子,后者无(也称含混吸引子)。
对于一个单摆,考虑阻尼和驱动力,并且其不再做小角度运动,由此我们可以得到:


我们可以将上式花间为一阶常微分方程:


我们用Euler-Cromer method进行计算:


并且如果在【】之外,则需加上或减去2

3.正文

  1. import math
  2. import pylab as pl
  3. #初始化各个值,以及计算单摆的运功轨迹,展示结果曲线图像
  4. class pendulums_basis:
  5. 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):
  6. self.omega = [0]
  7. self.theta = [init_theta]
  8. self.t = [0]
  9. self.dt = time_step
  10. self.total_time = total_time
  11. self.q = q
  12. self.l = l
  13. self.g = g
  14. self.Omega_D = Omega_D
  15. self.F_D = F_D
  16. def calculate(self):
  17. i = 0
  18. loop_calculate = True
  19. while(loop_calculate):
  20. 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)
  21. self.theta.append(self.theta[i] + self.omega[i + 1] * self.dt)
  22. self.t.append(self.t[i] + self.dt)
  23. if self.theta[i + 1] < -math.pi:
  24. self.theta[i + 1] = self.theta[i + 1] + 2 * math.pi
  25. if self.theta[i + 1] > math.pi:
  26. self.theta[i + 1] = self.theta[i + 1] - 2 * math.pi
  27. i += 1
  28. if self.t[i] > self.total_time:
  29. loop_calculate = False
  30. def show_results(self):
  31. pl.plot(self.t, self.theta)
  32. pl.title("$\\theta$ versus $t$ $F_D=%.1f$"%self.F_D, fontsize=20)
  33. pl.xlabel('time(s)', fontsize=20)
  34. pl.ylabel('$\\theta$(radians)', fontsize=20)
  35. pl.show()
  36. #计算两个几乎相同的摆,只是初始的$\theta$有微小的差异,每个时间点对应的$\Delta t=|\theta_1-\theta_2|$与时间$t$的关系曲线
  37. class pendulums_comparison(pendulums_basis):
  38. def compare(self):
  39. pendulum_1 = pendulums_comparison(self.F_D, self.total_time, self.theta[0], 0.5)
  40. pendulum_1.calculate()
  41. pendulum_2 = pendulums_comparison(self.F_D, self.total_time, self.theta[0], 0.501)
  42. pendulum_2.calculate()
  43. dtheta = []
  44. loop_compare = True
  45. i = 0
  46. while(loop_compare):
  47. dtheta.append(abs(pendulum_1.theta[i] - pendulum_2.theta[i]))
  48. i += 1
  49. if i == len(pendulum_1.t):
  50. loop_compare = False
  51. pl.semilogy(pendulum_1.t, dtheta)
  52. pl.title("$\\Delta\\theta$ versus $t$ $F_D=%.1f$"%self.F_D, fontsize=20)
  53. pl.xlabel('time(s)', fontsize=20)
  54. pl.ylabel('$\\Delta\\theta$(radians)', fontsize=20)
  55. pl.show()
  56. #展示$\omega$与$\theta$的关系曲线
  57. class omega_versus_theta(pendulums_basis):
  58. def show_results(self):
  59. pl.plot(self.theta, self.omega, '.',)
  60. pl.title("$\\omega$ versus $\\theta$ $F_D=%.1f$"%self.F_D, fontsize=20)
  61. pl.xlabel('$\\theta$(radians)', fontsize=20)
  62. pl.ylabel('$\\omega$(radians/s)', fontsize=20)
  63. pl.show()
  64. #展示在满足一定相位条件的$t$下$\omega$与$\theta$的关系曲线
  65. class poincare_section(pendulums_basis):
  66. def calculate(self):
  67. i = 0
  68. n = 1
  69. self.ps_omega = []
  70. self.ps_theta = []
  71. loop_calculate = True
  72. while(loop_calculate):
  73. 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)
  74. self.theta.append(self.theta[i] + self.omega[i + 1] * self.dt)
  75. self.t.append(self.t[i] + self.dt)
  76. if self.theta[i + 1] < -math.pi:
  77. self.theta[i + 1] = self.theta[i + 1] + 2 * math.pi
  78. if self.theta[i + 1] > math.pi:
  79. self.theta[i + 1] = self.theta[i + 1] - 2 * math.pi
  80. #$\Omega_Dt=2n\pi$
  81. if abs(self.t[i + 1] - 2 * n * math.pi / self.Omega_D) < self.dt / 2:
  82. self.ps_omega.append(self.omega[-1])
  83. self.ps_theta.append(self.theta[-1])
  84. n += 1
  85. # #$\Omega_Dt=n\pi-\pi/2$
  86. # if abs(self.t[i + 1] - (n * math.pi - 0.5 * math.pi) / self.Omega_D) < self.dt / 2:
  87. # self.ps_omega.append(self.omega[-1])
  88. # self.ps_theta.append(self.theta[-1])
  89. # n += 1
  90. # #$\Omega_Dt=2n\pi+\pi/4$
  91. # if abs(self.t[i + 1] - (2 * n * math.pi + math.pi / 4) / self.Omega_D) < self.dt / 2:
  92. # self.ps_omega.append(self.omega[-1])
  93. # self.ps_theta.append(self.theta[-1])
  94. # n += 1
  95. i += 1
  96. if self.t[i] > self.total_time:
  97. loop_calculate = False
  98. def show_results(self):
  99. pl.plot(self.ps_theta, self.ps_omega, '.')
  100. pl.xlabel('$\\theta$(radians)', fontsize=20)
  101. pl.ylabel('$\\omega$(radians/s)', fontsize=20)
  102. pl.title('$\\omega$ versus $\\theta$ $F_D=1.2$', fontsize=20)
  103. pl.show()
  104. #按需求运行程序
  105. start_1 = pendulums_basis(0, 60)
  106. start_1.calculate()
  107. start_1.show_results()
  108. start_2 = pendulums_basis(0.5, 60)
  109. start_2.calculate()
  110. start_2.show_results()
  111. start_3 = pendulums_basis(1.2, 60)
  112. start_3.calculate()
  113. start_3.show_results()
  114. #start_comparison_1 = pendulums_comparison(0.5, 50)
  115. #start_comparison_1.compare()
  116. #start_comparison_2 = pendulums_comparison(1.2, 50)
  117. #start_comparison_2.compare()
  118. #start_ovt_1 = omega_versus_theta(0.5, 40)
  119. #start_ovt_1.calculate()
  120. #start_ovt_1.show_results()
  121. #start_ovt_2 = omega_versus_theta(1.2, 200)
  122. #start_ovt_2.calculate()
  123. #start_ovt_2.show_results()
  124. #start_ps = poincare_section(1.2, 7000)
  125. #start_ps.calculate()
  126. #start_ps.show_results()

3.12:

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,,,,

3.13:

versus t,=0.5


versus t,=1.2


此处本应有图,显不出来┌( ಠ_ಠ)┘宝宝好方

3.14

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

此处本应有图,显不出来(ง •̀_•́)ง 还是要加强知识水平。唉!

4.结论

3.12:
得到的图像与预期的结果相符。
3.13:
图像可知在时系统运动是有规则的且收敛,曲线的渐近线很好的符合指数规律,指数<0. 但是当时情况发生了改变,一开始还是稳定的但是之后就变得无规则不可预测,进入了混沌状态,曲线渐近线近似符合指数规律,指数>0。
3.14:
由图可知,单摆的差异为,当时,系统最终稳定在一个常数系统的Lyapunov指数不再存在,当时曲线近似符合指数规律,指数>0,系统仍然是混乱的。

5.致谢

感谢张盛同学的细心教导还有张然带我了解liunx,还有蔡浩老师的指导。


添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注