Question: Created on Tue Apr 3 0 2 1 : 3 2 : 0 5 2 0 2 4 @author: bia

"""
Created on Tue Apr 3021:32:052024
@author: bia
"""
from scipy import optimize
import numpy as np
import matplotlib.pyplot as plt
import math
Qa =800.0
V =1.5
D =0.001
I =0.002
mass2area =0.067/0.018
sigma =5.67e-8
emiss =0.95
k1=3.49
Tair =35.0
x1=25.0
def f(Tb):
global Qout, C, E, M
M =0.0258* math.exp (Tb /10)* mass2area
if Tb <=20:
E =0.27
if ((Tb >20) and (Tb <36)):
E =0.08* math.exp (0.0586* Tb)
if Tb >=36:
E =0.00297* math.exp(0.1516* Tb)
E = E * mass2area
Qout = emiss * sigma *(Tb +273.15- I *(M-E))**4
hc = k1* math. sqrt(V)/ math.sqrt(D)
C = hc *(Tb - Tair - I *(M-E))
return M - E + Qa - Qout - C
global Qout, C, E, M
M =0.0258* math.exp(Tb /10)* mass2area
if Tb <=20:
E =0.27
if ((Tb >20) and (Tb <36)):
E =0.08* math.exp(0.0586* Tb )
if Tb >=36:
E =0.00297* math.exp(0.1516* Tb)
E = E * mass2area
Qout = emiss * sigma *(Tb +273.15- I *(M-E))**4
hc = k1* math.sqrt(V)/ math.sqrt (D)
C = hc *(Tb - Tair - I *(M-E))
return M - E + Qa - Qout - C
points =201
root = np.zeros (points)
wind = np.zeros (points)
for i in range (points):
V = i /100
wind[i]= V
root[i]= optimize.newton(f, x1)
# plot first graph
plt.plot(wind, root)
linex =[0,2]
liney =[45,45]
plt.plot (linex, liney, linesyles = 'dashed')
plt.xlabel(' wind speed (m/s)')
plt.ylabel ( 'Body temp (deg-C)')
plt.savefig(" Lizard")
plt.show()
I keep getting this error, please help me correct this so my program can run runfile('/Users/bia/Downloads/untitled0.py', wdir='/Users/bia/Downloads')
File ~/Downloads/untitled0.py:40
global Qout, C, E, M
^
SyntaxError: name 'Qout' is used prior to global declaration

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!