Chapter 2, Damped harmonic oscillator

Example 3, page 102

In [4]:
from __future__ import division
from math import log
# relaxation time ,damping force ,time and total distance
v=10 #cm/s
vo=100 #cm/s
t=23 #sec
x=-(log(v/vo))/t #
t=(1/x)*1 #seconds
print "Relaxation time  = %0.f seconds " %t
m=40 #gm
vx=50 #cm/sec
fd=((-x*m*10**-3*vx*10**-2)) #newton
print "Damping force = %0.e N" %fd
tx=5*(log(10)) #
print "Time in which kinetic energy will reduce to 1/10th of its value = %0.1f seconds " %tx
xx=v*1 #
print "Distance travelled = %0.f m " %xx
Relaxation time  = 10 seconds 
Damping force = -2e-03 N
Time in which kinetic energy will reduce to 1/10th of its value = 11.5 seconds 
Distance travelled = 10 m 

Example 4, page 104

In [5]:
from math import sqrt, pi
# period
#given data :
m=2 # in g
k=30 # in dynes/cm
b=5 # in dynes/cm-sec**-1
r=b/(2*m) 
w0=sqrt(k/m) 
T=2*pi/sqrt(w0**2-r**2) 
print "The time period, T = %0.2f s  " %T
The time period, T = 1.71 s  

Example 5, page 105

In [6]:
# time
tr=50 #seconds
r=(1/(2*tr)) #s**-1
t=1/r #seconds
print "Time in which amplitude falls to 1/e times the initial value = %0.f seconds " %t
t2=tr #
print "Time in which system falls to 1/e times the initial value = %0.f seconds" %t2
t3=2*(1/r) #f 
print "Time in which energy falls to 1/e^4 of the initial value = %0.f seconds " %t3
Time in which amplitude falls to 1/e times the initial value = 100 seconds 
Time in which system falls to 1/e times the initial value = 50 seconds
Time in which energy falls to 1/e^4 of the initial value = 200 seconds 

Example 6, page 106

In [22]:
from math import sqrt, pi
import sympy
# relaxation time ,frequency ,energy ,time ,rate and number of vibrations
k=20 #N/m
m=5#N-s/m
wo=sqrt(k/m) #
v1=2 #m/s
to=m/v1 #seconds
print "(a) Relaxation time = %0.1f seconds " %to
w=wo*(1-(1/(2*wo*to))**2) #
lf=w/(2*pi) #vibration/s
print "(b) Linear frequency = %0.3f vibration/s " %lf
a=1 #
e=((1/2)*m*a**2*wo**2) #joule
print "(c) Energy = %0.f J "%e
tm=v1*to #seconds
print "(d) Time taken in fall of amlitude to 1/e value = %0.f seconds " %tm
print "(e) Time taken in fall of velocity amplitude to 1/2 value = %0.f seconds " %tm
tr=to #
print "(f) Time taken in fall of energy to 1/e value = %0.2f seconds" %tr
eng=(1/2)*m*a*v1**2*(2/tm) #
print "(g) Rate of loss of energy at t=0 seconds is",eng,"J/s and at any time is",eng,"e^-2*t/",tm,"J/s"
rel=((eng*2*pi)/wo) #J/s
print "(h) Rate of loss of energy per cycle at t=0 seconds is",rel,"J/s and at any time is",round(rel,2),"e^-2*t/",tm,"J/s"
nv=tm/((2*sympy.pi)/wo) #
print "(i) Number of vibratios made are =",nv
(a) Relaxation time = 2.5 seconds 
(b) Linear frequency = 0.315 vibration/s 
(c) Energy = 10 J 
(d) Time taken in fall of amlitude to 1/e value = 5 seconds 
(e) Time taken in fall of velocity amplitude to 1/2 value = 5 seconds 
(f) Time taken in fall of energy to 1/e value = 2.50 seconds
(g) Rate of loss of energy at t=0 seconds is 4.0 J/s and at any time is 4.0 e^-2*t/ 5.0 J/s
(h) Rate of loss of energy per cycle at t=0 seconds is 12.5663706144 J/s and at any time is 12.57 e^-2*t/ 5.0 J/s
(i) Number of vibratios made are = 5.0/pi

Example 7, page 109

In [25]:
# time and distance
b=5 #N-s/m
v=10 #m/s
to=b/v #second
print "(a) Time in which velocity falls to 1/e times the initial value = %0.2f second " %to
t2=b*to #
print "(b) Time in which velocity falls to half the initial value = %0.2f second " %t2
print "(c) Distance traversed by the particle before the velocity falls to half the initial value is",b,"*(1-exp(log)",(2*to)/to
x=b #m
print "(d) Distance traversed by the particle it comes to rest = %0.2f m " %x
(a) Time in which velocity falls to 1/e times the initial value = 0.50 second 
(b) Time in which velocity falls to half the initial value = 2.50 second 
(c) Distance traversed by the particle before the velocity falls to half the initial value is 5 *(1-exp(log) 2.0
(d) Distance traversed by the particle it comes to rest = 5.00 m 

Example 8, page 111

In [27]:
from math import log, pi
# time interval
q=5*10**4 #quality factor
x=1/10 #
fr=300 #second**-1
to=q/(2*pi*fr) #second
xm=((to*log(10))) #seconds
print "Time interval = %0.f seconds " %xm
Time interval = 61 seconds 

Example 9, page 111

In [29]:
# Time
#given data :
n=240 # in sec**-1
w=2*pi*n 
Q=2*10**3 
tau=Q/w 
t=4*tau 
print "Time, t = %0.1f s " %t
Time, t = 5.3 s 

Example 10, page 112

In [31]:
from math import log
# Logarithmic decrement
#given data :
a=100 
l1=20 # in cm
l2=2 # in cm
l=l1/l2 
lamda=(1/100)*log(l) 
print " Logarithmic decrement = %0.3f " %lamda
 Logarithmic decrement = 0.023 

Example 12, page 116

In [33]:
from math import sqrt, pi
# Frequency
#given data :
C=10**-6 # in F
L=0.2 # in H
R=800 # in ohm
Rm=2*sqrt(L/C) 
n=sqrt((1/(L*C))-(R**2/(4*L**2)))/(2*pi) 
print "The frequency, n = %0.1f cycles/s " %n
The frequency, n = 159.2 cycles/s 

Example 13, page 116

In [35]:
from math import sqrt
# Resistance
#given data :
C=0.0012*10**-6 # in F
L=0.2 # in H
Rm=2*sqrt(L/C) 
print "The maximum value of resistance, Rm = %0.2e ohms " %Rm
The maximum value of resistance, Rm = 2.58e+04 ohms 

Example 14, page 117

In [38]:
from math import sqrt, pi
# Q factor
#given data :
C=5*10**-6 # in F
L=2*10**-3 # in H
R=0.2 # in ohm
w=round(sqrt((1/(L*C))-(R**2/(4*L**2)))) 
f=w/(2*pi) 
Q=w*L/R 
print "Frequency = %0.2e Hz " %f
print "Quality factor, Q = %0.f " %Q
Frequency = 1.59e+03 Hz 
Quality factor, Q = 100