# Initialization of Variable
from math import pi
from math import atan
from numpy import *
re=6.0
k=1.4
#calculations
nt=1-1/re**(k-1)
ntt=nt*100 #efficiency
#results
print "Thermal efficiency in percent",round(ntt,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
d=3.25 #in
stroke=4.0 #in
v=6.0 #cu in
#calculations
Dp=d**2 *pi*stroke/4
r=(Dp+v)/v #compression ratio
#results
print "Compression ratio ",round(r,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
per=20.0
Dp=100.0
#calculations
r=Dp/per +1
#results
print "Compression ratio ",round(r,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
r=16.0
rc=4.0
k=1.4
#calculations
etat=1-1/r**(k-1) *((rc**k -1)/(k*(rc-1)))
eta=etat*100; #efficiency
#results
print "Thermal efficiency in percent",round(eta,3)
print "The answer is a bit different due to rounding off error in the textbook"
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
F=200 #lb
area=1.65 #sq. in
length=3.5 #in
#calculations
ord=area/length
mep=ord*F
#results
print "MEP of an engine in psi",round(mep,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
Pi=90 #psi
L=5.0/12.0 #ft
r=5.0 #in
x=1.5 #ft
rpm=1500.0 #rpm
#calculations
A=pi*x*x
N=rpm*4/2
Ihp=Pi*L*A*N/33000.0
#results
print "IHP of cylinder ",round(Ihp,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
r=4.0 #ft
n=300.0 #rpm
F=60.0 #lb
#calculations
Bhp=2*pi*r*F*n/33000
#results
print "Bhp of the engine ",round(Bhp,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
C=1.0/4000.0
F=125.0 #lb
n=3500 #rpm
#calculations
Bhp=F*n*C
#results
print "Bhp of the engine ",round(Bhp,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
r=1.75 #ft
F1=72.0 #lb
F2=24.0 #lb
n=500.0 #rpm
m=1.8 #lb
mi=15.0 #min
Qh=20000.0 #Btu/lb
#calculations
Bhp=2*pi*r*F1*n/33000.0
Fhp=2*pi*r*F2*n/33000.0
Ihp=Bhp+Fhp
Fc=m*60/mi
Bsfc=Fc/Bhp
Isfc=Fc/Ihp
etam=Bhp/Ihp *100
etabt=Bhp*2545/(Fc*Qh)
etait=Ihp*2545/(Fc*Qh)
#results
print "Thermal efficiency in percent",round(etam,3)
print " Brake thermal effficiency in percent",round(etabt*100,3)
print " Indicated thermal effficiency in percent",round(etait*100,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
bore=3.0 #in
stroke=4.0 #in
rpm=3000.0 #rpm
air=110.0 #cu ft per min
#calculations
pdv=bore*bore*pi*stroke*2*bore/4
pde=pdv*rpm /2
req=air*1728
eff=req/pde *100; #efficiency
#results
print "Volumetric efficiency in percent",round(eff,3)
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
x1=11.5 # CO2
x2=4.1 #CO
x3=0.4 #O2
x4=2.3 # H2
x5=0.2 #CH4
x6=81.5 #N2
yc=0.842 #lb of C
yh=0.158 #lb of H2
basis=1
bhp=100
burn=8.9 #gal/hr
sg=0.731
Qh=20750.0 #Btu/lbm
rate=66.0 #gpm
ex=1100.0 #F
air=70.0 #F
cp=0.254
h2=4330.0 #btu/lb
h4=62000.0 #btu/lb
h5=23700.0 #btu/lb
#calculations
c1=x1*44 #mass CO2
c2=x2*28 #mass CO
c3=x3*32 #mass O2
c4=x4*2 #mass H2
c5=x5*16 #mass CH4
c6=x6*28 #mass N2
summ=c1+c2+c3+c4+c5+c6
carbon=x1*12 + x2*12+x5*12
hydrogen=x4*2+x5*4
lbdrygas=summ/carbon *yc
lbfuel=carbon/yc
lbH=lbfuel*yh
lbH2=lbH-hydrogen
lb3=lbH2*9
lbwater=lb3/lbfuel
lbair=lbdrygas+lbwater-basis
bsfc=burn*sg*8.33/bhp
fuelmin=bsfc*bhp/60
energy=2545/bsfc
per1=energy/Qh #energy supplied
Ec=rate*8.33*10
Eclb=Ec/fuelmin
per2=Eclb/Qh #energy absorbed
dryloss=(ex-air)*cp*lbdrygas
per3=dryloss/Qh #energy lost
hv2=h2*c2/lbfuel
hv4=h4*c4/lbfuel
hv5=h5*c5/lbfuel
hv=hv2+hv4+hv5
per4=hv/Qh #energy supplied
eh2=lbwater*(1066+0.5*ex-air)
per5=eh2/Qh #energy supplied
rad=1017
per6=rad/Qh; #energy supplied
#results
print "Air supplied per lb of fuel in lb air per lb fuel",round(lbair,3)
print "Percentage of energy supplied utilized in Btu in percent",round(per1*100,3)
print "Percentage of energy absorbed by coolant in percent",round(per2*100,3)
print "Energy lost in sensible heat in percent",round(per3*100,3)
print "Energy supplied in combustiles in exhaust in percent",round(per4*100,3)
print "Energy supplied in water formed by combustion in percent",round(per5*100,3)
print "Energy supplied unaccounted for in percent",round(per6*100,3)