myphysicslab – double spring
this simulation shows two springs and masses connected to a wall. if you've ever played with an oscilloscope you've probably seen curves like these. they are called lissajous curves
and are generated by simple sine and cosine functions.
you can change parameters in the simulation such as mass or spring stiffness. you can drag either mass with your mouse to set the starting position. if you don't see the simulation try instructions for enabling java. scroll down to see the math!
instructions: click near to a square and drag with your mouse
physics and equations of motion
the two springs act independently, so it is easy to figure out what are the forces acting on the two blocks. label the springs and blocks as follows:
wall - spring1 - block1 - spring2 - block2
we'll assume the origin is at the connection of the spring to the wall. define the following variables (subscripts refer to block 1 or block 2):
- x1, x2 = position (left edge) of blocks
- v1, v2 = velocity of blocks
- f1, f2 = force experienced by blocks
- l1, l2 = how much spring is stretched
and define the following constants:
- m1, m2 = mass of blocks
- w1, w2 = width of blocks
- k1, k2 = spring constants
- r1, r2 = rest length of springs
the springs exert force based on their amount of stretch according to
f = −k × stretch
the forces on the blocks are therefore
f1 = −k1 l1 + k2 l2
f2 = −k2 l2
the stretch of the spring is calculated based on the position of the blocks.
l1 = x1 − r1
l2 = x2 − x1 − w1 − r2
now using newton's law f = m a
and the definition of acceleration as a = x''
we can write two second order
differential equations. these are the equations of motion for the double spring.
m1 x1'' = −k1 (x1 − r1) +
k2 (x2 − x1 − w1 − r2)
m2 x2'' = −k2 (x2 − x1 − w1 − r2)
it's easy to convert the above second order equations to a set of first order equations. we define variables for the velocities v1, v2
. then there are four variables x1, x2, v1, v2
and a first-order differential equation for each:
x1' = v1
x2' = v2
v1' = −(k1 ⁄ m1) (x1 − r1) +
(k2 ⁄ m1) (x2 − x1 − w1 − r2)
v2' = −(k2 ⁄ m2) (x2 − x1 − w1 − r2)
this is the form that we need in order to use the runge-kutta method
for numerically solving
the differential equation.