[关闭]
@LiuYongJie 2016-11-13T09:51:16.000000Z 字数 7046 阅读 247

Ex_08 - chaos in the nonlinear, damped, driven pendulum(ex3.18/21)


Question

Investigate the bifurcation diagrams found for the pendulum with other values of the drive frequency and damping parameter. Warning: this can easily become an ambitious project!
实际就是观察改变相应的外力频率和阻尼系数后bifurcation图会有什么变化,包括了3.18中的三个不同力的大小引起的变化。

Theory and results

Now that we have a numerical method that is suitable for various of the simple pendulum, and armed with some understanding of what might or might not happen when dissipation, an external force, and/or nonlinearity is present, we are ready to take on a slightly more complicated and also more interesting situation. that is, we add all three ingredients which were previously discussed separately. Put all these ingredients together, we have the equation of motion

we call this model for a nonlinear, dapmped, driven pendulum, the physical pendulum. It contains some very rich and interesting behaviors. However, as the equation can not be solved analytically, we have to turn to a numerical method. Under that case, the relevent differentlial equations are



given properiate initial value, we can easily simulate the process. Here, we have shown several pictures of interest.

code

接下来我选择重力加速度和摆长均为9.8,阻尼系数为0.5,外力频率为2/3,2/3+0.0001,2/3+0.0002,时间间隔为0.04.,制摆的角度与时间的关系图。

  1. from __future__ import division
  2. from math import *
  3. from pylab import *
  4. from numpy import *
  5. # define a function that given amplitude of force, gives angle,avelo and t
  6. def change_amp(F,f):
  7. # define some constants
  8. q = 0.5
  9. l = 9.8
  10. g = 9.8
  11. dt = pi/100
  12. theta0 = 0.2
  13. omega0 = 0
  14. angle = [theta0]
  15. avelo = [omega0]
  16. t = [0]
  17. an=[]
  18. # move the pendulum
  19. while t[-1] <= 1200*pi:
  20. avelo_new = avelo[-1] - ((g/l)*sin(angle[-1]) + q*avelo[-1] - F*sin(f*t[-1]))*dt
  21. avelo.append(avelo_new)
  22. angle_new = angle[-1] + avelo[-1]*dt
  23. while angle_new > pi:
  24. angle_new -= 2*pi
  25. while angle_new < -pi:
  26. angle_new += 2*pi
  27. angle.append(angle_new)
  28. if t[-1]>=900*pi:
  29. if t[-1]%(3*pi)<=dt:
  30. an.append(angle_new)
  31. t_new = t[-1] + dt
  32. t.append(t_new)
  33. return an
  34. ###
  35. fdd_1=list(linspace(1.35,1.5,100))
  36. fd_1=[]
  37. th_1=[]
  38. for i in fdd_1:
  39. points=change_amp(i,2/3)
  40. for j in points:
  41. fd_1.append(i)
  42. th_1.append(j)
  43. ###
  44. fdd_2=list(linspace(1.35,1.5,100))
  45. fd_2=[]
  46. th_2=[]
  47. for i in fdd_2:
  48. points=change_amp(i,2/3+0.00001)
  49. for j in points:
  50. fd_2.append(i)
  51. th_2.append(j)
  52. ###
  53. fdd_3=list(linspace(1.35,1.5,100))
  54. fd_3=[]
  55. th_3=[]
  56. for i in fdd_3:
  57. points=change_amp(i,2/3+0.00002)
  58. for j in points:
  59. fd_3.append(i)
  60. th_3.append(j)
  61. ###
  62. subplot(1,3,1)
  63. scatter(fd_1,th_1,s=10)
  64. grid(True)
  65. xlim(1.35,1.48)
  66. ylim(0,3)
  67. title('f=2/3')
  68. xlabel('FD')
  69. ylabel('theta(radians)')
  70. subplot(1,3,2)
  71. scatter(fd_2,th_2,s=10)
  72. grid(True)
  73. xlim(1.35,1.48)
  74. ylim(0,3)
  75. title('f=(2/3)+0.00001')
  76. xlabel('FD')
  77. ylabel('theta(radians)')
  78. subplot(1,3,3)
  79. scatter(fd_3,th_3,s=10)
  80. grid(True)
  81. xlim(1.35,1.48)
  82. ylim(0,3)
  83. title('f=(2/3)+0.00002')
  84. xlabel('FD')
  85. ylabel('theta(radians)')
  86. show()

