diff --git a/examples/animation/double_pendulum_sgskip.py b/examples/animation/double_pendulum_sgskip.py index 3d4bf0c618ca..6ddf8eaf3e64 100644 --- a/examples/animation/double_pendulum_sgskip.py +++ b/examples/animation/double_pendulum_sgskip.py @@ -27,26 +27,28 @@ def derivs(state, t): dydx = np.zeros_like(state) dydx[0] = state[1] - del_ = state[2] - state[0] - den1 = (M1 + M2)*L1 - M2*L1*cos(del_)*cos(del_) - dydx[1] = (M2*L1*state[1]*state[1]*sin(del_)*cos(del_) + - M2*G*sin(state[2])*cos(del_) + - M2*L2*state[3]*state[3]*sin(del_) - - (M1 + M2)*G*sin(state[0]))/den1 + delta = state[2] - state[0] + den1 = (M1+M2) * L1 - M2 * L1 * cos(delta) * cos(delta) + dydx[1] = ((M2 * L1 * state[1] * state[1] * sin(delta) * cos(delta) + + M2 * G * sin(state[2]) * cos(delta) + + M2 * L2 * state[3] * state[3] * sin(delta) + - (M1+M2) * G * sin(state[0])) + / den1) dydx[2] = state[3] - den2 = (L2/L1)*den1 - dydx[3] = (-M2*L2*state[3]*state[3]*sin(del_)*cos(del_) + - (M1 + M2)*G*sin(state[0])*cos(del_) - - (M1 + M2)*L1*state[1]*state[1]*sin(del_) - - (M1 + M2)*G*sin(state[2]))/den2 + den2 = (L2/L1) * den1 + dydx[3] = ((- M2 * L2 * state[3] * state[3] * sin(delta) * cos(delta) + + (M1+M2) * G * sin(state[0]) * cos(delta) + - (M1+M2) * L1 * state[1] * state[1] * sin(delta) + - (M1+M2) * G * sin(state[2])) + / den2) return dydx # create a time array from 0..100 sampled at 0.05 second steps dt = 0.05 -t = np.arange(0.0, 20, dt) +t = np.arange(0, 20, dt) # th1 and th2 are the initial angles (degrees) # w10 and w20 are the initial angular velocities (degrees per second) @@ -91,7 +93,7 @@ def animate(i): time_text.set_text(time_template % (i*dt)) return line, time_text -ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)), - interval=25, blit=True, init_func=init) +ani = animation.FuncAnimation(fig, animate, range(1, len(y)), + interval=25, blit=True, init_func=init) plt.show()