Chapter 2: Zeroth Law of Thermodynamics

Example 1, page no. 46

In [1]:
  
#Variable Declaration: 
Tf = 98.6 #Temperature of human body in degree Fahrenheit:

#Calculation:
Tc = (Tf-32)/1.8 #Temperature of the body in degree Celcius:

#Results:
print "Temperature of the human body ",Tc,"°C"
Temperature of the human body  37.0 °C

Example 2, page no. 47

In [2]:
 
import math as m
import numpy as n

#Variable Declaration: 
p0 = 3.0   #Thermodynamic property at T = 0:
p100 = 8.0 #Thermodynamic property at T = 100:
p = 6.5                                 #Thermodynamic property at which t is to be found

#Calculation:
#Solving two linear equation by linear Algebra using matrices AX = B
A = n.matrix([[m.log(p0),0.5],[m.log(p100),0.5]])
B = n.matrix([[0],[100]])
X = n.matrix.getI(A)*B
a = round(X[0],2)                       #Thermodynamic constant a from matrix solution
b = round(X[1])                         #Thermodynamic constant b from matrix solution
t = a*m.log(p)-b/2      #At thermodynamic property p = 6.5:

#Results:
print "Temperature at the value of thermodynamic property (p = 6.5)" ,round(t,2),"°C"
Temperature at the value of thermodynamic property (p = 6.5) 302.83 °C

Example 3, page no. 47

In [3]:
  
#Variable Declaration:
T0 = 0                                              #Ice point (°C)
T100 = 100                                          #Steam Poiont (°C)
def E(t):                                           #Function definition for above expression of EMF
    return 0.003*t - 5*10**-7*t**2 + 0.5 *10**-3

#Calculation:
t = (E(30)-E(0))/(E(100)-E(0))*(T100-T0)    #Temperature shown by the thermometer at T = 30:

#Results:
print "!--Please check that there are calculation mistake done in the book \nhence there is heavy difference in answer of book and the code--!\n"
print  "The temperature shown by thermometer: ",round(t,2),"°C"
!--Please check that there are calculation mistake done in the book 
hence there is heavy difference in answer of book and the code--!

The temperature shown by thermometer:  30.36 °C

Example 4, page no. 48

In [4]:
 
#Variable Declaration: 
t1 = 50 #Temperature of gas using gas thermometer:
def E(t):                       #Function Definition as per question:
    return 0.18*t - 5.2*10**-4*t**2
    
#Calculation:
t = (100-0)*E(t1)/(E(100)-E(0))	#Temperature at EMF = E50:
p = (t-t1)/t1*100

#Results:
print  "Percentage variation: ",round(p,2),"%"
 
Percentage variation:  20.31 %

Example 5, page no. 48

In [5]:
 
import numpy as n

#Variable Declaration: 
#Solving the conversion relation X = aC + b using matrices and finding a and b
B = n.matrix([[0],[1000]])
A = n.matrix([[0,1],[100,1]])

#Calculations:
X = n.matrix.getI(A)*B
a = round(X[0])                 #Value of a of equation X = aC + B
b = round(X[1])                 #Value of b of equation X = aC + B
X = a*-273.15+b #Absolute temperature in new temperature scale:

#Results:
print  "Absolute temperature in new scale: ",X,"°X"
Absolute temperature in new scale:  -2731.5 °X