ANN: Simple Pendulum Simulation

Jim Hurley jhurley at infostations.com
Mon Oct 31 20:24:29 EST 2005


>
>Thanks, Jim.  I do indeed have this inclination.  In fact my original 
>intent was to use the simple pendulum to learn and apply the Runge-
>Kutta Method.  I just haven't gotten around to it yet.  Might your 
>suggestion be a variation of this?
>
>Cheers, Roger
>


Roger,

Actually I was thinking of something even simpler than the 
Runge-Kutta approximation.

Using the Euler approximation, the repeat loop to generate the 
pendulum motion is really simple and looks like this:

repeat until the mouseClick
     setRA r,270+psi -- Polar coordinates; 270 so that the pendulum hands DOWN
     add -c*psi to angVel --Add angular acceleration to the angular velocity
     add angVel to psi --Add angular velocity to the angle
end repeat

where psi is the angular displacement of the pendulum.

I am using Turtle Graphics, but I think you get the idea. To see this 
in action, put this in the message box:

go stack url "http://home.infostations.net/jhurley/ControlGraphics.rev"

and go to the last card.

Control graphics is a variation on TG. It allows you to identify any 
control as a Turtle which not only responds to Transcript, but also 
to TG. So you can create a circle graphic and call it "pendulum" and 
then talk to the circle like it was a turtle, i.e. forward 10, right 
90, setXY 20,30, setRA 200,35 etc.

Polar coordinates are particularly  useful in the pendulum problem

I tried to show the dependence of the period on the amplitude but no 
luck so far. Maybe Runga-Kutta is required.

The period depends on the amplitude (to second order in the 
amplitude) in this way:

T = T(0) (1 + A^2/16)

where A is the angular amplitude in radians.

Jim


More information about the use-livecode mailing list