# myphysicslab – double spring 2d

this simulation shows a two masses connected by springs and suspended from the ceiling. the masses are able to move in 2 dimensions, and gravity operates.
you can drag either mass with your mouse. you can also drag the top anchor point. click the "reset" button to put the masses in a resting equilibrium. you can change parameters such as gravity, mass, spring stiffness, and friction (damping). if you don't see the simulation try instructions for enabling java. scroll down to see the math!

## physics

an immoveable (but draggable) anchor point has two spring2 and bobs hanging below and swinging in two dimensions. we regard the bobs as point masses. we label the upper spring and bob as number 1, the lower spring and bob as number 2.

double spring variables
define the following variables:
• θ = angle (0=vertical)
• s = spring stretch (displacement from rest length)
• l = length of spring
• u = position of bob
• v = u'= velocity of bob
• a = u''= acceleration of bob
• f = net force on a bob
define some constants:
• r = rest length of spring
• t = position of anchor point
• m = mass of bob
• k = spring constant
• b = damping constant
• g = gravitational constant
note that for this simulation the vertical dimension increases downwards.

here are the equations of motion. the derivation is similar to that given for the single 2d spring. f1x = m1 a1x = −k1 s1 sin θ1b1 v1x + k2 s2 sin θ2
f1y = m1 a1y = −k1 s1 cos θ1b1 v1y + k2 s2 cos θ2 + m1 g
f2x = m2 a2x = −k2 s2 sin θ2b2 v2x
f2y = m2 a2y = −k2 s2 cos θ2b2 v2y + m2 g
the spring stretch sn and angles θn are functions of the positions un of the bobs as follows: l1 = √((u1xtx)2 + (u1yty)2)
l2 = √((u2xu1x)2 + (u2yu1x)2)
s1 = l1r1
s2 = l2r2
cos θ1 = (u1yty)/l1
sin θ1 = (u1xtx)/l1
cos θ2 = (u2yu1y)/l2
sin θ2 = (u2xu1x)/l2

## numerical solution

to solve the equations of motion numerically, so that we can drive the simulation, we use the runge-kutta method for solving sets of ordinary differential equations. we need to convert the four second order equations of motion to eight first order equations. u1x' = v1x
u1y' = v1y
u2x' = v2x
u2y' = v2y
v1x' = −(k1/m1) s1 sin θ1 − (b1/m1) v1x + (k2/m1) s2 sin θ2
v1y' = −(k1/m1) s1 cos θ1 − (b1/m1) v1y + (k2/m1) s2 cos θ2 + g
v2x' = −(k2/m2) s2 sin θ2 − (b2/m2) v2x
v2y' = −(k2/m2) s2 cos θ2 − (b2/m2) v2y + g
we keep in mind that the spring stretch sn and angles θn are functions of the position of the bob un as given previously.