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