[关闭]
@74849b 2016-10-30T06:58:36.000000Z 字数 5951 阅读 605

exercise 07


problem 3.13

背景

One example of a simple pendulum is a particle of mass connected by a massless string to a rigid support. is the angle that the string makes with the verticle.Given the force that the particle beard,the force perpendicular to the string is given by

where is the acceleration due to gravity.In terms of Newton's second law:,we assume is always small at the same time,we can obtain the equation of motion
It has the general solution
where ,and and are constants that depend on the initial displacement and velocity of the pendulum.
The previous equation describes a frictionless pendulum,we should add some damping.In many cases,this damping force is proportional to the velocity.The equation of motion for our damped pendulum has the form
.Here is a parameter that measures the strength of the damping.There are three regimes of distinct physical behaviour.The first regime,called underdamped,occurs for small friction,where the solution
At the other extreme,when the damping is large,the behaviour is overdamped,here the solution is
At the boundary between the underdamped and overdamped regimes,the pendulum is critically damped with

Besides the friction,we therefore consider the addition of a driving force to the problem.A convenient choice is to assume that the driving force is sinusoidal with time,with amplitude and angular frequency .This leads to the equation of motion
This driving force will pump energy into (or out of) the system.
However,we should have a mumerical method that is suitable for various versions of the pendulum problem.We don't assume the small-angle approximation.Putting all of these ingredients together,we obtain the following equation:
We can rewrite it as two first-order differential equations and obtain

Problem 3.13 need consider the stabilityof the solutions to our problems.We have two identical pendulums with exactly the same lengths and damping factors.The only difference is that we start them with slightly differentinitial angles.Observe the behaviour of the angular positions of two pendulums, and ,and the divergence .For different values of ,the trend of the plots vary.This line corresponds to the relation ,which implies
The parameter is known as a Lyapunov exponent.The behaviour of can be described by a Lyapunov exponent in both the chaotic and nonchaotic regimes.In the former case ,while in the latter,.The transition to chaos thus occurs when .

正文

Code as follows:

  1. import matplotlib.pyplot as plt
  2. import math
  3. class pendulum_1:
  4. def __init__(self,time_step=0,theta1=0,theta2=0,time_of_duration=0,fd=0.5,q=0.5):
  5. self.theta1=[theta1]
  6. self.theta2=[theta2]
  7. self.dt=time_step
  8. self.fd=fd
  9. self.q=q
  10. self.t=[0]
  11. self.w1=[0]
  12. self.w2=[0]
  13. self.nsteps=int(time_of_duration//time_step+1)
  14. def calculate(self):
  15. self.v=[]
  16. wd=float(2.0/3)
  17. for i in range(self.nsteps):
  18. self.w1.append(self.w1[i]+(-math.sin(self.theta1[i])-self.q*self.w1[i]+self.fd*math.sin(wd*self.t[i]))*self.dt)
  19. self.theta1.append(self.theta1[i]+self.w1[i+1]*self.dt)
  20. self.w2.append(self.w2[i]+(-math.sin(self.theta2[i])-self.q*self.w2[i]+self.fd*math.sin(wd*self.t[i]))*self.dt)
  21. self.theta2.append(self.theta2[i]+self.w2[i+1]*self.dt)
  22. self.t.append(self.t[i]+self.dt)
  23. self.v=list(map(lambda x:abs(x[0]-x[1]),zip(self.theta1,self.theta2)))
  24. if self.theta1[i+1]<-math.pi:
  25. self.theta1[i+1]=self.theta1[i+1]+2*math.pi
  26. if self.theta1[i+1]>math.pi:
  27. self.theta1[i+1]=self.theta1[i+1]-2*math.pi
  28. if self.theta2[i+1]<-math.pi:
  29. self.theta2[i+1]=self.theta2[i+1]+2*math.pi
  30. if self.theta2[i+1]>math.pi:
  31. self.theta2[i+1]=self.theta2[i+1]-2*math.pi
  32. return 0
  33. def show_calculate(self,color):
  34. plt.plot(self.t,self.v,color,label="fd=%r"%(self.fd))
  35. plt.title('difference of theta versus time fd=0.5')
  36. plt.xlabel('time/s')
  37. plt.ylabel('difference of theta/radians')
  38. plt.ylim(0,0.001)
  39. a=pendulum_1(0.04,0.200,0.199,60,0,0.5)
  40. a.calculate()
  41. a.show_results('red')
  42. plt.legend()
  43. plt.show()
  44. a=pendulum_1(0.04,0.200,0.199,60,0.5,0.5)
  45. a.calculate()
  46. a.show_results('red')
  47. plt.legend()
  48. plt.show()
  49. a=pendulum_1(0.04,0.200,0.199,60,1.2,0.5)
  50. a.calculate()
  51. a.show_results('red')
  52. plt.legend()
  53. plt.show()

First,draw three plots that behaviours of vary as a function of time for our driven for several different values of the driving force:
此处输入图片的描述
At low drrive,the motion is a simple oscillation.On the other hand,at high drive the motion is chaotic.The behaviour can be both deterministic and unpredictable at the same time.
Next,we consider the behaviour of two,nearly identicle pendulums.The results are as followings:
此处输入图片的描述
此处输入图片的描述
此处输入图片的描述
But the y axis'saccuracy isn't enough,the plot can't describe the quality of Lyapunov exponent.I modify the code,and calculate as a function of ,so we can obtain the following explicit results:
此处输入图片的描述
此处输入图片的描述
The first figure is plotted in ,we can easy to conclude is proportional to ,and ,which represents nonchaotic regimes.This means that the motion of the two pendulums becomes more and more similar,since the difference in the two angles approaches zero as the motion proceeds.
The second figure represents chaotic regimes with and .This is usually described by saying that the two trajectories, and ,diverge from one another.This system can obey certain deterministic laws of physics,but still exhibit behaviour that is unpredictable due to an extreme sensititvty to initial conditions.This's the nature of chaotic.
For ,we calculate the .Pick up two points from the turning point,such as:(0,-6.78) and (53.7,-20.35),we can obtain the slope:


We can gain the finally equation:

The second plot is difficulty to find two points,I don't calculate .

致谢

Thanks for the following code(from baidu):

  1. v=list(map(lambda x:x[0]-x[1],zip(v2-v1))
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注