from math import log
#Variable Declaration
betaOH = 11.2e-4 #Thermal exapnasion coefficient of ethanol, °C
betagl = 2.00e-5 #Thermal exapnasion coefficient of glass, °C
kOH = 11.0e-5 #Isothermal compressibility of ethanol, /bar
dT = 10.0 #Increase in Temperature, °C
#Calcualtions
vfbyvi = (1+ betagl*dT)
dP = betaOH*dT/kOH-(1./kOH)*log(vfbyvi)
#Results
print 'Pressure increase in capillary %4.1f bar'%dP
#Variable Declaration
cpsubysy = 1000 #Specific heat ration of surrounding and system
Tpreci = 0.006 #Precision in Temperature measurement, °C
#Calcualtions
dtgas = -cpsubysy*(-Tpreci)
#Results
print 'Minimum detectable temperature change of gas +-%4.1f °C'%dtgas
from sympy import symbols, integrate
#Variable Declaration
n = 1.0 #number of mole of N2, mol
Ti = 200.0 #Intial Temperature, K
Pi = 5.00 #Initial pressure, bar
Tf = 400.0 #Intial Temperature, K
Pf = 20.0 #Initial pressure, bar
a = 0.137 #van der Waals constant a, Pa.m3/(mol2)
b = 3.87e-5 #van der Waals constant b, m3/(mol)
A, B, C, D = 22.5, -1.187e-2,2.3968e-5, -1.0176e-8
#Constants in Cvm equation J, K and mol
vi = 3.28e-3 #initial volume, m3/mol
vf = 7.88e-3 #Final volume, m3/mol
#Calculations
T = symbols('T')
dUT = n**2*a*(1./vi-1./vf)
dUV = integrate( A + B*T + C*T**2 + D*T**3, (T,Ti,Tf))
#Results
print 'dUT = %4.1f J: This is wrongly reported in book'%dUT
print 'dUV = %4.1f J'%dUV
from sympy import symbols, integrate
#Variable Declaration
m = 143.0 #Mass of graphite, g
Ti = 300.0 #Intial Temperature, K
Tf = 600.0 #Intial Temperature, K
A, B, C, D, E = -12.19,0.1126,-1.947e-4,1.919e-7,-7.8e-11
#Constants in Cvm equation J, K and mol
M = 12.01
#Calculations
T = symbols('T')
dH = (m/M)*integrate( A + B*T + C*T**2 + D*T**3 + E*T**4, (T,Ti,Tf))
expr = A + B*T + C*T**2 + D*T**3 + E*T**4
cpm = expr.subs(T,300.)
qp = (m/M)*cpm*(Tf-Ti)
err = abs(dH-qp)/dH
#Results
print 'dH = %6.1f kJ'%(dH/1000)
print 'qp = %6.1f kJ'%(qp/1000)
print 'Error in calculations %4.1f'%(err*100)
#Variable Declaration
m = 124.0 #Mass of liquid methanol, g
Pi = 1.0 #Initial Pressure, bar
Ti = 298.0 #Intial Temperature, K
Pf = 2.5 #Final Pressure, bar
Tf = 425.0 #Intial Temperature, K
rho = 0.791 #Density, g/cc
Cpm = 81.1 #Specifi heat, J/(K.mol)
M = 32.04
#Calculations
n = m/M
DH = n*Cpm*(Tf-Ti)+ m*(Pf-Pi)*1e-6/rho
#Results
print 'Enthalpy change for change in state of methanol is %4.1f kJ'%(DH/1000)