#Chapter_3 Generalized Performance Characteristics Of Instruments
#Caption:Gaussian Distribution
# Example 1
me=7. ;
stddev=0.5;
x = 6. #('enter the lower limit of the range=:')
y= 7.5 #('enter the upper limit of the range=:')
n= 200. #('enter the number of samples=:')
print"using k =abs((x-me)/((2**0.5)*stddev));"
k =abs((x-me)/((2**0.5)*stddev));
print'Value of eta1 is \n',k
p=abs((y-me)/((2**0.5)*stddev));
print'Value of eta2 is \n',p
#Using the gaussian probability error function table, find the error function corresponding to the value of k and p
#LET IT BE s
s= 0.95 # ('enter the error function corresponding to k value=:')
Fx=(1./2.)+(1./2.*s);# Probability of having lengths less than x
l= 0.68 # ('enter the error function corresponding to p value=:')
Fy=(1./2.)+(1./2.*l);# Probability of having lengths less than y
print'probability of having length less than 6 cm is ',Fx
print'probability of having length less than 67.5cm is ',Fy
Px=abs(Fy-Fx);
print"Number of samples in the given length range="
m=(n*Px);
print(m);
#Caption:Combination of component errors in overall system-accuracy calculations
#example2
#page 62
#Consider an experiment for measuring, by means of a dynamometer, the average power transmitted by a rotating sheft
from math import pi
R=1202. #('Enter the revolutions of shaft during time t=:')
F=45. #('Enter the force at end oftorque arm=:')
L=0.397 #('Enter the length of torque arm=:')
t=60. #('Enter the time length of run=:')
W=(2*pi*R*F*L)/t;
#Computing various partial dervatives
dWF=(2*pi*R*L)/t;
print(dWF) #dWF represents dW/dF
dWR=(2*pi*F*L)/t;
dWL=(2*pi*F*R)/t;
dWt=-(2*pi*R*F*L)/(t**2);
#Let f, r, l and t represent the uncertainties
f=0.18 #('Enter the uncertainty in force=:')
r=1 #('Enter the uncertainty in the no of revolutions=:')
l=0.00127 #('Enter the uncertainty in the length=:')
t=0.5 #('Enter the uncertainty in the time length of run=:')
Ea=(dWF*f)+(dWR*r)+(dWL*l)+abs(dWt*t); #absolute error
print"The absolute error is "
print(Ea);
#To find total uncertainty
U=(((dWF*f)**2)+(dWR*r)**2+(dWL*l)**2+abs(dWt*t)**2)**0.5
print"Total uncertainty is "
print(U)
#Caption:Combination of component errors in overall system-accuracy calculations
#example3
#page 64
#Consider an experiment for measuring, by means of a dynamometer, the average power transmitted by a rotating sheft
from math import pi
R=1305. #('Enter the revolutions of shaft during time t=:')
F=85. #('Enter the force at end oftorque arm=:')
L=0.467 #('Enter the length of torque arm=:')
t=10. #('Enter the time length of run=:')
W=(2*pi*R*F*L)/t;
#Computing various partial dervatives
dWF=(2*pi*R*L)/t;
print(dWF) #dWF represents dW/dF
dWR=(2*pi*F*L)/t;
dWL=(2*pi*F*R)/t;
dWt=-(2*pi*R*F*L)/(t**2);
#Let f, r, l and t represent the uncertainties
f=0.18 #('Enter the uncertainty in force=:')
r=1 #('Enter the uncertainty in the no of revolutions=:')
l=0.00127 #('Enter the uncertainty in the length=:')
t=0.5 #('Enter the uncertainty in the time length of run=:')
Ea=(dWF*f)+(dWR*r)+(dWL*l)+abs(dWt*t); #absolute error
print"The absolute error is "
print(Ea);
#To find total uncertainty
U=(((dWF*f)**2)+(dWR*r)**2+(dWL*l)**2+abs(dWt*t)**2)**0.5
print"Total uncertainty is "
print(U)
# Chapter_3 Generalized Performance Characteristics Of Instruments
#Caption:First order instrument
#Example 4
#Page no. 94
d=.006 #('Enter the diameter of the diameter of the sphere in meters=:')
p=14500. #('Enter the density of the liquid in glass bulb=:')
c=180. #('Enter the specific heat of liquid(in j/kg degree centigrade)=:')
U=20. #('Enter the heat transfer coefficient in W/m^2-degree centigrade=:')
from math import pi
Vb=(pi*d*d*d)/6; #Volume of sphere
Ab=pi*d*d; #Surface area of sphere
timconstant=(p*c*Vb*1000)/(U*Ab); #time constant
print "the value of the time constatn is ",(timconstant)
# Chapter_3 Generalized Performance Characteristics Of Instruments
#Caption:First order instrument
#Example 5
#Page no. 96
d=.004 #('Enter the diameter of the diameter of the sphere in meters=:')
p=13600. #('Enter the density of the liquid in glass bulb=:')
c=150. #('Enter the specific heat of liquid(in j/kg degree centigrade)=:')
U=40. #('Enter the heat transfer coefficient in W/m^2-degree centigrade=:')
from math import pi
Vb=(pi*d*d*d)/6; #Volume of sphere
Ab=pi*d*d; #Surface area of sphere
timconstant=(p*c*Vb*1000)/(U*Ab); #time constant
print "the value of the time constatn is ",(timconstant)
#Caption:Step response of first order systems
#Example 6
# page 100
# Given:In air, probe dry timeconstant(tc)=30s
# In water tc=5s
# In air, probe wet tc=20s
# for t<0,T=25 degree C(initial temperature)
# 0<t<7, T=35 degree C(dry probe in air)
# 7<t<15, T=70 degree C(probe in water)
# 15<t<30, T=35 degree C(wet probe in air)
from math import e
#case i T(a)=25
T7=35+(25-35)*e**(-(7/30))
print"Temperature at the end of first interval"
print(T7);
#case ii T(a)=T7
T15=70+(T7-70)*e**(-((15-7)/5))
print"Temperature at the end of second interval"
print(T15);
#case iii T(a)=T15
T30=35+(T15-35)*e**(-((30-15)/20))
print"Temperature at the end of third interval"
print(round(T30));
#Caption:Adequate frequency response conditions for first order instruments
#Example 7
#Page 103
# To measure qi given by
# qi=sin2t+0.3sin20t
# timeconstant=0.2s
from math import pi,atan
H=1/((0.16+1)**0.5); #H(jw)=qo/qiK
phi=((atan(-2*0.2))*180)/pi ;
H2=1/((16+1)**0.5);
phi2=((atan(-20*0.2))*180)/pi;
print"sinusoidal transfer function at 2 rad/sec is"
print(H);
print(phi)
print"sinusoidal transfer function at 20rad/sec is"
print(H2)
print(phi2)
print"qo/K can be written as"
print" qo=0.93K sin(2t-21.8)+(0.24K) 0.3sin(20t-76)"
#Suppose we consider use of an instrument with timeconstant=0.002s
H=1/((1.6*(10)**(-5)+1)**0.5);
phi=((atan(-2*.002))*180)/pi ;
H2=1/((1.6*(10**-3)+1)**0.5);
phi2=((atan(-20*0.002))*180)/pi;
print"sinusoidal transfer function at 2 rad/sec is"
print(H);
print(phi)
print"sinusoidal transfer function at 20rad/sec is"
print(H2)
print(phi2)
print"qo/K can be written as"
print"qo=K sin(2t-0.23)+K 0.3sin(20t-2.3)"
print"Clearly, this instrument measures the given qi faithfully"