●当f增加时,图像的结构没有发生变化,只是图形整体下移,且上面的点有所增加。
此处输入图片的描述
Clink to cheek the reasult

  1. from __future__ import division
  2. from math import *
  3. from pylab import *
  4. from numpy import *
  5. # define a function that given amplitude of force, gives angle,avelo and t
  6. def change_amp(F,q):
  7. # define some constants
  8. l = 9.8
  9. g = 9.8
  10. dt = pi/100
  11. f=2/3
  12. theta0 = 0.2
  13. omega0 = 0
  14. angle = [theta0]
  15. avelo = [omega0]
  16. t = [0]
  17. an=[]
  18. # move the pendulum
  19. while t[-1] <= 1200*pi:
  20. avelo_new = avelo[-1] - ((g/l)*sin(angle[-1]) + q*avelo[-1] - F*sin(f*t[-1]))*dt
  21. avelo.append(avelo_new)
  22. angle_new = angle[-1] + avelo[-1]*dt
  23. while angle_new > pi:
  24. angle_new -= 2*pi
  25. while angle_new < -pi:
  26. angle_new += 2*pi
  27. angle.append(angle_new)
  28. if t[-1]>=900*pi:
  29. if t[-1]%(3*pi)<=dt:
  30. an.append(angle_new)
  31. t_new = t[-1] + dt
  32. t.append(t_new)
  33. return an
  34. ###
  35. fdd_1=list(linspace(1.35,1.5,100))
  36. fd_1=[]
  37. th_1=[]
  38. for i in fdd_1:
  39. points=change_amp(i,0.5)
  40. for j in points:
  41. fd_1.append(i)
  42. th_1.append(j)
  43. ###
  44. fdd_2=list(linspace(1.35,1.5,100))
  45. fd_2=[]
  46. th_2=[]
  47. for i in fdd_2:
  48. points=change_amp(i,0.51)
  49. for j in points:
  50. fd_2.append(i)
  51. th_2.append(j)
  52. ###
  53. fdd_3=list(linspace(1.35,1.5,100))
  54. fd_3=[]
  55. th_3=[]
  56. for i in fdd_3:
  57. points=change_amp(i,0.52)
  58. for j in points:
  59. fd_3.append(i)
  60. th_3.append(j)
  61. ###
  62. subplot(1,3,1)
  63. scatter(fd_1,th_1,s=10)
  64. grid(True)
  65. xlim(1.35,1.48)
  66. ylim(0,3)
  67. title('q=0.5')
  68. xlabel('FD')
  69. ylabel('theta(radians)')
  70. subplot(1,3,2)
  71. scatter(fd_2,th_2,s=10)
  72. grid(True)
  73. xlim(1.35,1.48)
  74. ylim(0,3)
  75. title('q=0.51')
  76. xlabel('FD')
  77. ylabel('theta(radians)')
  78. subplot(1,3,3)
  79. scatter(fd_3,th_3,s=10)
  80. grid(True)
  81. xlim(1.35,1.48)
  82. ylim(0,3)
  83. title('q=0.52')
  84. xlabel('FD')
  85. ylabel('theta(radians)')
  86. show()

此处输入图片的描述
●其次改变阻尼系数,令q=0.5,0.51,0.52,结果如图。由图可知,当阻尼系数有微小的变化时,图像整体右移,亦即推迟了混沌现象的出现,如果持续增大阻尼系数,混沌现象会随之消失,回归到周期运动。

