Homework 14: Problem 1
Homework 14: Problem 1
download=false
Homework 14
Problem 1
Use fsolve to find the roots of the polynomial .
In [ ]:
Problem 2
Use fsolve to find the solution of the following two equations:
In [ ]:
1 of 6 3/7/2017 7:38 AM
HW14 http://localhost:8888/nbconvert/html/Desktop/HW14.ipynb?download=false
Problem 3
Compute the adiabatic flame temperature for a stoichiometric methane-air flame. The code is given below. There is a thermo
class that is modified from your last homework. Also, you'll need thermoData.yaml again. Then there is a function to define.
Fill in the blanks as indicated. You should also read all of the code given below and make sure you understand it.
Equation Summary:
.
.
.
.
and are given.
.
Do these separately for reactants and products That is: for the
reactants. (Also is the same for products since mass is conserved.)
is computed using the thermo class. So, if t_CO2 is my thermo class object for , then
h_CO2=t_CO2.h_mass(T).
Description:
2 of 6 3/7/2017 7:38 AM
HW14 http://localhost:8888/nbconvert/html/Desktop/HW14.ipynb?download=false
class thermo:
def __init__(self, species, MW) :
"""
species: input string name of species in thermoData.yaml
M: input (species molecular weight, kg/kmol)
"""
self.Rgas = 8314.46 # J/kmol*K
self.M = MW
with open("thermoData.yaml") as yfile :
yfile = yaml.load(yfile)
self.a_lo = yfile[species]["a_lo"]
self.a_hi = yfile[species]["a_hi"]
self.T_lo = 300.
self.T_mid = 1000.
self.T_hi = 3000.
#--------------------------------------------------------
def h_mole(self,T) :
"""
return enthalpy in units of J/kmol
T: input (K)
"""
if T<=self.T_mid and T>=self.T_lo :
a = self.a_lo
elif T>self.T_mid and T<=self.T_hi :
a = self.a_hi
else :
print ("ERROR: temperature is out of range")
hrt = a[0] + a[1]/2.0*T + a[2]/3.0*T*T + a[3]/4.0*T**3.0 + a[4]/5.0*T**4.0
+ a[5]/T
return hrt * self.Rgas * T
#--------------------------------------------------------
def h_mass(self,T) :
"""
return enthalpy in units of J/kg
T: input (K)
"""
return self.h_mole(T)/self.M
3 of 6 3/7/2017 7:38 AM
HW14 http://localhost:8888/nbconvert/html/Desktop/HW14.ipynb?download=false
#-------- Reactants
# TO DO: compute total mass, then mass fractions
# TO DO: Set reactant temperature, then compute reactant enthalpy
#---------- Products
# TO DO: Set the product enthalpy = reactant enthalpy
# TO DO: Set the product mass fractions
# TO DO: Compute the enthalpy of the products corresponding to the current Tp
# Then return the function: f(Tp) = hp - hp_based_on_current_Tp
In [4]: # TO DO: Set a guess temperature, then solve for the product temperature
Problem 4
4 of 6 3/7/2017 7:38 AM
HW14 http://localhost:8888/nbconvert/html/Desktop/HW14.ipynb?download=false
This is solving a parallel pipe network where we have three pipes that are connected at the beginning and the end. The pipes
can be of different lengths and diameter and pipe roughness. Given the total flow rate, and the pipe properties, find the flow
rate through each of three parallel pipes.
Here, is the friction factor in the pipe. We treat it as an unknown so we have three more unknowns: , , .
The Colbrook equation relates to for given pipe properties. So, we have three more equations.
Here are the six equations in terms of the six unknowns: , , , , , .
1. .
2.
3.
5 of 6 3/7/2017 7:38 AM
HW14 http://localhost:8888/nbconvert/html/Desktop/HW14.ipynb?download=false
return F
#--------------------------------------
# TO DO: make a guess array for the unknowns: Q1, Q2, Q3, f1, f2, f3
# (use Q3 = Qtot-Q1-Q2 in your guess, for consistency)
# TO DO: Solve the problem and print the results.
In [ ]:
6 of 6 3/7/2017 7:38 AM