# Exercise 4 Solutions

# 10.4. Exercise 4 Solutions#

```
#6.7.3 Exercise 1
#Determine the change in specific enthalpy of O<sub>2</sub> as it is heated from 500 K
#to 700 K using
# a) property evaluation in Cantera
# b) polynomial expression for specific heat as a function of temperature
# c) average specific heats
# d) constant specific heat at 300 K.
import cantera as ct
species1=ct.Oxygen()
species2=ct.Oxygen()
T1=500 #K
T2=700 #K
P = 100000 # Pressure not specificed and not necessary because ideal gas. Use 1 bar
```

```
#a)
species1.TP = T1,P
species2.TP = T2,P
h1=species1.TH[1] #J/kg
h2=species2.TH[1] #J/kg
print("Change in specific enthalpy using Cantera property evaluation is ", round((h2-h1)/1000,3), "kJ/kg")
```

```
Change in specific enthalpy using Cantera property evaluation is 200.537 kJ/kg
```

```
#b)
A,B,C,D,E = 31.32234,-20.23531,57.86644,-36.50624,-0.007374 # from NIST Webbook
def cp_int(T,A,B,C,D,E): #this is the integrated form of the shomate equation, which we will evaluate at T1 and T2. Units J/mol
return A*T + B*T**2/2 + C*T**3/3 + D*T**4/4 + E*T**(-1)/(-1)
delta_h=cp_int(T2/1000,A,B,C,D,E)-cp_int(T1/1000,A,B,C,D,E) # The units are J/mol, as seen from the NIST website. Thus we need to convert to kJ/kg or J/g to compare to our other calculations
M_O2 = 32 # kg/kmol
delta_h=delta_h*1000/M_O2
print("The change in enthalpy using the Shomate Equation is", round(delta_h,3), "kJ/kg" )
```

```
The change in enthalpy using the Shomate Equation is 200.503 kJ/kg
```

```
#c)
species1.TP = T1,P
species2.TP = T2,P
cp1=species1.cp #J/kg
cp2=species2.cp #J/kg
cp_avg=(cp1+cp2)/2
print("Change in specific enthalpy using Cantera property evaluation is ", round(cp_avg*(T2-T1)/1000,3), "kJ/kg")
```

```
Change in specific enthalpy using Cantera property evaluation is 200.318 kJ/kg
```

```
#d)
species1.TP = 300,P
cp=species1.cp #J/kg
print("Change in specific enthalpy using Cantera property evaluation is ", round(cp*(T2-T1)/1000,3), "kJ/kg")
```

```
Change in specific enthalpy using Cantera property evaluation is 183.987 kJ/kg
```

```
#6.7.3 Exercise 2
#A cylinder is fitted with a piston and has an initial volume of 0.1 m3 and contains
#N2 gas at 150 kPa, 25 °C. The piston is moved, compressing the N2 until the
#pressure is 1 MPa and T = 150 °C. During compression, heat is transferred from the N2,
#and the work done on the system is 20 kJ. Determine the amount of heat transfer using average specific heats.
import cantera as ct
species1=ct.Nitrogen()
species2=ct.Nitrogen()
V1=0.1 # m3
T1=25+273.15 #K
T2=150+273.15 #K
P1 = 150000 # Although pressure changes, not necessary to account for because ideal gas. Use 1.5 bar.
species1.TP = T1,P1
species2.TP = T2,P1
cv_avg = (species1.cv+species2.cv)/2 # J/kg
# delta_U = Q-W, from first law
W = -20 #kJ
v1=species1.TV[1] #m3/kg
m=V1/v1 #kg
Q=cv_avg*(T2-T1)/1000*m+W #kJ
print("Heat transferred from the system is ", round(Q,3), "kJ/kg")
```

```
Heat transferred from the system is -4.199 kJ/kg
```

```
#6.7.3 Exercise 3
#A cylinder is fitted with a piston contains N2 gas at 150 kPa, 25 °C. 300 kJ/kg of heat is transferred
#to the system at constant pressure. Determine the temperature after heat addition using average specific
#heats. Note that an iterative solution approach is necessary.
import cantera as ct
species1=ct.Nitrogen()
species2=ct.Nitrogen()
T1=25+273.15 #K
P1 = 150000 # Although pressure changes, not necessary to account for because ideal gas. Use 1.5 bar.
species1.TP = T1,P1
cp1=species1.cp
def cp2(Tguess):
species2.TP = Tguess,P1
return species2.cp
def cv_avg(Tguess):
return (cp1+cp2(Tguess))/2 # J/kg
# guess T until cv_avg*(Tguess-T1) = 300 kJ/kg
def Q(Tguess):
return cv_avg(Tguess)*(Tguess-T1)/1000
Tguess=583 #K
print("Q using Tguess", round(Q(Tguess),2), "kJ/kg. T2 is ", Tguess, "K")
# use fsolve to determine T2
import numpy as np
from scipy.optimize import fsolve
def T2(Tguess):
return Q(Tguess)-300
root = fsolve(T2, 500)
print
print("T2 using fsolve", round(root[0],2), "K")
```

```
Q using Tguess 300.76 kJ/kg. T2 is 583 K
```

```
T2 using fsolve 582.3 K
```