#CHAPTER 8 _ TEMPERATURE MEASUREMENT
#Caption : Thermocouple
# Example 1 # Page 500
import numpy
from math import pi,sqrt
t1 = 100. #('entering the temperature(in deg cent) =:')
e1= 5. # ('entering the emf (in mv)at temperature t1 =:')
t2=445. #('entering the second temperature(in deg cent)= :')
e2=25. #('entering the emf(in mv) at temperature t2 =:')
# TO CALCULATE CONSTANTS a AND b
#e1=a*(t1)+b*(t1**2);
#e2=a*(t2)+b*(t2**2);
A=numpy.matrix([[t1, t1**2],[t2, t2**2]]);
B=[(e1, 0),(e2, 0)]
Y=numpy.array([[0.0482088,0.],[0.0000179,0.]]); #computes the minimum norm least square solution of the equation A*Y=B,
print(Y)
print'value of constants a and b are d V/deg cent and d V/deg cent respectively',Y[0,0],Y[1,0]
#PART B
#Let e(0-40) be represented by E1 , e(40-t) by E2 and e(0-t) by E3
E1=(Y[0,0]*40)+(Y[1,0]*40**2);
print(E1);
E2=2; # given
E3=E1+E2;
D=sqrt((Y[0,0]**2)+(4*Y[1,0]*E3));
t=(-Y[1,1]+D)/(2*Y[1,0]);
print(t)
print'Hot junction temperature is deg cent ',t
# PART C
# Let e(0-500) be represented by E4 and e(40-500) by E5
E4=Y[0,0]*500+Y[1,0]*500**2;
E5=E4-E1;
print (E5)
print'emf when the hot junction is at 500 and cold at 40 is mV ',round(E5,2)
#CHAPTER 8 _ TEMPERATURE MEASUREMENT
#Caption : THERMOCOUPLE AND THERMOPILE
# Example 2 # Page 511
h=(100/5)*10**-3 # in mv print'emf per thermocouple is %1.2f mV \n', h);
# e(0-100)+e(100-t)=e(0-t)
# Let e(0-100) = E1 and e(100-t)= E2
E1= 5.27 # given
E2=h;
E3=E1+E2;
E4=5.325; # given emf at 101 deg cent
c=100 ; # given that cold junction is at 100 deg cent
# BT EXTRAPOLATION
t=c+((E3-E1)/(E4-E1));
print'Required temperature difference is deg cent ' ,round(t)
#CHAPTER 8 _ TEMPERATURE MEASUREMENT
#Caption : ELECTRICAL- RESISTANCE SENSORS
# Example 3 # Page 517
from math import pi
s =0.2 #('enter the sensitivity =:')
d=0.4*10**-3
A=pi*(d**2)/4;
# R=pho *l/A
R=100
pho=0.8*10**-3;
l=(R*A)/pho;
print'Length corresponding to resistance 100 ohm and diameter 0.4mm is d m\n',l
d=2*10**-3
A=pi*(d**2)/4;
R=100
pho=0.8*10**-3;
l=(R*A)/pho;
print'Length corresponding to resistance 100 ohm and diameter 2mm is m\n',l
# The above lengths of wire indicate that their diameters should be very small so reasonable lengths can be used in practical applications .
# Let resistance at 50deg cent be R1 and at 100 deg cent be R2
t=-50 #('Enter the temperture at which resistance has to be calculated = :')
R1= R+s*(t-20);
print'Resistance at temperature is ohm \n',t,R1
t2=100 #('Enter the temperture at which resistance has to be calculated = :')
R2= R+s*(t2-20);
print'Resistance at temperature is ohm\n ',t2,R2
#CHAPTER 8 _ TEMPERATURE MEASUREMENT
#Caption : THERMISTOR
# Example 4 # Page 521
from math import log,sqrt
To= 293. #('Enter the temperature in K=:')
Ro=1000. #('Entering the corresponding resistance in ohm=:')
B=3450. # (' Entering the val)ue of constant=:')
Rt=2500. #(' Entering the resistance at which temperature has to be calculated=:')
T=1/((1/To)+(1/B)*log(Rt/Ro));
print("Temperature is given by:")
print("T=1/((1/To)+(1/B)*log(Rt/Ro));")
print'The temperature corresponding to resistance of ohm is K \n ',Rt,T
Wrt=5 #('Entering the error in Rt resistance measurement=:' )
Wro=2 #('Entering the error in Ro temperature measurement=:')
# Let dT/dRt be represented by DRt and dT/dRo by DRo
DRt=-T**2/(B*Rt) ;
DRo=-T**2/(B*Ro);
print ("Error in temperature measurement is given by:")
print("Wt=sqrt((DRt*Wrt)**2+(DRo*Wro)**2);")
Wt=sqrt((DRt*Wrt)**2+(DRo*Wro)**2);
print'Error in the required temperature measurement is K \n',round(Wt,3)
print'So the required temperature is +_ K \n',round(T,3),round(Wt,3)
#CHAPTER 8 _ TEMPERATURE MEASUREMENT
#Caption : PYROMETERS
# Example 5# Page 545
#(i)Optical Pyrometer
# Ta(K) is the actual temperature and Ti(K) is the indicated temperature
TI=1200. #('Enter the indicated temperature in degree centigrade=:')
Ti=TI+273.
from math import log
print("Ti=TI+273")
lamda=0.7*10**-6 #('Entering the wavelength(in meters) at which intensities are compared')
epsilon=0.6 #('Entering the emissivity of the body')
C2=0.014387 #('Entering the value of constant')
print("Actual temperature is given by :")
print("Ta=(Ti*C2)/(C2-lamda*Ti*log(epsilon));")
Ta=(Ti*C2)/(C2-lamda*Ti*log(epsilon));
ta=Ta-273;
print'Actual temperature of the body is \n',ta
#(ii) For radiation pyrometer
T=(epsilon*Ta**4)**(1./4.);
ti=T-273;
print'Indicated temperature in degree celsius of the total radiation pyrometer is degree cent \n',ti
#To calculate error
Error1=Ta-Ti;
print'Error using Optical Pyrometer is K \n',round(Error1,2)
Error2=Ta-T;
print'Error using Radiation Pyrometer is K \n',round(Error2,2)