Clink to cheek the reasult
3.18题中改变力的大小,分别为1.4,1.44,1.465,用VPython可观察入下

  1. from __future__ import division
  2. from visual import *
  3. from math import *
  4. # add some constants
  5. q=0.5
  6. l=9.8
  7. g=9.8
  8. f=2.0/3
  9. dt=0.04
  10. theta0=0.2
  11. omega0=0
  12. # add three ceilings
  13. ceil1=box(pos=(-20,5,0),size=(5,0.5,2),material=materials.bricks)
  14. ceil2=box(pos=(0,5,0),size=(5,0.5,2),material=materials.bricks)
  15. ceil3=box(pos=(20,5,0),size=(5,0.5,2),material=materials.bricks)
  16. ball1=sphere(pos=(-20+l*sin(theta0),5-l*cos(theta0),0),radius=1,material=materials.emissive,color=color.red)
  17. ball2=sphere(pos=(l*sin(theta0),5-l*cos(theta0),0),radius=1,material=materials.emissive,color=color.yellow)
  18. ball3=sphere(pos=(20+l*sin(theta0),5-l*cos(theta0),0),radius=1,material=materials.emissive,color=color.green)
  19. ball1.omega=omega0
  20. ball2.omega=omega0
  21. ball3.omega=omega0
  22. ball1.theta=theta0
  23. ball2.theta=theta0
  24. ball3.theta=theta0
  25. ball1.t=0
  26. ball2.t=0
  27. ball3.t=0
  28. ball1.F=1.4
  29. ball2.F=1.44
  30. ball3.F=1.465
  31. string1=curve(pos=[ceil1.pos,ball1.pos],color=color.red)
  32. string2=curve(pos=[ceil2.pos,ball2.pos],color=color.yellow)
  33. string3=curve(pos=[ceil3.pos,ball3.pos],color=color.green)
  34. po1=arrow(pos=ball1.pos,axis=(10*ball1.omega*cos(ball1.theta),10*ball1.omega*sin(ball1.theta),0),color=color.red)
  35. po2=arrow(pos=ball2.pos,axis=(10*ball2.omega*cos(ball2.theta),10*ball2.omega*sin(ball2.theta),0),color=color.yellow)
  36. po3=arrow(pos=ball3.pos,axis=(10*ball3.omega*cos(ball3.theta),10*ball3.omega*sin(ball3.theta),0),color=color.green)
  37. while True:
  38. rate(100)
  39. ball1.omega=ball1.omega-((g/l)*sin(ball1.theta)+q*ball1.omega-ball1.F*sin(f*ball1.t))*dt
  40. ball2.omega=ball2.omega-((g/l)*sin(ball2.theta)+q*ball2.omega-ball2.F*sin(f*ball2.t))*dt
  41. ball3.omega=ball3.omega-((g/l)*sin(ball3.theta)+q*ball3.omega-ball3.F*sin(f*ball3.t))*dt
  42. angle1_new=ball1.theta+ball1.omega*dt
  43. while angle1_new>pi:
  44. angle1_new-=2*pi
  45. while angle1_new<-pi:
  46. angle1_new+=2*pi
  47. angle2_new=ball2.theta+ball2.omega*dt
  48. while angle2_new>pi:
  49. angle2_new-=2*pi
  50. while angle2_new<-pi:
  51. angle2_new+=2*pi
  52. angle3_new=ball3.theta+ball3.omega*dt
  53. while angle3_new>pi:
  54. angle3_new-=2*pi
  55. while angle3_new<-pi:
  56. angle3_new+=2*pi
  57. ball1.theta=angle1_new
  58. ball2.theta=angle2_new
  59. ball3.theta=angle3_new
  60. ball1.pos=(-20+l*sin(ball1.theta),5-l*cos(ball1.theta),0)
  61. ball2.pos=(l*sin(ball2.theta),5-l*cos(ball2.theta),0)
  62. ball3.pos=(20+l*sin(ball3.theta),5-l*cos(ball3.theta),0)
  63. string1.pos=[ceil1.pos,ball1.pos]
  64. string2.pos=[ceil2.pos,ball2.pos]
  65. string3.pos=[ceil3.pos,ball3.pos]
  66. po1.pos=ball1.pos
  67. po2.pos=ball2.pos
  68. po3.pos=ball3.pos
  69. po1.axis=(10*ball1.omega*cos(ball1.theta),10*ball1.omega*sin(ball1.theta),0)
  70. po2.axis=(10*ball2.omega*cos(ball2.theta),10*ball2.omega*sin(ball2.theta),0)
  71. po3.axis=(10*ball3.omega*cos(ball3.theta),10*ball3.omega*sin(ball3.theta),0)
  72. ball1.t=ball1.t+dt
  73. ball2.t=ball2.t+dt
  74. ball3.t=ball3.t+dt

3.18结果如图

Conclusion

利用python来解决混沌问题是一个很好的选择,也对混沌有了更深刻的理解,发现步长以及初始条件对混沌有着很大的影响。同时经过分析Bifurcation diagram,知道了更多的知识,也进一步对python有了更深刻的理解。
利用VPython可以更直观的观察混沌摆的现象,更直接的研究其他因素的影响。但是3.21题改变阻尼系数和频率还不是很会做vpython展示,之后再做补充。

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