#pg 1.29
#calculate the pressure and temperature in all cases
import math
#Input data
V1=0.5;#Initial Volume before the commencement of compression in m**3
P1=1.;#Initial pressure before the commencement of compression in bar
T1=300.;#Initial temperature in K
P2=12.;#Final pressure at the end of compression stroke in bar
Q=220.;#Heat added during the constant volume process in kJ
r=1.4;#Isentropic constant for air
R=0.287;#Characteristic Gas constant in kJ/kg K
Cv=0.718;#Specific heat of mixture in kJ/kg K
#Calculations
r1=(P2/P1)**(1/r);#Compression ratio
T2=T1*(r1)**(r-1);#Final temperature after the end of compression stroke in K
V2=(P1*T2*V1)/(P2*T1);#Final volume after the end of compression stroke in m**3
m=(P1*10**5*V1)/(R*T1*1000);#Mass of air flowing in kg
T3=(Q/(m*Cv))+T2;#Temperature after constant volume heat addition in K
P3=(P2*T3)/T2;#Pressure after constant volume heat addition in K
V3=V2;#Volume at 3
P4=P3*(1/r1)**(r);#Pressure after isentropic expansion in bar
V4=V1;#Volume after isentropic expansion in m**3
T4=T3*(1/r1)**(r-1);#Temperature at the end of isentropic expansion in K
#Output
print '(a)The pressures at 1 is (bar) = ',round(P1,2)
print '(b)The pressures at 2 is (bar) = ',round(P2,2)
print '(c)The pressures at 3 is (bar) = ',round(P3,2)
print '(d)The pressures at 4 is (bar) = ',round(P4,2)
print '(e)Temperature at 1 is (K) = ',round(T1,2)
print '(f)Temperature at 2 is (K) = ',round(T2,1)
print '(g)Temperature at 3 is (K) = ',round(T3,0)
print '(h)Temperature at 4 is (K) = ',round(T4,0)
print '(i)Volume at 1 is (m^3) = ',round(V1,2)
print '(j)Volume at 1 is (m^3) = ',round(V2,5)
print '(h)Volume at 1 is (m^3) = ',round(V3,5)
print '(k)Volume at 1 is (m^3) = ',round(V4,2)
#pg 1.31
#calculate the increase in efficiency
#Input data
r1=6.;#Initial compression ratio
r2=7.;#Final compression ratio
r=1.4;#Isentropic coefficient of air
#Calculations
nr1=(1-(1/r1)**(r-1))*100;#Otto cycle efficiency when compression ratio is 6 in percentage
nr2=(1-(1/r2)**(r-1))*100;#Otto cycle efficiency when compression ratio is 7 in percentage
n=nr2-nr1;#Increase in efficiency in percentage
#Output
print 'The increase in efficiency due to change in compression ratio from 6 to 7 is (percent) = ',round(n,1)
#pg 1.31
#calculate the compression ratio and Efficiency of Otto cycle
#Input data
T1=315.;#Temperature at the beginning of isentropic compression in K
T2=600.;#Temperature at the end of isentropic compression in K
r=1.4;#Isentropic constant of air
#Calculations
r1=(T2/T1)**(1/(r-1));#Compression ratio
n=(1-(1/r1**(r-1)))*100;#Efficiency of Otto cycle in percent
#Output
print '(a)The compression ratio is ',round(r1,3),'\n(b)Efficiency of the Otto cycle is (percent) = ',n
#pg 1.32
#calculate the standard efficiency of air
#Input data
D=0.1;#Diameter of the cylinder in m
L=0.15;#Stroke length in m
Vc=0.295*10**-3;#Clearance volume in m**3
r=1.4;#Isentropic constant of air
#Calculations
Vs=(3.14/4)*(D**2*L);#Swept volume in m**3
r1=(Vc+Vs)/Vc;#Compression ratio
n=(1-(1/r1)**(r-1))*100.;#Otto cycle efficiency in percentage
#Output
print 'The air standard efficiency of air is (percent) = ',round(n,2)
#pg 1.33
#calculate the compression ratio, standard air efficiency and Mean effective pressure
#Input data
P1=1.;#Initial pressure of air in bar
T1=300.;#Initial temperature in K
P2=17.;#Pressure at the end of isentropic compression in bar
P3=40.;#Pressure at the end of constant volume heat addition in bar
Cv=0.717;#Specific heat of mixture in kJ/kg K
M=28.97;#Molecular weight in kg
Ru=8.314;#Universial gas constant in kJ/kg mole K
m=1.;#Mass from which heat is extracted in kg
W=363.;#Work done in kN m
#Calculations
Rc=Ru/M;#Characteristic gas constant in kJ/kg K
Cp=Rc+Cv;#Specific heat at constant pressure in kJ/kg K
r=Cp/Cv;#Isentropic gas constant
r1=(P2/P1)**(1/r);#Compression ratio
na=(1-(1/r1)**(r-1))*100;#Air standard efficiency in percentage
T2=T1*(P2/P1)**((r-1)/r);#Temperature at the end of isentropic compression process in K
T3=(P3/P2)*T2;#Temperature at the end of constant volume heat addition in K
Q=m*Cv*(T3-T2);#Heat supplied in kJ/kg
V1=(m*Rc*T1*1000)/(P1*10**5);#Initial volume before compression in m**3
V2=V1/r1;#Volume at the end of compression stroke in m**3
Vs=V1-V2;#Stroke volume in m**3
MEP=(W/Vs)/100;#Mean effective pressure in bar
#Output
print '(a)Compression ratio is',round(r1,2)
print '(b)The air standard efficiency is (percent) = ',round(na,1)
print '(c)Mean effective pressure is (bar) = ',round(MEP,2)
#pg 1.34
#calculate the clearance volume, compression ratio, standard efficiency, work done
#Input data
V1=0.6;#Initial volume of an engine working on otto cycle in m**3
P1=1.;#Initial pressure in bar
T1=308.;#Initial temperature in K
P2=10.;#Pressure at the end of compression stroke in bar
Q=210.;#Heat added during constant heat process in kJ
r=1.4;#Isentropic constant of air
#Calculations
r1=(P2/P1)**(1/r);#Compression ratio
V2=V1/r1;#Clearance volume in m**3
C=(V2/(V1-V2))*100;#Percentage clearance in percent
na=(1-(1/r1)**(r-1))*100;#Air standard efficiency in percent
W=Q*(na/100);#Work done per cycle in kJ
#Output
print '(a)Clearance volume as percentage of stroke volume is (percent) = ',round(C,2)
print '(b)Compression ratio is = ',round(r1,2)
print '(c)Air standard efficiency is (percent) = ',round(na,1)
print '(d)Work done per cycle is (kJ) = ',round(W,2)
#pg 1.36
#calculate the Ideal power
#Input data
r=5.5;#Compression ratio of an engine working on the otto cycle
Q=250.;#Heat supplied during constant volume in kJ
N=500.;#Engine operating speed in rpm
r1=1.4;#Isentropic ratio
#Calculations
n=(1-(1/r)**(r1-1))*100;#Otto cycle efficiency in percent
W=Q*(n/100);#Work done per cycle in kJ
P=W*(N/60);#Work done per second i.e., Power developed in kJ/s or kW
#Output data
print 'Ideal power developed by the engine is (kW) = ',round(P,0)
#pg 1.36
#calculate the Mean effective pressure
#Input data
V1=0.53;#Volume of cylinder of an engine working on Otto cycle in m**3
V2=0.1;#Clearance volume in m**3
Q=210.;#Heat supplied during constant volume in kJ
r=1.4;#Isentropic ratio
#Calculations
r1=V1/V2;#Compression ratio
n=(1-(1/r1)**(r-1))*100;#Otto cycle efficiency in percentage
W=Q*(n/100);#Work done per cycle in kJ
P=W/((V1-V2)*100);#Mean effective pressure in bar
#Output data
print 'Mean effective pressure is (bar) = ',round(P,3)
#pg 1.38
#calculate the Maximum power
#Input data
T3=1500.;#Upper temperature limit of a otto cycle in K
T1=300.;#Lower temperature limit in K
a=0.4;#Rate of flow of air through the cycle in kg/min
Cv=0.718;#
#Calculations
T2=(T1*T3)**(1./2);#Temperature at point 2 in K
T4=T2;#Temperature at point 4 in K
W=Cv*((T3-T2)-(T4-T1));#Work done per cycle in kJ/kg
P=W*(a/60);#Maximum power developed by the engine in kW
#Output
print 'Maximum power developed by the engine is (kW) = ',round(P,3)
#pg 1.39
#calculate the Thermal efficiency in all cases
#Input data
r=1.4;#Air standard ratio
p1=1.25;#Cut off ratio 1
p2=1.50;#Cut off ratio 2
p3=2.00;#Cut off ratio 3
rc=16;#Compression ratio
#Calculations
n1=(1-((1/rc**(r-1)*(p1**r-1)/(r*(p1-1)))))*100;#Thermal efficiency of the diesel cycle for cut off ratio 1.25
n2=(1-((1/rc**(r-1)*(p2**r-1)/(r*(p2-1)))))*100;#Thermal efficiency of the diesel cycle for cut off ratio 1.50
n3=(1-((1/rc**(r-1)*(p3**r-1)/(r*(p3-1)))))*100;#Thermal efficiency of the diesel cycle for cut off ratio 2.00
#Output
print '(a)Thermal efficiency when cut off ratio is 1.25 is (percent) = ',round(n1,1)
print '(b)Thermal efficiency when cut off ratio is 1.50 is (percent) = ',round(n2,1)
print '(c)Thermal efficiency when cut off ratio is 2.00 is (percent) = ',round(n3,1)
#pg 1.40
#calculate the Air standard efficiency
r=15.;#Compression ratio of a diesel engine
Q=5.;#Heat supplied upto 5 percent of the stroke
r1=1.4;#Isentropic ratio
#Calculations
p=1+(Q/100)*(r-1);#Cut off ratio
n=(1-((1/r**(r1-1)*(p**r1-1)/(r1*(p-1)))))*100;#Efficiency of diesel cycle in percent
#Output
print 'Air standard efficiency of the diesel cycle is (percent) = ',round(n,2)
#pg 1.40
#calculate the air standard efficiency
#Input data
r=17.;#Compression ratio of a diesel engine
e=13.5;#Expansion ratio
r1=1.4;#Isentropic ratio
#Calculations
p=r/e;#Cut off ratio
n=(1-((1/r**(r1-1)*(p**r1-1)/(r1*(p-1)))))*100;#Air standard efficiency in percent
#Output
print 'Air standard efficiency is (percent) = ',round(n,1)
#pg 1.41
#calculate the compression ratio, cut off ratio and Ideal efficiency
#Input data
T1=300.;#Temperature at the beggining of compression stroke in K
T2=873.;#Temperature at the end of compression stroke in K
T3=2173.;#Temperature at the beggining of expansion stroke in K
T4=1123.;#Temperature at the end of expansion stroke in K
r1=1.4;#Isentropic ratio
#Calculations
r=(T2/T1)**(1/(r1-1));#Compression ratio
rho=T3/T2;#Cut off ratio
n=(1-((1/r1)*((T4-T1)/(T3-T2))))*100;#Efficiency of diesel cycle in percent
#Output data
print '(a)Compression ratio = ',round(r,2)
print '(b)Cut off ratio = ',round(rho,2)
print '(c)Ideal efficiency of the diesel cycle is (percent) = ',round(n,2)
#pg 1.42
#calculate the pressure at all points
#Input data
r=18.;#Compression ratio of diesel cycle
Q=2000.;#Heat added in kJ/kg
T1=300.;#Lowest temperature in the cycle in K
p1=1.;#Lowest pressure in the cycle in bar
Cp=1.;#Specific heat of air at constant pressure in kJ/kg K
Cv=0.714;#Specific heat of air at constant volume in kJ/kg K
#Calculations
r1=Cp/Cv;#Isentropic ratio
v1=((1-Cv)*T1)/(p1*10**5);#Initial volume at point 1 in the graph in m**3/kg
v2=v1/r;#Volume at point 2 in m**3/kg
p2=p1*(v1/v2)**(r1);#Pressure at point 2 in bar
T2=T1*(v1/v2)**(r1-1);#Temperature at point 2 in K
T3=(Q/Cp)+T2;#Temperature at point 3 in K
v3=v2*(T3/T2);#Volume at point 3 in K
v4=v1;#Since Constant volume heat rejection in m**3/kg
T4=T3/(v4/v3)**(r1-1);#Temperature at point 4 in K for isentropic expansion
p4=p1*(T4/T1);#Pressure at point 4 in bar
#Output
print '(a)Pressure at point 1 in the cycle is (bar) = ',p1
print '(b)Pressure at point 2 & 3 is (bar) = ',round(p2,1)
print '(c)Pressure at point 4 is (bar) = ',round(p4,2)
print '(d)Temperature at point 1 is (K) = ',T1
print '(e)Temperature at point 2 is (K0 = ',round(T2,0)
print '(f)Temperature at point 3 is (K) = ',round(T3,0)
print '(g)Temperature at point 4 is (K) = ',round(T4,0)
#pg 1.43
#calculate the Thermal efficiency and Power developed
#Input data
r=16.;#Compression ratio for the air standard diesel cycle
Q1=2200.;#Heat added in kJ/kg
T4=1500.;#Temperature at the end of isentropic expansion in K
T1=310.;#Lowest temperature in the cycle in K
m=0.3;#Air flow rate in kg/sec
Cv=0.714;#Specific heat at constant volume in kJ/kg K
#Calculations
Q2=Cv*(T4-T1);#Heat rejected in kJ/kg
n=((Q1-Q2)/Q1)*100;#Efficiency in percent
P=m*(Q1-Q2);#Power developed in kW
#Output
print '(a)Thermal efficiency is (percent) =',round(n,2)
print '(b)Power developed is (kW) = ',round(P,0)
#pg 1.44
#calculate the air standard efficiency of the cycle
#Input data
T1=303;#Temperature at the beginning of compression in K
T2=823;#Temperature at the end of compression in K
T3=3123;#Temperature at the end of heat addition in K
T4=1723;#Temperature at the end of isentropic expansion in K
r=1.4;#Isentropic ratio
#Calculations
n=(1-((T4-T1)/(r*(T3-T2))))*100;#Efficiency of the cycle in percent
#Output
print 'Air standard efficiency of the cycle is (percent) = ',round(n,1)
#pg 1.45
#calculate the Mean effective pressure
#Input data
r=15.;#Compression Ratio of a diesel engine
P1=1.;#Operating Pressure of a diesel engine in bar
r1=1.4;#Isentropic constant
V1=15.;#Volume at the start of compression stroke in m**3
V3=1.8;#Volume at the end of constant Pressure heat addition in m**3
V2=1.;#Volume at the end of isentropic compression stroke in m**3
#Calculations
Vs=V1-V2;#Swept volume in m**3
V4=V1;#Volume at the end of Isentropic expansion stroke in m**3
P2=P1*(r)**r1;#Pressure at the end of Isentropic compression of air
P3=P2;#Pressure at the end of constant pressure heat addition in bar
P4=P3*(V3/V4)**r1;#Pressure at the end of Isentropic expansion stroke in bar
Pm=(V2/Vs)*(P2*((V3/V2)-1)+(P3*(V3/V2)-P4*(V4/V2))/(r1-1)-(P2-P1*(V1/V2))/(r1-1));#Mean effective pressure in bar
#Output
print 'Mean effective pressure of the cycle is (bar) = ',round(Pm,2)
#pg 1.46
#calculate the compression ratio and air standard efficiency
#Input data
P1=1.5;#Pressure at the 7/8th stroke of compression in bar
P2=16;#Pressure at the 1/8th stroke of compression in bar
n=1.4;#Polytropic index
c=8.;#Cutoff occurs at 8% of the stroke in percentage
#Calculations
R1=(P2/P1)**(1./n);#Ratio of volumes
R2=(R1-1.)/((7./8)-(R1/8.));#Ratio of stroke volume to the clearance volume
r=1.+R2;#Compression ratio
rho=1+((c/100.)*r);#Cut off ratio
na=(1-((1./r**(n-1))*(((rho**n)-1.)/(n*(rho-1)))))*100;#Air standard efficiency in percentage
#Output
print '(a)Compression ratio of the engine = ',round(r,3)
print '(b)Air standard efficiency is (percent) = ',round(na,2)
print 'The answers are a bit different due to rounding off error in textbook'
#pg 1.47
#calculate the loss in efficiency
#Input data
r=16.;#Compression ratio of diesel engine
r1=1.4;#Isentropic ratio
#Calculations
rho1=1+(r-1)*(6./100);#Cutoff ratio at 6% of stroke
rho2=1+(r-1)*(9./100);#Cutoff ratio at 9% of stroke
n1=(1-(1/r**(r1-1))*(1/r1)*(rho1**r1-1)/(rho1-1))*100;#Efficiency of the cycle at 6% of the stroke in percent
n2=(1-(1/r**(r1-1))*(1/r1)*(rho2**r1-1)/(rho2-1))*100;#Efficiency of the cycle at 9% of the stroke in percent
L=n1-n2;#The loss in efficiency in percent
#Output
print 'The loss in efficiency is (percent) = ',round(L,2)
#pg 1.48
#calculate the compression ratio, temperature in all cases
#Input data
P1=1.03;#Pressure at the beginning of compression stroke in bar
T1=303.;#Initial temperature in K
P2=40.;#Maximum pressure in the cycle in bar
Q=550.;#The heat supplied during the cycle in kJ/kg
r=1.4;#Isentropic compression ratio
Cp=1.004;#Specific heat at constant pressure in kJ/kg K
#Calculations
r1=(P2/P1)**(1/r);#Compression ratio
T2=(P2/P1)**((r-1)/r)*T1;#Temperature at the end of compression stroke in K
T3=(Q/Cp)+T2;#Temperature at the end of heat addition in K
rho=T3/T2;#Cut off ratio
n=(1-(1/r1**(r-1))*(1/r)*(rho**r-1)/(rho-1))*100;#Air standard efficiency in percentage
#Output\n
print '(a)Compression ratio =',round(r1,2)
print '(b)Temperature at the end of compression is (K) =',round(T2,0)
print '(c)Temperature at the end of comstant pressure heat addition is (K) = ',round(T3,0)
print '(d)Air standard efficiency is (percent) = ',round(n,2)
#pg 1.50
#calculate the air standard efficiency
#Input data
r=12.;#Compression ratio of an oil engine, working on the combustion cycle
r1=1.4;#Isentropic ratio
P1=1.;#Pressure at the beginning of compression
P3=35.;#Pressure at the end of constant volume heat addition in bar
#Calculations
rho=1+(1/10.)*(r-1);#Cut off ratio at 1/10th of the stroke
P2=P1*(r)**r1;#Pressure at the end of isentropic compression in bar
a=P3/P2;#Pressure ratio
n=(1-(1/r**(r1-1))*(a*rho**r1-1)/((a-1)+(r1*a*(rho-1))))*100;#Air standard efficiency in percent
#Output
print 'The air standard efficiency of an oil engine working on the combustion cycle is (percent) = ',round(n,2)
#pg 1.51
#calculate the temperature and cut off ratio
#Input data
P1=1.;#Pressure at the beginning of compression stroke of an oil engine working on a air standard dual cycle in bar
T1=303.;#Temperature at the beginning of compression stroke in K
P3=40.;#The maximum pressure reached in bar
T4=1673.;#Maximum temperature reached in K
Cp=1.004;#Specific heat at constant pressure in kJ/kg K
Cv=0.717;#Specific heat at constant volume in kJ/kg K
r1=10.;#Compression ratio
#Calculations
P4=P3;#Pressure at the start of constant pressure heat addition in bar
r=Cp/Cv;#Isentropic ratio
T2=T1*r1**(r-1);#Temperature at the end of compression stroke in K
P2=P1*r1**r;#Pressure at the end of compression stroke in bar
T3=T2*(P3/P2);#Temperature at the end of constant volume heat addition in K
rho=T4/T3;#Cut off ratio
#Output
print '(a)Temperature at the end of constant volume heat addition is (C) = ',T3-273.15
print '(b)Cut off ratio = ',round(rho,2)
print 'The answer for cut off ratio is wrong in textbook. It doesnt convert C to kelvins'
#pg 1.52
#calculate the work done and cycle efficiency
#Input data
P1=1.;#pressure at the beginning of compression stroke in bar
T1=298.;#Temperature at the beginning of compression stroke in K
P3=38.;#Pressure at the end of constant volume heat addition in bar
T4=1573.;#Temperature at the end of constant volume heat addition in K
r=9.5;#Compression ratio
Cp=1.004;#Specific heat of air at constant pressure
Cv=0.717;#Specific heat of air at constant volume
#Calculations
r1=Cp/Cv;#Isentropic ratio
T2=T1*r**(r1-1);#Temperature at the end of compression stroke in K
P2=P1*r**r1;#Pressure at the end of compression stroke in bar
T3=T2*(P3/P2);#Temperature at the end of constant volume heat addition in K
rho=T4/T3;#Cut off ratio
T5=T4*(rho/r)**(r1-1);#Temperature at the end of expansion stroke in K
Qs=Cv*(T3-T2)+Cp*(T4-T3);#Heat supplied per kg in kJ
Qr=Cv*(T5-T1);#Heat rejected per kg in kJ
W=Qs-Qr;#Work done per kg of air in kJ
n=(W/Qs)*100;#Efficiency of the air standard dual cycle in percent
#Output
print '(a)The work done per kg of air is (kJ) = ',round(W,1)
print '(b)Cycle efficiency is (percent) = ',round(n,2)
print 'The answers are a bit different due to rounding off error in textbook'
#pg 1.53
#calculate the pressure, Temperature in all cases and Efficiency
#Input data
r=10.5;#Compression ratio
P3=65.;#Maximum pressure in bar
qs=1650.;#Heat supplied in kJ/kg
P1=1.;#Pressure at the beginning of compression stroke in bar
T1=368.;#Temperature at the beginning of compression stroke in K
Cp=1.004;#Specific heat of air at constant pressure in kJ/kg K
Cv=0.717;#Specific heat of air at constant volume in kJ/kg K
#Calculations
P4=P3;#Pressure at the end of constant volume heat addition in bar
r1=Cp/Cv;#Compression ratio
P2=P1*r**r1;#Pressure at the end of compression stroke in bar
T2=T1*r**(r1-1);#Temperature at the end of compression stroke in K
T3=T2*(P3/P2);#Temperature at the end of constant volume heat addition in K
qv=Cv*(T3-T2);#Heat supplied at constant volume in kJ/kg
qp=qs-qv;#Heat supplied at constant pressure in kJ/kg
T4=(qp/Cp)+T3;#Temperature at the end of constant volume heat addition in K
rho=T4/T3;#Cut off ratio
T5=T4*(rho/r)**(r1-1);#Temperature at the end of expansion stroke in K
P5=P4*(rho/r)**r1;#Pressure at the end of expansion stroke in K
q=Cv*(T5-T1);#Heat rejected in kJ/kg
n=((qs-q)/qs)*100;#Efficiency of the cycle in percent
#Output
print '(a)Pressure at the end of compression stroke is (bar) = ',round(P2,1)
print '(b)Temperature at the end of compression stroke is (K) = ',round(T2,1)
print '(c)Temperature at the end of constant volume heat addition is (K) = ',round(T3,2)
print '(d)Temperature at the end of constant pressure heat addition is (K) = ',round(T4,2)
print '(e)Temperature at the end of expansion stroke is (K) = ',round(T5,2)
print '(e)Pressure at the end of expansion stroke is (bar) = ',round(P5,2)
print '(f)Efficiency of the cycle is (percent) = ',round(n,2)
#pg 1.55
#calculate the standard efficiency
#Input data
r=8.5;#Compression ratio
e=5.5;#Expansion ratio
P1=1;#Pressure at the beginning of compression stroke in bar
T1=313.;#Temperature at the beginning of compression stroke in K
n=1.3;#polytropic constant
Cp=1.004;#Specific heat of air at constant pressure in kJ/kg K
Cv=0.717;#Specific heat of air at constant volume in kJ/kg K
#Calculations
rho=r/e;#Cut off ratio
T2=T1*r**(n-1);#Temperature at the end of compression stroke in K
T3=(2*Cv*T2)/(2*Cv-Cp*rho+1);#Temperature at the end of constant volume heat addition in K
T4=rho*T3;#Temperature at the end of constant pressure heat addition in K
a=T3/T2;#Pressure ratio i.e.,P3/P2
n1=(1-(1/r**(n-1))*(a*rho**n-1)/((a-1)+(n*a*(rho-1))))*100;#Air standard efficiency in percent
#Output
print 'The air standard efficiency is (percent) = ',round(n1,2)
#pg 1.56
#calculate the ideal thermal efficiency
#Input data
P1=1;#Initial pressure in a compression engine working on a dual combustion engine in bar
T1=300.;#Initial Temperature in K
P2=25.;#Pressure at the end of compression stroke in bar
Q=400.;#Heat supplied per kg of air during constant volume heating in kJ/kg
P5=2.6;#Pressure at the end of isentropic expansion in bar
Cp=1.005;#Specific heat of air at constant pressure in kJ/kg K
Cv=0.715;#Specific heat of air at constant volume in kJ/kg K
#Calculations
r=Cp/Cv;#Isentropic index
r1=(P2/P1)**(1/r);#Compression ratio
T2=T1*(r1)**(r-1);#Temperature at the end of compression stroke in K
T3=(Q/Cv)+T2;#Temperature at the end of constant volume heat addition in K
a=T3/T2;#Pressure ratio
P3=a*P2;#Pressure ratio at the end of constant volume heat addition in bar
P4=P3;#Pressure at the end of constant pressure heat addition in bar
x=(P5/P4)**(1/r);#Ratio of volume at the end of constant pressure heat addition to the volume at the end of isentropic expansion
rho=x*(r1);#Cut off ratio
n=(1-(1/r1**(r-1))*(a*rho**r-1)/((a-1)+(r*a*(rho-1))))*100;#Air standard efficiency in percent of a dual combustion engine
#Output
print 'The ideal thermal efficiency is (percent) = ',round(n,2)
#pg 1.58
#calculate the temperature in all cases
#Input data
P1=1.;#Initial pressure of an enfine working on a dual combustion cycle in bar
T1=318.;#Initial temperature before compression in K
r1=14.;#Compression ratio
r=1.4;#Isentropic index
a=2.;#Pressure ratio in the compression process
rho=2.;#Cut off ratio
#Calculations
T2=T1*r1**(r-1);#Temperature at the end of compression stroke in K
T3=T2*a;#Temperature at the end of constant volume heat addition in K
T4=rho*T3;#Temperature at the end of constant pressure heat addition in K
T5=T4*(rho/r1)**(r-1);#Temperature at the end of isentropic compression in K
n=(1-((T5-T1)/(r*(T4-T3)+(T3-T2))))*100;#Efficiency of an engine working on a dual combustion cycle in percent
#Output
print '(a)Temperature at the end of compression stroke is (K) = ',round(T2,0)
print '(b)Temperature at the end of constant volume heat addition is (K) = ',round(T3,0)
print '(c)Temperature at the end of constant pressure heat addition is (K) = ',round(T4,0)
print '(d)Temperature at the end of isentropic expansion process is (K) = ',round(T5,0)
print '(e)Efficiency of the cycle is (percent) = ',round(n,2)
#pg 1.59
#calculate the pressure ratio, cut off ratio, heat supplied, heat rejected, Work done, Thermal efficiency, Mass of air, Mean effective pressure
#Input data
r=15.;#Compression ratio
Vs=0.01;#Stroke volume in m**3
P1=1.;#Initial pressure in bar
T1=310.;#Initial temperature in K
P3=65.;#Pressure in constant pressure heat addition stroke in bar
Cp=1.;#Specific heat of air at constant pressure in kJ/kg K
Cv=0.714;#Specific heat of air at constant volume in kJ/kg K
R=287.;#Molar gas constant
#Calculations
r1=Cp/Cv;#Isentropic index
P2=P1*(r)**r1;#Pressure at the end of compression stroke in bar
a=P3/P2;#Pressure ratio
rho=1+((5./100)*(r-1))
V2=Vs/(r-1);#Volume at the end of compression stroke in m**3
V1=Vs+V2;#Initial volume in m**3
m=P1*10**5*V1/(R*T1);#Mass of air contained in the cylinder in kg
T2=T1*r**(r1-1);#Temperature at the end of compression stroke in K
a=P3/P2;#Pressure ratio
T3=T2*a;#Temperature at the end of constant volume heat addition in K
T4=T3*rho;#Temperature at the end of constant pressure heat addition in K
T5=T4/(r/rho)**(r1-1);#Temperature at the end of isentropic expansion in K
Qs=(Cv*(T3-T2)+Cp*(T4-T3))*m;#Heat supplied in kJ
Qr=m*Cv*(T5-T1);#Heat rejected in kJ
W=Qs-Qr;#Work done per cycle in kJ
n=(W/Qs)*100;#Efficiency of the cycle in percent
Mep=(W/Vs)/100;#Mean effective pressure in bar
#Output
print '(1)Pressure ratio = ',round(a,3)
print '(2)Cut off ratio = ',rho
print '(3)Heat supplied per cycle is (kJ) = ',round(Qs,0)
print '(4)Heat rejected per cycle is (kJ) = ',round(Qr,2)
print '(5)Work done per cycle is (kJ) = ',round(W,2)
print '(6)Thermal efficiency of the cycle is (percent) = ',round(n,0)
print '(7)Mass of air contained in the cylinder is (kg) = ',round(m,5)
print '(8)Mean effective pressure is (bar) = ',round(Mep,2)
#pg 1.62
#calculate the Thermal efficiency
#Input data
P1=1.;#Initial pressure of air received by gas turbine plant in bar
T1=310.;#Initial tamperature in K
P2=5.5;#Pressure at the end of compression in bar
r=1.4;#isentropic index
#Calculations
rp=P2/P1;#pressure ratio
n=(1-(1/rp)**((r-1)/r))*100;#Thermal efficiency of the turbine in percent
#Output data
print 'Thermal efficiency of the turbine unit is (percent) = ',round(n,2)
#pg 1.62
#calculate the Power developed
#Input data
P1=1.;#Initial pressure of a simple closed cycle gas turbine plant in bar
T1=298.;#Initial temperature in K
P2=5.1;#Pressure of gas after compression in bar
T3=1123.;#Temperature at the end of compression in K
P4=1.;#Pressure of hot air after expansion in the turbine in bar
r=1.4;#Isentropic constant
Cp=1.005;#Specific heat of air in kJ/kg K
#Calculations
P3=P2;#Pressure at the end of constant pressure stroke
T2=T1*(P2/P1)**((r-1)/r);#Temperature at the end of process 1-2 in K
T4=T3*(P4/P3)**((r-1)/r);#Temperature at the end of process 3-4 in K
Wt=Cp*(T3-T4);#Work done by the turbine in kJ/kg
Wc=Cp*(T2-T1);#Work required by the compressor in kJ/kg
W=Wt-Wc;#Net work done by the turbine in kJ/kg
P=1*W;#Power developed by the turbine assembly per kg per second in kW
#Output
print 'Power developed by the turbine assembly per kg of air supplied per second is (kW) = ',round(P,2)
print 'The answer is a bit different from textbook due to rounding off error '
#pg 1.63
#calculate the maximum temperature and cycle efficiency
#Input data
P1=1.;#The pressure of air entering the compressor of a gas turbine plant operating on Brayton cycle in bar
T1=293.;#Initial temperature in K
r=6.5;#Pressure ratio of the cycle
r1=1.4;#Isentropic ratio
#Calculations
T2=T1*(r)**((r1-1)/r1);#Temperature at the end of compression in K
T4=2.3*(T2-T1)/0.708;#Temperature at point 4 in K
T3=T4*(r)**((r1-1)/r1);#Maximum temperature in K
n=(1-((T4-T1)/(T3-T2)))*100;#Turbine plant efficiency in percent
#Output
print '(a)The maximum temperature of the cycle is (K) = ',round(T3,2)
print '(b)Cycle efficiency is (percent) = ',round(n,2)
print 'The answers are a bit different from textbook due to rounding off error '
#pg 1.64
#calculate the net power an dair fuel ratio
#Input data
P1=1.;#Pressure in an oil gas turbine installation in bar
T1=298.;#Initial Temperature in K
P2=4.;#Pressure after compression in bar
CV=42100.;#Calorific value of oil in kJ/kg
T3=813.;#The temperature reached after compression in K
m=1.2;#Air flow rate in kg/s
Cp=1.05;#Specific heat of air at constant pressure in kJ/kg K
r=1.4;#Isentropic ratio
#Calculations
r1=P2/P1;#Pressure ratio
T2=(r1)**((r-1)/r)*T1;#Temperature at the end of compression stroke in K
T4=T3/(r1)**((r-1)/r);#Temperature at the end of isentropic expansion in K
Wt=m*Cp*(T3-T4);#Work done by the turbine in kJ/s or kW
Wc=m*Cp*(T2-T1);#Work to be supplied to the compressor in kJ/s or kW
Wn=Wt-Wc;#Net work done by the turbine unit in kW
qs=m*Cp*(T3-T2);#Heat supplied by the oil in kJ/s
M=qs/CV;#Mass of fuel burnt per second in kg/s
a=m/M;#Air fuel ratio
#Output
print '(a)The net power output of the installation is (kW) = ',round(Wn,2)
print '(b)Air fuel ratio is ',round(a,1)
#pg 1.66
#calculate the net power
#Input data
T1=300.;#Minimum temperature of the plant containing a two stage compressor with perfect intercooling and a single stage turbine in K
T5=1100.;#Maximum temperature of the plant in K
P1=1.;#Initial Pressure in bar
P5=15.;#Final pressure in bar
Cp=1.05;#Specific heat of air in kJ/kg K
r=1.4;#Isentropic ratio
#Calculations
P6=P1;#Pressure at 6 in bar
P3=(P1*P5)**(1./2);#The intermediate pressure for cooling in bar
P2=P3;#Pressure at point 2 in bar
T2=T1*(P2/P1)**((r-1)/r);#Temperature at the end of process 1-2
T3=T1;#Intermediate temperature in K
T4=1.473*T3;#Temperature at point 4 in K
T6=T5/(P5/P6)**((r-1)/r);#Temperature at point 6 in k
Wt=Cp*(T5-T6);#Work done by the turbine per kg of air in kJ/s
Wc=Cp*(T4-T3)+Cp*(T2-T1);#Work done by the compressor per kg of air in kJ/s
Wn=Wt-Wc;#Net work done in kJ/s
Pn=Wn;#Net power developed in kW
#Output
print 'The net power of the plant per kg of air/s is (kW) = ',round(Pn,2)
#pg 1.67
#calculate the maximum power
#Input data
P1=1.;#Initial Pressure of a gas turbine power plant in bar
P2=8.;#Final pressure in bar
T1=300.;#Initial temperature in K
T5=850.;#Temperature of air expanded in the turbine in K
m=1.8;#Mass of air circulated per second in kg
Cp=1.05;#Specific heat of air at constant pressure in kJ/kg K
r=1.4;#Ratio of specific heat
#Calculations
P4=(P1*P2)**(0.5);#Pressure for maximum power output in bar
P3=P2;#Pressure after the constant pressure process in bar
T3=T5;#For reheating condition Temperature in K
T2=T1*(P2/P1)**((r-1)/r);#Temperature at the end of constant entropy process in K
T4=T3/((P3/P4)**((r-1)/r));#Temperature after the process 3-4 in K
T6=T4;#Temperature at the end of process 5-6 in K
Wt=m*Cp*((T3-T4)+(T5-T6));#Work done by the turbine in kJ/s
Wc=m*Cp*(T2-T1);#Work absorbed by the compressor in kJ/s
P=Wt-Wc;#Power that can be obtained from gas turbine installation in kW
#Output
print 'The maximum power that can be obtained from turbine installation is (kW) = ',round(P,0)
#pg 1.69
#calculate the mass of fluid and amount of heat supplied
#Input data
P1=1.5;#Pressure at the inlet of the low pressure compressor in bar
T1=300.;#Temperature at the inlet of the low pressure compressor in K
P5=9.;#Maximum pressure in bar
T5=1000.;#Maximum temperature in K
P=400.;#Net power developed by the turbine in kW
Cp=1.0;#Specific heat of air at constant pressure in kJ/kg K
r=1.4;#Ratio of specific heat
#Calculations
P8=P1;#For perfect intercooling and perfect reheating in bar
P4=P5;#For perfect intercooling and perfect reheating in bar
P2=(P1*P4)**0.5;#Pressure at the end of Isentropic compression in LP compressor in bar
P6=P2;#Pressure at the end of process 5-6 in bar
T2=T1*(P2/P1)**((r-1)/r);#Temperature at the end of isentropic compression in K
T3=T1;#For perfect intercooling in K
T4=T2;#For perfect intercooling in K
T6=T5/(P5/P6)**((r-1)/r);#Temperature at the end of process 5-6 in K
T7=T5;#Temperature in K
T8=T6;#Temperature in K
Wt=Cp*((T5-T6)+(T7-T8));#Work done by the turbine in kg/s
Wc=Cp*((T2-T1)+(T4-T3));#Work absorbed by the compressor in kJ/s
Wn=Wt-Wc;#Net work output in kJ/s
m=P/Wn;#Mass of fluid flow per second in kg/s
qs=m*Cp*((T5-T4)+(T7-T6));#Heat supplied from the external source in kJ/s
#Output
print '(a)Mass of fluid to be circulated in the turbine is (kg/s) = ',round(m,3)
print '(b)The amount of heat supplied per second from the external source is (kJ/s) = ',round(qs,1)
#pg 1.70
#calculate the mass of air and heat supplied
#Input data
T1=293.;#Temperature of a constant pressure open cycle gas turbine plant in K
T3=1043.;#The maximum temperature in K
a=6.5;#The pressure ratio
P=1000.;#Power developed by the installation in kW
Cp=1.05;#Specific heat at constant pressure in kJ/kg K
r=1.4;#Isentropic ratio
#Calculations
T2=T1*a**((r-1)/r);#Temperature after the isentropic compression stroke in K
T4=T3/a**((r-1)/r);#Temperature after the isentropic expansion process in K
Wt=Cp*(T3-T4);#Work done by the turbine per kg of air per second in kJ
Wc=Cp*(T2-T1);#Work absorbed by the compressor per kg of air per second in kJ
Wn=Wt-Wc;#Net work output in kJ/s
m=P/Wn;#Mass of fluid circulated per second in kg/s
Q=m*Cp*(T3-T2);#Heat supplied by the heating chamber in kJ/s
#Output
print '(a)Mass of air circulating in the installation is (kg/s) = ',round(m,2)
print '(b)Heat supplied by the heating chamber is (kJ/s) = ',round(Q,1)
print 'The answers are a bit different from textbook due to rounding off error '
#pg 1.72
#calculate the Overall efficiency and Mass of air circulated
#Input data
a=6.;#Pressure ratio of a gas turbine plant
T1=293.;#Inlet temperature of air in K
T3=923.;#Maximum temperature of the cycle in K
P=2000.;#Power developed in the cycle in kW
nc=85.;#Efficiency of the compressor in percentage
nt=85.;#Efficiency of the turbine in percentage
Cp=1.;#Specific heat of gas at constant pressure in kJ/kg K
Cv=0.714;#Specific heat of gas at constant volume in kJ/kg K
#Calculations
r=Cp/Cv;#Ratio of specific heats
T2a=a**((r-1)/r)*T1;#Temperature at 2' in K
T2=((T2a-T1)/(nc/100))+T1;#Temperature at point 2 in K
T4a=T3/a**((r-1)/r);#Temperature at the point 4' in K
T4=T3-((T3-T4a)*(nt/100));#Temperature at the point 4 in K
Wt=Cp*(T3-T4);#Work done by the turbine per kg of air in kJ
Wc=Cp*(T2-T1);#Work done by the compressor per kg of air in kJ
Wn=Wt-Wc;#Net work output of the turbine per kg of air in kJ
qA=Cp*(T3-T2);#Heat supplied per kg of air in kJ
n=(Wn/qA)*100;#Overall efficiency of the turbine plant in percentage
m=P/Wn;#Mass of air circulated per second in kg
#Output
print '(1)Overall efficiency of the turbine is (percentage) = ',round(n,0)
print '(2)Mass of air circulated by the turbine is (kg) = ',round(m,2)
#pg 1.73
#calculate the isentropic efficiency
#Input data
T1=293.;#Initial temperature of a gas turbine plant in K
P1=1.;#Initial pressure in bar
P2=4.5;#Pressure after the compression in bar
nc=80.;#Isentropic efficiency of a compressor in percentage
T3=923.;#Temperature of the gas whose properties may be assumed to resemble with those of air in the combustion chamber in K
deltaP=0.1;#Pressure drop in a combustion chamber in bar
nt=20.;#Thermal efficiency of the plant in percentage
r=1.4;#Isentropic index
P4=1.;#Pressure at point 4 in bar
#Calculations
P3=P2-deltaP;#Pressure at point 3 in bar
T21=T1*(P2/P1)**((r-1)/r);#Temperature after the compression process in K
T2=(T21-T1)/(nc/100)+T1;#Temperature at the point 2 in K
T41=T3/(P3/P4)**((r-1)/r);#Temperature at the end of expansion process in K
Ac=T2-T1;#Work done by the compressor per kg of air per specific heat at constant pressure Ac=Wc/Cp
At=T3;#Work done by the turbine per kg of air per specific heat at constant pressure At=Wt/Cp
An=At-Ac;#Net work done per kg of air
Bs=T3-T2;#Heat supplied per kg of air per specific heat at constant pressure Bs=qs/Cp;qs=heat supplied
T4=An-((nt/100)*Bs);#Temperature at point 4 in K
nT=((T3-T4)/(T3-T41))*100;#Isentropic efficiency of the turbine in percentage
#Output
print 'The isentropic efficiency of the turbine is (percent) = ',round(nT,2)
#pg 1.75
#calculate the Overall efficiency
#Input data
P1=1.;#Pressure of air received by the gas turbine plant in bar
T1=300.;#Initial Temperature in K
P2=5.;#Pressure of air after compression in bar
T3=850.;#Temperature of air after the compression in K
nc=80.;#Efficiency of the compressor in percent
nt=85.;#Efficiency of the turbine in percent
r=1.4;#Isentropic index of gas
P41=1.;#Pressure at the point 41 in bar
Cp=1.05;#Specific heat of the gas at constant pressure in kJ/kg K
#Calculations
P3=P2;#Since 2-3 is constant pressure process in bar
T21=T1*(P2/P1)**((r-1)/r);#Temperature at the point 21 on the curve in K
T2=(T21-T1)/(nc/100)+T1;#Temperature at the point 2 in K
T41=T3/(P3/P41)**((r-1)/r);#Temperature at the point 41 in K
T4=T3-((nt/100)*(T3-T41));#Temperature of gas at the point 4 in K
Wt=Cp*(T3-T4);#work done by the turbine in kJ/kg of air
Wc=Cp*(T2-T1);#Work done by the compressor in kJ/kg of air
Wn=Wt-Wc;#Net work done by the plant in kJ
nt=(Wn/(Cp*(T3-T2)))*100;#Thermal efficiency of the plant in percentage
#Output
print 'Overall efficiency of the plant is (percent) = ',round(nt,2)
#pg 1.76
#calculate the overall efficiency
#Input data
P1=1.;#Initial pressure of a gas turbine plant in bar
T1=310.;#Initial temperature in K
P2=4.;#Pressure of air after compressing in a rotary compressor in bar
P3=P2;#Constant pressure process
P41=P1;#Since 1-41 is a constant pressure process in bar
T3=900.;#Temperature of air at the point 3 in constant process in K
nc=80.;#Efficiency of the compressor in percentage
nt=85.;#Efficiency of the turbine in percentage
E=70.;#Effectiveness of the plant in percentage
r=1.4;#Isentropic index
Cp=1.;#Specific heat of air at constant pressure in kJ/kg K
#Calculations
T21=T1*(P2/P1)**((r-1)/r);#Temperature at the point 21 in the temperature versus entropy graph in K
T2=T1+((T21-T1)/(nc/100));#Temperature of air after the compression process in K
T41=T3/((P3/P41)**((r-1)/r));#Temperature at the point 41 after the isentropic expansion process in K
T4=T3-((T3-T41)*(nt/100));#Temperature at the point 4 in K
Wt=Cp*(T3-T4);#Work done by the turbine in kJ
Wc=Cp*(T2-T1);#Work done by the compressor in kJ
Wn=Wt-Wc;#Net work done in kJ
qs=Cp*(T3-T2);#Heat supplied in kJ
qa=Cp*(T4-T2);#Heat available in the exhaust gases in kJ
H=qa*(E/100);#Actual heat recovered from the exhaust gases in the heat exchanger in kJ
Hs=qs-(H);#Heat supplied by the combustion chamber in kJ
nt=(Wn/Hs)*100;#Thermal efficiency of the gas turbine plant with heat exchanger in percent
#Output
print 'The overall efficiency of the plant is (percent) = ',round(nt,1)