from scipy.integrate import quad
# Variables
V1 = 0.1 ; # Volume of gas initially -[cubic metres]
V2 = 0.2 ; # Volume of gas finally -[cubic metres]
T1 = 300 ; # Temperature of gas initially -[K]
P1 = 200 ; # Pressure of gas finally -[kPa]
R = 8.314 ; # Universal gas constant
n = (P1*V1)/(T1*R) ; # Moles of gas taken-[kg mol]
#You are asked to calculate work by eqn. 21.1 , but you do not know the F(force) exerted by gas , so write F = P.A, multiply divide A and eqn 21.1 reduces to W= integate(P.dv)
# Calculations and Results
# Isobaric process see fig E21.1b to see the path followed
def f(V):
return -(P1)
W= quad(f,V1,V2)[0] ; # Work done by gas on piston -[kJ]
print ' (a)Work done by gas on piston for isobaric process is %.0f kJ . ',W
def f1(V):
return -(T1*R*n/V)
W= quad(f1,V1,V2)[0] ; # Work done by gas on piston -[kJ]
print '(b)Work done by gas on piston for isothermal process is %.2f kJ . ',W
# Variables
id_ = 3. ; # Internal diameter of tube-[cm]
Vf = 0.001 ; # Volume flow rate of water in tube-[cubic meter/s]
rho = 1000. ; # Assumed density of water-[kg/cubic meter]
# Calculations
rad = id_/2. ; # Radius of tube -[ cm]
a = 3.14*rad**2 ; # Area of flow of tube -[squqre centimeter]
v = Vf*(100)**2/a ; # Velocity of water in tube - [m/s]
KE = v**2/2. ; # Specific(mass=1kg) kinetic energy of water in tube -[J/kg]
# Results
print 'Specific kinetic energy of water in tube is %.2f J/kg . '%KE
# Variables
# Let water level in first reservoir be the reference plane
h = 40. ; # Difference of water-[ft]
g = 32.2 ; # acceleration due to gravity-[ft/square second]
# Calculations
PE=g*h/(32.2*778.2) ; # # Specific(mass=1kg) potential energy of water -[Btu/lbm]
# Results
print 'Specific potential energy of water is %.4f Btu/lbm . '%PE
# Variables
#Constant volume process
mol_air = 10. ; # Moles of air-[kg mol]
T1 = 60.+273 ; # Initial temperature of air-[K]
T2 = 30.+273 ; # final temperature of air-[K]
# Additional data needed
Cv = 2.1*10.**4 ; # Specific heat capacity of air at constant volume-[J/(kg mol*C)]
# Calculations
def f(T):
return mol_air*Cv
del_U = quad(f,T1,T2)[0] ; #Change in internal energy-[J]
# Results
print 'Change in internal energy is %.1e J . '%del_U
# Variables
#Constant pressure process
mol_air = 10. ; # Moles of air-[kg mol]
T1 = 60+273 ; # Initial temperature of air-[K]
T2 = 30+273 ; # final temperature of air-[K]
# Calculations
# Additional data needed
Cp = 2.9*10**4 ; # Specific heat capacity of air at constant pressure-[J/(kg mol*C)]
# Use eqn. 21.11 for del_H
def f(T):
return mol_air*Cp
del_H = quad(f,T1,T2)[0] ; #Change in enthalpy-[J]
print 'Change in enthalpy is %.1e J . '%del_H