This simulation shows two springs and masses connected to a wall. The graphs produced 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.
The math behind the simulation is shown below. Also available: source code, documentation and how to customize.
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 - spring_{1} - block_{1} - spring_{2} - block_{2}
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):
And define the following constants:
The springs exert force based on their amount of stretch according to
F = −k × stretch
The forces on the blocks are therefore
F_{1} = −k_{1} L_{1} + k_{2} L_{2}
F_{2} = −k_{2} L_{2}
The stretch of the spring is calculated based on the position of the blocks.
L_{1} = x_{1} − R_{1}
L_{2} = x_{2} − x_{1} − w_{1} − R_{2}
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.
m_{1} x_{1}'' = −k_{1} (x_{1} − R_{1}) +
k_{2} (x_{2} − x_{1} − w_{1} − R_{2})
m_{2} x_{2}'' = −k_{2} (x_{2} − x_{1} − w_{1} − R_{2})
It is easy to convert the above second order equations to a set of first order equations. We define variables for the velocities v_{1}, v_{2} . Then there are four variables x_{1}, x_{2}, v_{1}, v_{2} and a first-order differential equation for each:
x_{1}' = v_{1}
x_{2}' = v_{2}
v_{1}' = −(k_{1} ⁄ m_{1}) (x_{1} − R_{1}) +
(k_{2} ⁄ m_{1}) (x_{2} − x_{1} − w_{1} − R_{2})
v_{2}' = −(k_{2} ⁄ m_{2}) (x_{2} − x_{1} − w_{1} − R_{2})
This is the form that we need in order to use the Runge-Kutta method for numerically solving the differential equation.
This web page was first published April 2001.