search

Class myphysicslab.sims.springs.SingleSpringSim

Provided By
Extends
All Implemented Interfaces

Simulation of a spring-mass system. One end of the spring is fixed, the other end has the mass attached.

Variables and Parameters

Variables:

x = position of mass, stored in vars[0]
v = x' = velocity of mass, stored in vars[1]
L = x - x_0 = current length of spring
L - R = how much spring is stretched from rest length

Parameters:

x_0 = fixed point of spring
R = rest length of spring
k = spring constant
b = damping constant

The fixed point is set to a location such that the mass is at position x=0 when the spring is at its rest length. This makes the simulation match the differential equations shown in the corresponding web page on the myPhysicsLab website. When spring rest length changes, we move the fixed point so that the resting position is still x=0.

Equations of Motion

See also http://www.myphysicslab.com/spring1.html.

The spring force is -k (L - R). Damping force is - b v.

F = -k (L- R) - b v
F = -k (x - x_0 - R) - b V
F = m a = m v'
-k (x - x_0 - R) - b v = m v'

The equations of motion are:

x' = v
v' = -(k/m)(x - x_0 - R) -(b/m)v

Work from Damping

The work from damping is stored in vars[3]. We intergrate the work done by damping as follows:

dW = F dR  (work = force times distance)

divide by dt

dW/dt = F dR/dt = F v

Since the damping force is F = -b v we have

dW/dt = -b v^2.

Note that #initWork method should be called if initial conditions are modified.

new SingleSpringSim( opt_name )

Parameters
opt_name(string|undefined)

name of this as a Subject

Instance Methods

Instance Properties

Static Properties

Type Definitions