# Internal energy problem

1. Mar 17, 2010

### serchyissexy

1. The problem statement, all variables and given/known data

Use your program for the viscously damped spring to solve this problem. Make sure you change the parameters as specified below.

A mass m=7.1 kg is attached to the end of a spring with a spring constant of k=16.4 N/m. The mass moves through a viscous damping medium with a damping constant b=1.8 kg/s giving a velocity dependent damping force Fdamp= -bv.

The motion occurs in zero gravity so set the force of gravity to ZERO in your program. Also set the equilibrium position L0=0. The mass is initially motionless and displaced from equilibrium by a distance yinitial=0.2 m.

What is the energy of the spring-mass system when the mass first passes through the equilibrium position? (you may wish to include a logical test to help you find when this occurs)

2. Relevant equations

from __future__ import division
from visual.graph import *

scene.y = 400 # moves animation window down 400 pixels to make room for graph

# Constants
pi = 3.14159
L0 = .08 # equilibrium length of spring (not stretched)
g = 0 # gravitational acceleration set to zero (not on earth)
k = 14 # insert the spring constant you found for the coiled spring

# Objects
# Ceiling to hang spring from.
# block to act as mass.
# Spring is represented by a cylinder.
scene.center = vector(0,-.1,0) # you may want to adjust this to improve display

ceiling = box(pos=vector(0,0,0), size=(.3,0.005,0.005)) # make the contact pointthe origin
block=box(pos=vector(0,-0.1,0), size=(.02,0.02,0.02), color=color.yellow)

# Using the positions of the block and ceiling set the cylinder to stretch from the ceiling to the block

# Initial values
block.m = 0.45 # insert the measured mass from coiled spring experiment.
block.v = vector(0,0,0) # the vector velocity assuming the block is initially stationary
block.p= block.m * block.v

block.pos=vector(0,-L0-0.05,0) # initial position of block 0.05m from equilibrium

# Setting the timestep and zeroing the cumulative time
deltat = .0001 # you should decrease this later to test if it is small enough
t = 0
W = 0
displacement=0
Kgraph = gcurve(color=color.cyan)
Ugraph = gcurve(color=color.yellow)
KplusUgraph = gcurve(color=color.red)
Wgraph = gcurve(color=color.green)
# Loop for repetitive calculations
scene.autoscale=0
while t < 4:

Fnet= -(((block.pos-vector(0,-L0,0))*k))-((block.p/block.m)*.2) #INSERT the force of the spring on the block
displacement=(mag(block.p)/block.m)*deltat
block.p= block.p+Fnet*deltat # updates the momentum
block.pos= block.pos+block.p/block.m*deltat # updates the position
spring.axis = block.pos #updates the spring axis so it stays on the block
t=t+deltat
pmag = mag(block.p) # or whatever you've called the block's momentum

K = (pmag**2)*.5/block.m #COMPLETE this for the kinetic energy of the
block
U = ((mag(block.pos)-L0)**2)*.5*k #COMPLETE this for the potential energy of the block-spring system (note no gravity)
W = W - displacement*(mag(block.p)/block.m)*.2
Kgraph.plot(pos=(t,K))
Ugraph.plot(pos=(t,U))
KplusUgraph.plot(pos=(t,K+U))
Wgraph.plot(pos=(t,W))

3. The attempt at a solution