from math import log
#initialisation of variables
t1=305 #temp in k
r=0.287 #kJ/kg
p2=6 #pressure in bar
p1=1.013 #pressure in bar
g=1.4 #const value
n=1.28
v1=100 #volume
#CALCULATIONS
rp=(p2/p1)
wiso=r*t1*log(p2/p1)
wadia=(g/(g-1))*r*t1*0.6623
wpoly=(n/(n-1))*r*t1*0.4756
m=(p1*v1*100)/(r*t1)
ipr=(wiso*m)/60
apr=(wadia*m)/60
#RESULTS
print 'work for isthermal compression is %0.1f knm/kg'%(wiso)
print '\nwork for adiabatic compression is %0.1f knm/kg'%(wadia)
print '\nwork for polytropic compression is %0.2f knm/kg'%(wpoly)
print '\nmass of air compressed is %0.2f kg/min'%(m)
print '\nisothermal power required is %0.1f kW'%(ipr)
print '\nadiabatic power required is %0.1f kW'%(apr)
from math import ceil
#initialisation of variables
p2=135 #bar pressure
p1=1 #bar pressure
x=5 #x=p2/p1
#CALCULATIONS
s=log(p2)/log(x)
rp=(p2/p1)**0.25
#RESULTS
print 's is %0.3f '%(s)
print 'rp is %0.4f '%(rp)
print 'number of stages are : ',int(ceil(rp))
print '1st intermediate pressure is %0.4f bar abs.'%rp
print '2nd intermediate pressure is %0.3f bar abs.'%(rp**2)
print '3rd intermediate pressure is %0.3f bar abs.'%(rp**3)
#initialisation of variables
p2=3.24 #pressure in bar
p1=1 #pressure in bar
v1=16 #volume in m*m*m
n=1.35
rp=3.24 #pressure
r=10.5
t1=294 #temparature in k
t2=294 #temparature in k
cp=1.005 #kJ/kg
rx=0.287
#CALCULATIONS
w1=(2*n/(n-1))*p1*v1*100*0.35630 #(3.24)**0.2592-1
w2=(n/(n-1))*p1*v1*100*0.8396 #(10.5)**0.2592-1
pr1=w1/60
pr2=w2/60
tb=t1*(r)**(n-1/n)
t3=t2*(rp)**((n-1)/n)
m=(p1*v1*100)/(rx*t1)
hr=m*cp*(t3-t2)
ma=hr/(4.18*25)
#RESULTS
print 'minimum power required are %0.2f kw and %0.1f kw'%(pr1,pr2)
print '\nmass of air compressed is %0.2f kg/min'%(m)
print '\nheat rejected by air compressor is %0.2f kJ/min'%(hr)
print '\nmass of water is %0.2f kg/min'%(ma)
#initialisation of variables
p2=4.08 #pressure in bar
p1=1 #pressure in bar
n=1.22
r=0.287
p=1.01325 #pressure in bar
v=145 #volume
t=288 #temparature in k
p3=17.5 #pressure in bar
t1=307 #temp in k
t2=313 #temp in k
#CALCULATIONS
wlp=5.54*r*t1*(((p2/p1)**((n-1)/n))-1)
whp=5.54*r*t2*(((p2/p1)**((n-1)/n))-1)
w=wlp+whp
m=(p*v)/(r*t)
pr=(w*m)/60
p2=(p1*p3)**0.5
x=(p2)**0.5 #x=d1/d2
#RESULTS
# ans in the book is wrong.
print 'the intercooler pressure = %0.2f bar'%p2
print 'total work required is %0.2f kNm/kg'%(w)
print '\nmass of free air is %0.2f kg/min'%(m)
print '\npower required to drive the compressor is %0.2f kw'%(pr)
print '\nratio of cylinder diameters is %0.3f '%(x)
#initialisation of variables
c1=0.05 #percentage
c2=0.10 #percentage
c3=0.20 #percentage
rp=10
#CALCULATIONS
eff1=(1+c1-c1*(rp)**(0.78125))
eff2=(1+c2-c2*(rp)**(0.78125))
eff3=(1+c3-c3*(rp)**(0.78125))
#RESULTS
print 'volumetric effiency 1 is %0.3f '%(eff1)
print '\nvolumetric effiency 2 is %0.3f '%(eff2)
print '\nvolumetric effiency 3 is %0.f '%abs(eff3)
from __future__ import division
#initialisation of variables
d=0.2 #diameter in m
lc=0.01 #linear clearance
l=0.3 #lenght
rp=7
n=1.25
pi=(22/7)
#CALCULATIONS
cv=((pi/4)*((d)**2)*lc)
sv=((pi/4)*(d)**2*l)
cr=cv/sv
veff=(1+cr-cr*(rp)**(1/n))
x=veff*sv
#RESULTS
# ans in the book is wrong.
print 'clearance ratio is %0.2f '%(cr)
print '\nvolumetric efficiency is %0.3f '%(veff)
print '\nvolume of air taken in is %0.2e m*m*/stroke'%(x)
#initialisation of variables
n=1.2
r=0.287
t1=310 #temparature in degrees
p2=7 #pressure in bar
p1=1 #pressure in bar
#CALCULATIONS
rp=(p2/p1)
wr=((n/(n-1))*r*t1*((rp)**((n-1)/n)-1))
#RESULTS
print 'volumetric efficiency is 0.797'
print 'volumetric efficiency referred to atmospheric conditions is 0.731'
print 'work required is %0.2f kNm/kg'%(wr)
#initialisation of variables
veff=0.8 #efficiency
rp=7
n=1.2 #constant value
pi=(22/7)
#CALCULATIONS
c=(veff-1)/(1-(rp)**(1/n))
vs=2/c
d=((4*vs)/pi)**(1/3)
#RESULTS
print 'stroke volume is %0.2f m*m*m'%(vs)
print '\nlenght of stroke is %0.2f m'%(d) # ans in the book is wrong.
#initialisation of variables
sp=1400 #speed in revolutions per min
ma=15 #mass in kgs
r=0.287
p1=1 #pressure in bar
t1=303 #temparature in k
p2=7 #pressure in bar
c=0.05 #clearance volume/stoke volume
pi=(22/7)
n=1.2
m1=15
meff=0.85 #mechanical efficinecy
#CALCULATIONS
rp=(p2/p1)
m=ma/sp
va=(m1*r*t1)/(p1*100)
eff1=(1+c-c*(rp)**(1/n))
vs=va/eff1
d1=((4*vs)/pi)**(1/3)
pr=((n/(n-1))*m1*r*t1*((rp)**((n-1)/n)-1))/60
prs=pr/meff
d2=((prs*4)/(7*100*pi*700))**0.333
#RESULTS
print 'volumetric efficiency is %0.3f '%(eff1)
print '\nlengh of the stroke is %0.2f m'%(d1)
print '\nindicated power is %0.2f kw'%(pr)
print '\npower required at the shaft of the compressor is %0.2f kw'%(prs)
print '\ndiameter of the piston is %0.2f m'%(d2)
# ans in the book is wrong.
#initialisation of variables
sp=200 #mean speed m/s
#CALCULATIONS
d=(21/(0.7773*1.18*200))**0.5
l=1.5*d
s=200/(3*d)
#RESULTS
print 'volumetric efficiency is 0.7773'
print '\ndiameter is %0.4f m'%(d)
print '\nstroke is %0.4f m'%(l)
print '\nspeed of compressor is %0.f rev/min'%(s)
#initialisation of variables
r=0.287
p=1.01325 #pressure in bar
v=5 #volume in m*m*m
t=288 #temparature in k
t1=303 #temparature in k
t2=403 #temparature in k
p2=4.08 #pressure in bar
p1=0.98 #pressure in bar
p3=17 #pressure in bar
n=1.25
c=0.06 #clearance volume by swept volume
#CALCULATIONS
m=(p*v)/(r*t)
rp=p2/p1
t2s=(t1*(p2/p1)**((n-1)/n))
wr=(n/n-1)*r*(t2-t1)
wc=2*wr
veff=(1+c-c*(rp)**(1/n))
x=(p*100*v*t1)/(p1*100*t) #x=(v1-v4)
vs=x/veff
vsc=vs/125
d1=((4*vsc)/pi)**(1/3)
#RESULTS
print 'volumetric efficiency is %0.3f '%(veff)
print '\nstoke volume is %0.3f m*m*m/min'%(vs)
print '\nstroke volume per cycle is %0.4f m*m*m'%(vsc)
print '\nstoke of piston is %0.3f '%(d1)
#initialisation of variables
t1=303 #temparature in k
p2=4.08 #pressure in bar
p1=1 #pressure in bar
t5=303 #temparature in k
x=0.3247 #x=v2/v1 where the relation is v2=v1*(1/rp)**1/n
y=0.0385 #y=v3/v1
vo=0.2862 #vo=volume of air delivered/v1
vf=0.8299 #vf=vome of free air /v1
n=1.25
p3=17.5 #pressure in bar
r=0.287
tatm=2911 #temp in k
patm=1.02 #pressure in bar
w=291
#CALCULATIONS
t2=(t1*(p2/p1)**((n-1)/n))
veff=vf/(1-y)
a=(r*(t2-t1)*5)
t3=(t1*(p3/p2)**((n-1)/n))
hp=(5*r*(t3-t1))
iso=(r*tatm*log(p3/patm))/10 #its ln
ieff=iso/w
#RESULTS
print 'volumetric efficiency is %0.3f '%(veff)
print '\nwork required for lp cyclinder is %0.2f '%(a)
print '\nwork required for hp cyclinder is %0.2f '%(hp)
print '\nwork required for isothermal is %0.2f '%(iso)
print '\nisothermal efficiency is %0.3f '%(ieff)
#initialisation of variables
p2=1.5 #pressure in bar
p1=1 #pressure in bar
v=0.05 #volume in m*m*m
g=1.4
r=1.4
n=120 #number of cycles
#CALCULATIONS
wa=v*(p2-p1)*100
wi=3.5*100*p1*v*(((p2/p1)**((r-1)/r))-1)
reff=wi/wa
vo=v/4
pr=wa*n/60
#RESULTS
print 'roots efficiency is %0.2f '%(reff)
print '\nvolume of air is %0.4f m*m*m/cycle'%(vo)
print '\npower required is %0.2f kw'%(pr)
#initialisation of variables
p2=1.5 #pressure in bar
p1=1 #pressure in bar
v=0.05 #volume in m*m*m
x=0.35 #increse in pressure
g=1.4
r=1.4
n=120 #number of cycles
#CALCULATIONS
wa=v*(p2-p1)*100
wi1=3.5*100*p1*v*(((p2/p1)**((r-1)/r))-1)
ceff=wi1/wa
vo=v/4
pr=wa*n/60
prs=x*(p2-p1)
p3=p1+prs
wi2=3.5*100*p1*v*(((p3/p1)**((r-1)/r))-1)
vi=v*(p1/p3)**(1/g)
w2=vi*(p2-p3)*100
tw=w2+wi2
comeff=wi1/tw
po=tw*2
#RESULTS
print 'compressor efficiency is %0.2f '%(ceff)
print '\nwork required for internal compression is %0.3f knm/rev'%(wi2)
print '\npower required is %0.2f kW'%(pr)
print '\ncompressor efficiency 2 is %0.3f '%(comeff)
print '\npower required 2 is %0.3f kW'%(po)
#initialisation of variables
t1=295 #temp in k
p1=1.02 #pressure in bar
p2=7.14 #pressure in bar
cp=1.005 #kJ/kg
g=1.4
wr=250 #kJ/kg
#CALCULATIONS
t2s=t1*(p2/p1)**((g-1)/g)
wi=cp*(t2s-t1)
ieff=wi/wr
t2=(wr/cp)+t1
#RESULTS
print 'isentropic work is %0.2f kJ/kg'%(wi)
print '\nisentropic efficiency is %0.3f '%(ieff)
print '\ntemparature 2 is %0.2f k'%(t2)
print 'index of compression is 1.46'
#initialisation of variables
t1=310 #temp in k
p1=1 #pressure in bar
p2=4 #pressure in bar
cp=1.005 #kJ/kg
v1=28 #m*m*m volume
r=0.287
ce=0.7 #copression efficiency
g= 1.4 #ft/sec**2
#CALCULATIONS
t2s=t1*(p2/p1)**((g-1)/g)
wi=cp*(t2s-t1)
m=(p1*v1*100)/(r*t1)
apr=(m*wi)/60
iei=wi/ce
#RESULTS
print 'isentropic work is %0.2f '%(apr)
print '\nadiabatic power required is %0.2f '%(m)
print '\nindicated enthalpy increase is %0.2f '%(iei)
from math import sin
#initialisation of variables
p2=6 #prressure in bar
p1=1 #pressure in bar
t1=313 #temp in k
a1=45 #angle in degrees
a2=10 #angle in degrees
a3=55 #angle in degrees
r=1.4
cp=1.005 #kJ/kg
ieff=0.85 #isentropic efficiency
c=200 #m/s
#CALCULATIONS
t2s=(t1*(p2/p1)**((r-1)/r))
t2=(((t2s-t1)/ieff)+t1)
w=cp*(t2-t1)
cro=(c*(sin(45*(pi/180))/sin(55*(pi/180))))
cv=c-cro
n=w/cv
#RESULTS
print 'actual work is %0.2f kJ/kg'%(w)
print '\nchange in whirl velocities is %0.2f kJ/kg/stage'%(cv)
print '\nnumber of stages is %0.f stages'%(n)