Rc = 7.; #Compression Ratio Rc = v2/v3
k = 1.4; #It is apparent incerease in compression ratio yields an increased cycle efficiency
notto = (1-(1/Rc)**(k-1))*100; #Efficiency of an otto engine
print "The efficiency of the otto cycle is %.2f percentage"%(notto);
#For the carnot cycle,
#Nc = 1-(T2/T4) #efficiency for the carnot cycle #T2 = lowest temperature #T4 = Highest temperature
T2 = 70.+460; #for converting to R #Conversion of unit
#At 700 F
T4 = 700.+460; #temperatures converted to absolute temperatures;
nc = (1-(T2/T4))*100; #efficiency of the carnot cycle
print "When peak temperature is 700 fahrenheit, efficiency of the carnot cycle is %.2f percentage"%(nc);
#At 1000 F
T4 = 1000.+460; #temperatures converted to absolute temperatures;
nc = (1-(T2/T4))*100; #efficiency of the carnot cycle
print "When peak temperature is 1000 fahrenheit, efficiency of the carnot cycle is %.2f percentage"%(nc);
#At 3000 F
T4 = 3000.+460; #temperatures converted to absolute temperatures;
nc = (1-(T2/T4))*100; #efficiency of the carnot cycle
print "When peak temperature is 3000 fahrenheit, efficiency of the carnot cycle is %.2f percentage"%(nc);
from numpy.linalg import inv
cv = 0.172; #Unit:Btu/(lbm*R) #Specific heat constant
Rc = 7; #Compression Ratio Rc = v2/v3
k = 1.4; #It is apparent incerease in compression ratio yields an increased cycle efficiency
T2 = 70+460; #for converting to R #Conversion of unit
#For 1000 F
T4 = 1000+460; #temperatures converted to absolute temperatures;
T3byT2 = Rc**(k-1); #Unit less
T3 = T3byT2*T2;
qin = cv*(T4-T3); #Unit:Btu/lbm #Heat added
#Qr = cv*(T5-T2)*(T5/T4) = (v2/v3)**(k-1)
Qr = (inv([[Rc]]))**(k-1); #Unit:Btu/lbm #Heat rejected
T5 = T4*Qr;
Qr = cv*(T5-T2); #Unit:Btu/lbm #Heat rejected
print "The net work out is %.2f Btu/lbm"%(qin-Qr);
notto = ((qin-Qr)/qin)*100; #The efficiency of otto cycle
print "The efficiency of otto cycle is %.2f percentage"%(notto);
#The value agrees with the results of problem 9.1
cv = 0.7186; #Unit:kJ/(kg*K) #Specific heat constant for constant volume process
Rc = 8.; #Compression Ratio Rc = v2/v3
k = 1.4; #It is apparent incerease in compression ratio yields an increased cycle efficiency
T2 = 20.+273; #20 C converted to its kelvin value
qin = 50.; #Heat added #Unit:kJ
T3byT2 = Rc**(k-1);
T3 = T3byT2*T2; #Unit:K
#qin = cv*(T4-T3) #heat added #Unit:kJ
T4 = (qin/cv)+T3; #The peak temperature of the cycle #Unit:K
print "The peak temperature of the cycle is %.2f Kelvin i.e. %.2f Celcius"%(T4,T4-273);
#For an Otto cycle,
rc = 7.; #Compression Ratio Rc = v2/v3
q = 50.; #Unit:Btu/lbm #Heat added
p2 = 14.7; #Unit:psia #pressure at point 2
T2 = 60.+460; #temperatures converted to absolute temperatures; #Unit:R
cp = 0.24; #Unit:Btu/(lbm*R) #Specific heat constant for constant pressure process
cv = 0.171; #Unit:Btu/(lbm*R) #Specific heat constant for constant volume process
R = 53.3; #Unit:ft*lbf/lbm*R #constant of proportionality
k = 1.4; #It is apparent incerease in compression ratio yields an increased cycle efficiency
#Refering to figure 9.9,
#At (2),we need v2.
#p2*v2 = R*T2
v2 = (R*T2)/(p2*144); #Unit:ft**3/lbm #1ft**2 = 144 in**2 #specific volume at point 2
print "At point 2, specific volume v2 = %.2f ft**3/lbm"%(v2);
#For The isentropic path (2)&(3),p3*v3**k = p2*v2**k,so
#So,p3 = p2*(v2/v3)**k;
p3 = p2*rc**k; #Unit:psia #pressure at point 3
print "At path2&3";
print "pressure p3 = %.2f psia"%(p3);
v3 = v2/rc; #Unit:ft**3/lbm #specific volume at point 3
print "specific volume v3 = %.2f ft**3/lbm"%(v3);
T3 = (p3*v3*144)/R; #Unit:R #1ft**2 = 144 in**2 #temperature at point 3
print "temperature T3 = %.2f R"%(T3);
print "At point4"
#To obtain the values at (4),we note
v4 = v3; #Unit:ft**3/lbm #specific volume at point 4
print "specific volume v4 = %.2f ft**3/lbm"%(v4);
#qin = cv*(T4-T3)
T4 = T3+(q/cv); #Unit:R #temperature at point 4
print "temperature T4 = %.2f R"%(T4);
#For p4,
p4 = (R*T4)/(144*v4); #Unit:psia #1ft**2 = 144 in**2 #pressure at point 4
print "pressure p4 = %.2f psia"%(p4);
#The last point has the same specific volume as (2),giving
print "At last point"
v5 = v2; #Unit:ft**3/lbm #specific volume at point 5
print "specific volume v5 = %.2f ft**3/lbm"%(v5);
#The isentropic path equation,p5*v5**k = p4*v4**k,so
p5 = p4*(v4/v5)**k; #Unit:psia #pressure at point 5
print "pressure p5 = %.2f psia"%(p5);
T5 = (p5*v5*144)/(R); #Unit:R #1ft**2 = 144 in**2 temperature at point 5
print "temperature T5 = %.2f R"%(T5);
n = (((T4-T3)-(T5-T2))/(T4-T3))*100; #The efficiency of the cycle
print "The efficiency of the cycle is %.2f percentage"%(n);
#For four cycle engine,
#Using the results of problem 9.6,
pm = 1000.; #Unit:kPa #mean effective pressure #Unit:psia
N = 4000./2; #Power strokes per minute #2L engine #Unit:rpm
LA = 2. #Mean #Unit:liters
hp = (pm*LA*N)/44760; #The horsepower #Unit:hp
print "The horsepower is %.2f hp"%(hp);
# variables.
c=0.2; #clearance equal to 20% of its displacement
#An otto engine
#Using results of problem 9.8,
rc = (1+c)/c; #The compression ratio
print "The compression ratio is %.2f"%(rc);
import math
#For four cycle,six cylinder engine,
#Using the results of problem 9.5,
hp = 100; #Horsepower #Unit:hp
L = 4./12; #Unit:ft #stroke is 4 in.
A = (math.pi/4)*(3)**2*6; #Cylinder bore is 3 in.
N = 4000/2; #Power strokes per minute #2L engine #Unit:rpm
#hp = (pm*LA*N)/33000;
pm = (hp*33000)/(L*A*N); #The mean effective pressure #psia
# Results
print "The mean effective pressure is %.2f psia"%(pm);
#six cylinder engine,with print lacement 3.3L
#Using the results of problem 9.5,
hp = 230; #Horsepower #Unit:hp
#3.3L*1000 cm**3/L*(in/2.54 cm)**3
LA = 3.3*1000*(1/2.54)**3; #mean #in**3
N = 5500/2; #Power strokes per minute #2L engine #Unit:rpm
#hp = (pm*LA*N)/33000;
pm = (hp*33000*12)/(LA*N); #1ft = 12inch #The mean effective pressure #psia
print "The mean effective pressure is %.2f psia"%(pm);
from numpy.linalg import inv
#An air-smath.radians(numpy.arcmath.tan(ard Diesel engine
rc = 16; #Compression Ratio Rc = v2/v3
v4byv3 = 2; #Cutoff ratio = v4/v3
k = 1.4; #with the cycle starting at 14 psia and 100 F #It is apparent incerease in compression ratio yields an increased cycle efficiency
T2 = 100+460; #temperatures converted to absolute temperatures;
ndiesel = 1-((inv([[rc]]))**(k-1)*(((v4byv3)**k-1)/(k*(v4byv3-1)))); #The efficiency of the diesel engine
print "The efficiency of the diesel engine is %.2f percentage"%(ndiesel*100);
# T3/T2 = rc**k-1 and T5/T4 = (1/re**k-1) #re = expansion ratio = v5/v4
#But T4/T3 = v4/v3 = rc/re
#So,
T5 = T2*(v4byv3)**k; #The temperature of the exhaust of the cycle #Unit:R
print "The temperature of the exhaust of the cycle is %.2f R i.e. %.2f F"%(T5,T5-460);
#Now,in problem 9.12,
#An air-smath.radians(numpy.arcmath.tan(ard Diesel engine
rc = 16; #Compression Ratio Rc = v2/v3
v4byv3 = 2; #Cutoff ratio = v4/v3
k = 1.4; #with the cycle starting at 14 psia and 100 F #It is apparent incerease in compression ratio yields an increased cycle efficiency
T2 = 100; #Unit:F #temperature
T5 = 1018; #Unit:F #Found in 9.12 #The temperature of the exhaust of the cycle #Unit:R
ndiesel = 0.614 #Efficiency of the diesel engine #Found in 9.12
#Now,in problem 9.13,
cp = 0.24; #Unit:Btu/(lbm*R) #Specific heat constant for constant pressure process
cv = 0.172; #Unit:Btu/(lbm*R) #Specific heat constant for constant volume process
Qr = cv*(T5-T2); #Heat rejected #Unit:Btu/lbm
#ndeisel = 1-(Qr/qin); #Efficiency = ndeisel #qin = heat added
qin = Qr/(1-ndiesel); #Unit:Btu/lbm
J = 778; #J = Conversion factor
networkout = J*(qin-Qr); #(ft*lbf)/lbm #Net work out per pound of gas
print "Net work out per pound of gas is %.2f ft*lbf)/lbm"%(networkout);
#The mean effective pressure is net work divided by (v2-v3):
mep = networkout/((16-1)*144); #1ft**2 = 144 in**2 #Unit:psia #The mean effective pressure
print "The mean effective pressure is %.2f psia"%(mep);
from numpy.linalg import inv
#A Brayton cycle
rc = 7; #Compression Ratio Rc = v2/v3
k = 1.4; #It is apparent incerease in compression ratio yields an increased cycle efficiency
cp = 0.24; #Unit:Btu/(lbm*R) #Specific heat constant for constant pressure process
T3 = 1500; #(unit:fahrenheit) #peak tempeature
p1 = 14.7; #Unit:psia #Initial condition
T1 = 70+460; #temperatures converted to absolute temperatures; #Initial condition
R = 53.3; #Unit:ft*lbf/lbm*R #constant of proportionality
nBrayton = 1-(0.1428571**(k-1)); #A Brayton cycle efficiency
print "A Brayton cycle efficiency is %.2f percentage"%(nBrayton*100);
#If we base our calculation on 1 lbm of gas and use subscripts that corresponds to points (1),(2),(3) and (4) of fig.9.22,we have
v1 = (R*T1)/p1; #Unit:ft**3/lbm #specific volume at point 1
#Because rc = 7 then,
v2 = v1/rc; #Unit:ft**3/lbm #specific volume at point 2
#After the isentropic compression, T2*v2**k-1 = T1*v1**k-1
T2 = T1*(v1/v2)**(k-1); #Unit:R #temperature at point 2
T2 = T2-460; #Unit:fahrenheit #temperature at point 2
qin = cp*(T3-T2); #Heat in #Unit:Btu/lbm
print "The heat in is %.2f Btu/lbm"%(qin);
#Because efficiency can be stated to be work out divided by heat in,
wbyJ = nBrayton*qin; #The work out #Unit:Btu/lbm
print "The work out is %.2f Btu/lbm"%(wbyJ); #Answer is wrong in the book.cause they have taken efficiency value wrong
print "The heat rejected is %.2f Btu/lbm"%(qin-wbyJ); #Anser is affected because of value of wbyJ