attempting to run this command on python 3.10, however, it is not working, could someone please help me out? Also, disregard the line indentations. """ AFT of Hydrogen at different equivalence ratios 2H2 + O2 + 3.76N2 = 2H20 +7.52N2 """ import matplotlib.pyplot as plt import math import numpy as np # The equivalence ratio 'phi' is varied from 0.0 to 2.0 phi = np.linspace(0.0,2.0,101) # Function to calculation the enthalpy using NASA polynomial function def h(T, co_effs): R = 8.314 #J/mol-k

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I'm attempting to run this command on python 3.10, however, it is not working, could someone please help me out? Also, disregard the line indentations.

"""
AFT of Hydrogen at different equivalence ratios

2H2 + O2 + 3.76N2 = 2H20 +7.52N2

"""

import matplotlib.pyplot as plt
import math
import numpy as np

# The equivalence ratio 'phi' is varied from 0.0 to 2.0

phi = np.linspace(0.0,2.0,101)

# Function to calculation the enthalpy using NASA polynomial function

def h(T, co_effs):
R = 8.314 #J/mol-k
a1 = co_effs[0]
a2 = co_effs[1]
a3 = co_effs[2]
a4 = co_effs[3]
a5 = co_effs[4]
a6 = co_effs[5]
  
return(a1 + a2*T/2 + a3*pow(T,2)/3 + a4*pow(T,3)/4 + a5*pow(T,4)/5 + a6/T)*R*T

# Low temp coefficients of reactants at STP conditions

H2_coeffs_l = [2.34433112E+00, 7.98052075E-03, -1.94781510E-05, 2.01572094E-08, -7.37611761E-12, -9.17935173E+02, 6.83010238E-01]

O2_coeffs_l = [3.78245636E+00-2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03, 3.65767573E+00]

N2_coeffs_l = [0.03298677E+02, 0.14082404E-02, -0.03963222E-04, 0.05641515E-07, -0.02444854E-10, -0.10208999E+04, 0.03950372E+02]

# High temp coefficients (products)

H2O_coeffs_h = [3.03399249E+00, 2.17691804E-03, -1.64072518E-07, -9.70419870E-11, 1.68200992E-14, -3.00042971E+04, 4.96677010E+00]

N2_coeffs_h = [0.02926640E+02, 0.14879768E-02, -0.05684760E-05, 0.10097038E-09, -0.06753351E-13, -0.09227977E+04, 0.05980528E+02]

O2_coeffs_h = [3.28253784E+00, 1.48308754E-03, -7.57966669E-07, 2.09470555E-10, -2.16717794E-14, -1.08845772E+03, 5.45323129E+00]

# Function for root-solving usering NR method iteratively

def f(T, phi):
  
R = 8.314
x=0
y=4
  
if phi<=1:
  
h_N2_p = h(T,N2_coeffs_h)
h_H2O_p = h(T,H2O_coeffs_h)
h_O2_p = h(T,O2_coeffs_h)
  
H_products = 2*h_H2O_p + ((2/phi)-2)*h_O2_p + (7.52/phi)*h_N2_p
N_products = 2 + ((2/phi) - 2) + (7.52/phi)
  
Tstp = 298.15
h_H2_r = h(Tstp,H2_coeffs_l)
h_O2_r = h(Tstp,O2_coeffs_l)
h_N2_r = h(Tstp,N2_coeffs_l)
  
H_reactants = h_H2_r + ((2/phi)*(h_O2_r+3.76*h_N2_r))
N_reactants = 1 + (2/phi)*3.76
  
else:
  
h_N2_p = h(T,N2_coeffs_h)
h_H2O_p = h(T,H2O_coeffs_h)
h_O2_p = h(T,O2_coeffs_h)
  
H_products = 2*h_H2O_p + (7.52/phi)*h_N2_p
N_products = 2 + (7.52/phi)
  
Tstp = 298.15
h_H2_r = h(Tstp,H2_coeffs_l)
h_O2_r = h(Tstp,O2_coeffs_l)
h_N2_r = h(Tstp,N2_coeffs_l)
  
H_reactants = h_H2_r + ((2/phi)*(h_O2_r+3.76*h_N2_r))
N_reactants = 1 + (2/phi)*3.76
  
# Defining derivative of function

def fprime(T,phi):
return(f(T+1E-06,phi) - f(T,phi))/1E-03

tol = 1E-03
alpha = 0.5
temp = []

for i in phi:
  
T_guess = 1500
R = 8.314
  
while((f(T_guess,i)) is None or tol):
T_guess = T_guess - alpha*((f(T_guess,i)/fprime(T_guess,i)))
  
temp.append(T_guess)
  
print(max(temp))
print(temp)

plt.figure()
plt.plot(phi,temp,color='red')
plt.xlabel('Equivalence Ratio, $phi$')
plt.ylabel('Adiabatic Flame Temperature ($K)')
plt.title('Adiabatic Flame Temperature vs Equivalence Ratio')

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY