import math
#initialization
P1 = 100.0 #lb/in^2
P2 = 14.7 #lb/in^2
T1 = 600+460.0 #R
T2 = 300+460.0 #R
area = 1.0 #in^2
#calculation
#From steam tables
ht1 = 1329.1
h2 = 1192.8
v2 = 30.53
Vel = math.sqrt(2*32.2*778.0*(ht1-h2))
wdot = area*Vel/(144*v2)
#result
print "Exit velocity = %d ft/sec" %Vel
print "Mass flow rate = %.3f lbm/sec" %wdot
#difference in exit velocity due to rounding off in Python
import math
#initialization
Pt1 = 100.0 #lb/in^2
P2 = 15.0 #lb/in^2
A = 1.0 #in^2
T = 500+460.0 #F
gamma = 1.4
#calculation
Pratio = P2/Pt1
r1 = (P2/Pt1)**((gamma-1)/gamma)
r2 = (P2/Pt1)**(2/gamma)
r3 = (P2/Pt1)**((gamma+1)/gamma)
V2 = math.sqrt(2*gamma*32.2*53.3*T*(1-r1)/(gamma-1))
wdot = A*Pt1*math.sqrt(2*gamma*(r2-r3)/(gamma-1)) /(math.sqrt(53.3*T/32.2))
#result
print "Exit velocity = %d ft/sec" %V2
print "Mass flow rate = ", round(wdot, 3), "lbm/sec"
import math
#initialization
Pt1 = 100.0 #lb/in^2
Tt1 = 960.0 #RP2 = 15 #lb/in^2
wdot = 1.13 #lbm/sec
gamma = 1.4
#calculation
Pstar = Pt1*(2/(1+gamma))**(gamma/(gamma-1))
Tstar = Tt1*(2/(1+gamma))
Vstar = math.sqrt(gamma*32.2*53.3*Tstar)
vstar = 53.3*Tstar/(144*Pstar)
Astar = wdot*vstar*144/Vstar
#result
print "Ideal throat area = ", round(Astar,3), "in^2"
print "Ideal pressure = ", round(Pstar, 1), "lb/in^2"
print "Ideal temperature = %d R" %Tstar
print "Ideal throat specific volume = ", round(vstar, 1), "ft^3/lbm"
import math
#initialization
ht1 = 1329.1
st1 = 1.7581
h2s = 1151.4
s2s = 1.7581
#calculation
eta = math.sqrt((ht1-1192.8)/(ht1-h2s))
#result
print "efficiency = ", round(eta, 2)
#initializaiton
v = 2200.0 #exit velocity from ex. 11.2
p = 15.0 #exit pressure
n_eta = 0.95 #nozzle efficiency 95%
t2 = 598.0
#calculations
V2 = n_eta*v
v = (53.3*t2)/(144.0*p)
w = (1.0*V2)/(144.0*v)
print "Volume at exit ", round(v, 1), "ft^3/lbm"
print "The mass flow is ", round(w, 3), "lbm/sec"
#difference in answers due to rounding off in Python, check manually
#initialization
v = 500.0 #ft/sec
P = 14.7 #lb/in^2
T = 60+460.0 #R
eta = 0.85
cp = 0.24
gamma = 1.4
#calculation
Pt2 = eta*P*(1+ (gamma-1)*v**2 /(2*gamma*32.2*53.3*T))**(gamma/(gamma-1))
Tratio = 1+(gamma-1)*v*v/(2*gamma*32.2*53.3*T)
Tt2 = T*Tratio
#result
print "Exit stagnation temperature = %d R" %(Tt2+1)
import math
#initialization
P = 30.0 #lb/in^2
T = 1000+460.0 #R
Pd = 14.7 #lb/in^2
w = 60.0 #lbm/sec
eta = 0.95 #percent
R = 53.3
gamma = 1.35
cp = 0.264
#calculation
V2s = math.sqrt(2*gamma*32.2*53.3*T*(1-(Pd/P)**(0.259))/(gamma-1))
V2 = eta*V2s
Fn = w*(V2)/32.2
#result
print "Thrust of the engine = %d ft/sec" %Fn
#difference due to +5 in V2s calculation while sqrt
import math
#initialization
v = 600.0 #ft/sec
T = 60+460.0 #R
P = 14.7 #lb/in^2
Pratio = 6.0
Tin = 1540+460.0 #R
cp = 0.264
cpratio = 1.35
#calculation
Pt2byP1 = (1+(cpratio-1)*v**2/(cpratio*2*32.2*53.3*T))**(3.86)
Pt3byP1 = Pt2byP1*Pratio
eta = 1-1/(Pt3byP1)**0.259
Tt3 = T*(Pt3byP1)**((cpratio-1)/cpratio)
Q = cp*(Tin-Tt3)
V6 = math.sqrt(eta*2*32.2*778*Q + v**2)
Fn = (V6-v)/32.2
#resullts
print "Thermal efficiency = ", round(eta, 3)
print "thrust per pound of air per sec = ", round(Fn, 1), "lb-sec/lbm"
#initialization
V = 1000.0 #mph
P = 14.7 #lb/in^2
T = 60.0 #F
g = 1.4
#calculation
V1 = V*(88/T)
Pratio = (1+ (g-1)*V1**2 /(2*g*32.2*53.3*(T+460)))**(g/(g-1))
eta = 1-1/(Pratio)**0.286
#result
print "Theoretical cycle efficiency = ", round(eta, 3)
import math
#initialization
P = 300.0 #lb/in^2
P2 = 14.7 #lb/in^2
T = 4540+460.0 #R
w = 100.0 #lbm/sec
g = 1.25
MW = 30.0
R = 1544.0
#calculation
R = R/MW
Pratio = P2/P
V4 = math.sqrt(2*g*32.2*51.5*T*(1-(Pratio)**((g-1)/g))/(g-1))
Fn = w*V4/32.2
#result
print "Thrust = %d lb" %Fn