# 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.

*f*_{1x} = *m*_{1} *a*_{1x} = −*k*_{1} *s*_{1} sin *θ*_{1} − *b*_{1} *v*_{1x} + *k*_{2} *s*_{2} sin *θ*_{2}

*f*_{1y} = *m*_{1} *a*_{1y} = −*k*_{1} *s*_{1} cos *θ*_{1} − *b*_{1} *v*_{1y} + *k*_{2} *s*_{2} cos *θ*_{2} + *m*_{1} g

*f*_{2x} = *m*_{2} *a*_{2x} = −*k*_{2} *s*_{2} sin *θ*_{2} − *b*_{2} *v*_{2x}

*f*_{2y} = *m*_{2} *a*_{2y} = −*k*_{2} *s*_{2} cos *θ*_{2} − *b*_{2} *v*_{2y} + *m*_{2} g
the spring stretch

*s*_{n} and angles

*θ*_{n} are functions of the positions

*u*_{n} of the bobs as follows:

*l*_{1} = √((*u*_{1x} − *t*_{x})^{2} + (*u*_{1y} − *t*_{y})^{2})

*l*_{2} = √((*u*_{2x} − *u*_{1x})^{2} + (*u*_{2y} − *u*_{1x})^{2})

*s*_{1} = *l*_{1} − *r*_{1}

*s*_{2} = *l*_{2} − *r*_{2}

cos *θ*_{1} = (*u*_{1y} − *t*_{y})/*l*_{1}

sin *θ*_{1} = (*u*_{1x} − *t*_{x})/*l*_{1}

cos *θ*_{2} = (*u*_{2y} − *u*_{1y})/*l*_{2}

sin *θ*_{2} = (*u*_{2x} − *u*_{1x})/*l*_{2}
## 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.

*u*_{1x}' = *v*_{1x}

*u*_{1y}' = *v*_{1y}

*u*_{2x}' = *v*_{2x}

*u*_{2y}' = *v*_{2y}

*v*_{1x}' = −(*k*_{1}/*m*_{1}) *s*_{1} sin *θ*_{1} − (*b*_{1}/*m*_{1}) *v*_{1x} + (*k*_{2}/*m*_{1}) *s*_{2} sin *θ*_{2}

*v*_{1y}' = −(*k*_{1}/*m*_{1}) *s*_{1} cos *θ*_{1} − (*b*_{1}/*m*_{1}) *v*_{1y} + (*k*_{2}/*m*_{1}) *s*_{2} cos *θ*_{2} + g

*v*_{2x}' = −(*k*_{2}/*m*_{2}) *s*_{2} sin *θ*_{2} − (*b*_{2}/*m*_{2}) *v*_{2x}

*v*_{2y}' = −(*k*_{2}/*m*_{2}) *s*_{2} cos *θ*_{2} − (*b*_{2}/*m*_{2}) *v*_{2y} + g
we keep in mind that the spring stretch

*s*_{n} and angles

*θ*_{n} are functions of the position of the bob

*u*_{n} as given previously.