#initialisation of variables
t2=275 #k
t1=1100 #k
R = 0.287 # kJ/kgK
y = 1.4
qs = 250 # kJ/kgK
pa = 1.01325 # bar
th=393 #k
re=0.14
#CALCULATIONS
eff = 1-t2/t1
from sympy import symbols, solve, log
p1,pb = symbols('p1 pb')
expr = t1/t2-(p1/pa)**((y-1)/y)
p1 = float(solve(expr,p1)[0])
expr2 = qs-R*t1*log(pb/p1)
pb = float(solve(expr2,pb)[0])
va = R*t2/pa
vb = R*t1/pb
mep = qs*eff/(va-vb)
#RESULTS
print "Cycle efficiency = %0.2f \nmean effective pressure = %0.3f bar"%(eff, mep)
#initailisation variables
d=20 #cm
l=25 #cm
cv=1400 #cc
g=1.4
#CALCULATIONS
sv=(22/7*d**2*l)/4
tv=sv+cv
r=tv/cv
e=1-1/(r)**(g-1)
print 'otto efficiency is %.3f'%e
#initialisation of variables
t1=305 #K
t3=1920 #K
r=7
g=1.4
p1=1 #bar
cv=0.718
R=0.287 #kj/kgk
#CALCULATIONS
print "part(a): "
t2=t1*r**(g-1)
p2=p1*r**(g)
print "T2 = %0.f K"%t2
print "P2 = %0.1f bar"%p2
p3=p2*(t3/t2)
print "T3 = %0.f K"%t3
print "P3 = %0.1f bar"%p3
t4=t3*1/r**(g-1)
p4=p3*(1/r)**(g)
print "T4 = %0.f K"%t4
print "P4 = %0.2f bar"%p4
print "part(b) :"
qs=cv*(t3-t2)
print "Heat Supplied, qs = %0.1f kJ/kg/cycle"%qs
qr1=cv*(t4-t1)
print "part(c) :"
print "Heat rejected, qr = %0.1f kJ/kg/cycle"%qr1
wo=qs-qr1
print "part(d) : "
print "Work Output = %0.1f kJ/kg/cycle"%wo
print "part(e) : "
ef=wo/qs
print "Efficiency = %0.3f"%ef
v1=R*t1/p1
v2=v1/r
sv=v1-v2
cl=v2/(v1-v2)
print "part(f) : \nclearance = %0.4f"%cl
mep=wo/sv
print 'part(g) : \nmean effective pressure is %0.3f bar'%mep
#initialisation of variables
r=14
g=1.4
x=1.78 #x=v3/v2
#CALCULATIONS
oef=1-(1/14)**(g-1)
Def=1-((1/(14)**(g)*1.4))*((x**(g) -1)/(x-1))
print 'otto efficiency is %0.3f'%oef
#1.5
from __future__ import division
#initialisation of variables
t1=300 #K
t3=1900 #K
r=15
g=1.4
p1=1 #bar
cp=1.005
cv=0.718
R=0.287 #kj/kgk
#CALCULATIONS
t2=t1*r**(g-1)
p2=p1*r**(g)
p3=p2
t4=t3*0.143**(g-1)
p4=p3*(0.143)**(g)
qs=cp*(t3-t2)
qr1=cv*(t4-t1)
wo=qs-qr1
ef=wo/qs
v1=R*t1/p1/1e2
v2=v1/r
sv=v1-v2
cl=v2/(v1-v2)
v3 = t3/t2*v2
cf = (v3-v2)/(v1-v2)
mep=wo/sv
print "part(a) : \nT2 = %0.f K\nP2 = %0.1f bar\nT4 = %0.f K\nP4 = %0.2f bar"%(t2,p2,t4,p4)
print "part(b) : \nHeat Supplied, qs = %0.2f"%qs
print "part(c) : \nHeat rejected, qr = %0.2f kJ/kg/cycle"%qr1
print "part(d) : \nNet work output = %0.2f kJ/kg/cycle" %wo
print "part(e) : \nEfficiency = %0.4f "%ef
print "part(f) : \nClearance = %0.5f"%cl
print "part(g) : \nCut-off = %0.4f"%cf
print 'part(h) : \nmean effective pressure is %0.f kN/m^2'%mep
#initialisation of variables
t1=300 #temparature in k
r=10 #compression ratio
p1=1 #pressure in bar
g=1.4
p3=40 #pressure in bar
x=0.166 #x=v4/v5=t4/v1=(v4/v2)*(v2/v1)
t4=2000 #temparature in k
p4=40 #pressure in bar
cv=0.718 #calorific value(const volume)
cp=1.005 #calorific value(const preussure)
R=0.287
r=10
#CALCULATIONS
t2=(t1*(r)**(g-1))
p2=(p1*(r)**(g))
t3=t2*(p3/p2)
t5=t4*(x)**(g-1)
p5=p4*(x)**(g)
q23=cv*(t3-t2)
q34=cp*(t4-t3)
q44=cv*(t5-t1)
nwd=q23+q34-q44
ef=nwd/(q23+q34)
v1=(R*t1)/(p1*100)
v2=v1/r
mep=nwd/(v1-v2)
effo=1-(1/(r)**(g-1))
v3=(R*t4)/(p2*100)
cr=v3/v2
effd=1-((1/(r)**(g-1))*(1/g)*((cr)**(g)-1)/(cr-1))
#RESULTS
print '(a) temparature 2,3,5 and pressure 2,5 are %.fk,%.fk,%.fk and %0.f bar,%0.2f bar'%(t2,t3,t5,p2,p5)
print '\n(b) heat supplied at const volume is %.2f kJ/kg/cycle'%q23
print '\n(c) heat supplied at const pressure is %.2f kJ/kg/cycle'%q34
print '\n(d) heat rejected is %.2f kJ/kg/cycle'%q44
print '\n(e) net work output is %.2f'%nwd
print '\n(f) efficiency is %.4f'%ef
print '\n(g) otto efficiency is %0.3f'%effo,
print ' & diesel efficiency is %0.3f'%effd
#initialisation of variables
t1=295 #temparature in k
r=5.25
g=1.4
t3=923 #temparature in k
tc=511 #temparature in k
tt=633 #temparature in k
#CALCULATIONS
t2=t1*(r)**((g-1)/g)
t4=t3/(r)**((g-1)/g)
effb=1-((t4-t1)/(t3-t2))
wt=t3-t4
wc=t2-t1
wr1=(1-(t2-t1)/(t3-t4))
ctwr1=(t2-t1)/(t3-t4)
effc=(t2-t1)/(tc-t1)
efft=(t3-tt)/(t3-t4)
effbr=1-((tt-t1)/(t3-tc))
wr2=1-((tc-t1)/(t3-tt))
ctwr2=(tc-t1)/(t3-tt)
#RESULTS
print 'work ratio and compressed turbine wrok ratio in first part of problem are %.3f and %0.3f'%(wr1,ctwr1)
print '\nwork ratio and compressed turbine wrok ratio in second part of problem are %0.3f and %0.3f'%(wr2,ctwr2)