@David88
2016-06-19T15:00:04.000000Z
字数 3793
阅读 802
This homework is to solve 3.8 problem of textbook exercises. In the absence of small angle approximation,study the law of real pendulum,assuming that the swing arm is a massless rigid rod, which will allow us to consider the swing of more than angle 90. Do not take the small angle approximation.In a certain length of pendulum and the acceleration of gravity, the cycle will be associated with the pendulum swing, and the swing is bigger, the cycle will be longer. This assignment will be numerical trajectories of different swing hem, and make the swing cycle diagram.
Swing (pendulum) in the ideal case, ignore the various friction, and assuming that the amplitude is very small, the motion of the pendulum can be seen as a simple harmonic motion (简谐运动). But the range discussed in this work, we do not assume that the swing is small, while allowing the swing of more than 90 degrees (assuming that the swing arm is not retractable light bar), pendulum motion equation can be expressed as:

In the angle swing,
g=gravity acceleration,
l=length of pendulum.
Conservation of energy in the absence of friction in the system, still pendulum motion, but not simple harmonic motion. In this model, the cycle will be associated with the pendulum swing. We assume that the pendulum is the initial velocity, then the initial position is the swing.
Using two order Runge-Kutta method,consider the nonlinear pendulum swing trajectory calculation , study the period and swing relationship.
The equation of motion of pendulum can be transformed into two first-order differential equations are as follows:

Using the two order Runge-Kutta method to calculate step by step . The method is as follows:
1 use the starting point of θ and ω to calculate the midpoint of ω;
2 use the midpoint of the ω and the starting point of θ to calculate the ending point of θ.
3 use the starting point of θ and ω to calculate the midpoint of θ;
4 use the midpoint of the θ and the starting point of ω to calculate the ending point of ω, thus completing a step calculation.
As for the study of period and amplitude relationship, we can use scanning method, 1 degree to calculate a path in each trace between 10 degrees to 170 degrees,recording three times before passing through the equilibrium position of the time.The first and the third time difference is the swing cycle, From here we can get the combination of swing and cycle.
Link code
The definition of pendulum,θ,ω and record time respectively with the three list. NextState method for calculating motion state in the next moments, including the two order Runge-Kutta method; F method for calculating the rate of change of angular velocity.
import pylab as plb
def a(x, k, alpha):
return - k * x ** alpha
def caculate(x0, v0, k, alpha, end_t, dt):
x = [x0]
v = [v0]
t = [0]
for i in range(int(end_t / dt)):
v.append(v[-1] + a(x[-1], k, alpha) * dt)
x.append(x[-1] + v[-1] * dt)
t.append(t[-1] + dt)
return x, t
def main():
x0 = 0.
v0 = 3.
k = 1
alpha = 1
end_t = 20
dt = 0.1
x, t = caculate(x0, v0, k, alpha, end_t, dt)
beta = 3
y, t = caculate(x0, v0, k, beta, end_t, dt)
plb.figure(figsize=(10,6),dpi=144)
plb.plot(t,x,'ob',linestyle='-',linewidth=1.0,color='b',label='alpha=1')
plb.plot(t,y,'ob',linestyle='-',linewidth=1.0,color='r',label='alpha=3')
plb.title('plot x vs t')
plb.xlabel=('t axis')
plb.ylabel=('x axis')
plb.legend(loc='upper right',fontsize=14)
plb.show()
Select several angles to calculate the trajectory and mapping cycle,calculate period for each corresponding angle.
theta=[]
period=[]
for i in np.linspace(10,170,161):
theta.append(i)
p=pendulum(i)
times=0
deltat=[0,0,0]
while p.t[-1]<100:
p.nextState()
if times<2.5:
if p.theta[-1]*p.theta[-2]<=0:
deltat[times]=(p.t[-1]+p.t[-2])/2
times=times+1
period.append(deltat[2]-deltat[0])
A swing of 30 degrees, 90 degrees and 170 degrees, make a motion picture at the end of the pendulum.
As we can see,the biggerhe of the swing, the bigger of the period.
+print period[0]
+print period[1]
+print period[2]
Swing between 30 to 90, every 1 degree calculate once time, record each cycle corresponding angle, make the cycle - swing curve.
As we can see,the swing cycle with the rise of period, and the rising rate is increasing.
Hanzhen Ma and Shixin Wang student.