In [6]:

```
#ques1
#Standard brayton cycle
#1-Inlet for compressor
#2-Exit for compressor
#T-Temperature at a state
#P-Pressure at a state
T1=288.2;#K
P2=1000.0;#kPa
P1=100.0;#kPa
k=1.4;
T2=T1*(P2/P1)**(1.0-1/k);#K
Cp=1.004;#Specific heat at constant pressure in kJ/kg
wc=Cp*(T2-T1);#compressor work in kJ/kg;
print" Temperature T2 =",round(T2,2),"K"
print" Compressor work =",round(wc,1),"kJ/kg"
#3-Turbine Inlet
#4-Turbine Exit
P4=P1;
P3=P2;
T3=1373.2;#K
T4=T3*(P4/P3)**(1-1/k);#K
wt=Cp*(T3-T4);
wnet=wt-wc;
print" Temperature T3 =",round(T3,2)," K"
print" Temperature T4 =",round(T4),"K"
print" Turbine work =",round(wt,2),"kJ/kg"
print" Net work =",round(wt-wc,2),"kJ/kg"
#2-Also high temperature heat exchanger Inlet
#3-(-do-) Exit
qh=Cp*(T3-T2);#Heat of source in kJ/kg
#4-high temp heat exchanger inlet
#1-(-do-) Exit
ql=Cp*(T4-T1);#Heat of sink in kJ/kg
nth=wnet/qh;
print" Thermal Efficiency of cycle =",round(nth*100,2),"%"
```

In [22]:

```
#Calculation mistake in book
#ques2
#Standard brayton cycle
#Calculation mistake in book
#1-Inlet for compressor
#2-Exit for compressor
#T-Temperature at a state
#P-Pressure at a state
T1=288.2;#K
P2=1000.0;#kPa
P1=100.0;#kPa
k=1.4;
T2s=T1*(P2/P1)**(1-1/k);#K
nc=.80;#Compressor Efficiency
T2=T1+(T2s-T1)/0.80;
Cp=1.004;#Specific heat at constant pressure in kJ/kg
wc=Cp*(T2-T1);#compressor work in kJ/kg
wc=round(wc)
print" Temperature T2 =",round(T2,2),"K"
print" Compressor work =",(wc),"kJ/kg"
#3-Turbine Inlet
#4-Turbine Exit
P4=P1;
P3=P2;
T3=1373.2;#K
T4s=T3*(P4/P3)**(1-1.0/k);#K
nt=0.85;#turbine Efficiency
T4=T3-(T3-T4s)*0.85;
wt=Cp*(T3-T4);
wnet=wt-wc;
print" Temperature T3 =",round(T3,1),"K"
print" Temperature T4 =",round(T4,1),"K"
print" Turbine work =",round(wt,2),"kJ/kg"
print" Net work =",round(wt-wc,2),"kJ/kg"
#2-Also high temperature heat exchanger Inlet
#3-(-do-) Exit
qh=Cp*(T3-T2);#Heat of source in kJ/kg
#4-high temp heat exchanger inlet
#1-(-do-) Exit
ql=Cp*(T4-T1);#Heat of sink in kJ/kg
nth=wnet/qh;
print" Thermal Efficiency of cycle =",round(nth*100),"percent"
#some answers are have acceptable difference beacause of approximization in book but here calculations are precise
```

In [24]:

```
#ques3
#efficiency of the cycle
wnet=395.2;#kJ/kg from example no 1
#Tx=T4
Tx=710.8;#K from example no 1
T3=1373.2;#K from example no 1
Cp=1.004;#specific heat in kJ/kg
qh=Cp*(T3-Tx);
nth=wnet/qh;
print" Thermal efficiency =",round(nth*100,1)," percent"
```

In [26]:

```
#ques4
#Calculation of work in the given cycle
import math
R=0.287;#gas constant
T1=288.2;#compressor temperature K
T2=1373.2;#K turbine temperature K
#Pe/Pi=c=10, Pi/Pe=1/c from example 12.1
c=10.0;
wc=-R*T1*math.log(c);
print" Isothermal work in compressor =",round(wc,1),"kJ/kg"
wt=-R*T2*math.log(1/c);
print" Isothermal work in turbine =",round(wt,1),"kJ/kg"
```

In [28]:

```
#ques5
#air standard cycle for jet repulsion
import math
#1-compressor inlet
#2-Compressor exit
#P-Pressure at given point
#T-Temperature at given point
P1=100;#kPa
P2=1000;#kPa
T1=288.2;#K
T2=556.8;#K
wc=269.5;#from ex 12.1 work done in compressor in kJ/kg
#2-Burner inlet
#3-Burner exit
P3=1000;#kPa
T3=1373.2;#K
#wc=wt
Cp=1.004;#specific enthalpy of heat at constant pressure in kJ/kg
k=1.4;
T4=T3-wc/Cp;
P4=P3*(T4/T3)**(1-1/k);
#from s4=s5 and h4=h5+v2/2 we get
T5=710.8#K, from second law
v=math.sqrt(2*Cp*1000*(T4-T5));#m/s
print" Velocity of air leaving the nozel =",round(v),"m/s"
```

In [36]:

```
#ques6
#air standard refrigeration cycle
#1-compressor inlet
#2-compressor exit
P1=100;#kPa
P2=500;#kPa
k=1.4;
rp=P2/P1;
cop=(rp**(1-1/k)-1)**-1;
print" Coefficient of performance =",round(cop,2)
#3-Expander inlet
#4-Expander exit
P3=P2;
P4=P1;
T3=288.23;#K, given and fixed
T4=T3/(P3/P4)**(1-1/k);
T1=253.2;#K, given
Cp=1.004;#Specific heat at cons pressure in kJ/kg
ql=Cp*(T1-T4);#heat released in kJ/kg
P=1#power required in kW
ms=P/ql;#kg/s
print" Rate at which the air enter the compressor =",round(ms,3),"kg/s"
```

In [42]:

```
#ques7
#the otto cycle
#1-compressor inlet
#2-compressor exit
P1=100.0;#kPa
T1=288.2;#K
R=0.287;#gas constant
v1=R*T1/P1;#specific volume at inlet in m^3/kg
rv=10.0;#compression ratio given
k=1.4;#constant
T2=T1*rv**(k-1);#K
print" Temperature at compressor exit, T2 =",round(T2,1),"K"
P2=P1*rv**k;#kPa
print" Pressure at compressor exit, P2 =",round(P2/1000,2),"MPa"
v2=v1/rv;#specific heat at exit in m^3/kg
#23-heat addition process
#q23=Cv*(T3-T2)=1800 kJ/kg given
q23=1800.0;#kJ/kg heat addition, given
Cv=0.717;#specific heat at constant volume in kJ/kg
T3=T2+q23/Cv;#K
print" Initial Temperature during heat additon process, T3 =",round(T3,2),"K"
P3=P2*(T3/T2);#kPa
print" Initial pressure during heat addition process, P3 =",round(P3/1000,3),"MPa"
r=10.0;#k=V4/V3=P3/P4
T4=T3*(1/r)**(k-1);
print" Final temperature during heat addition process, T4 =",round(T4,3),"K";
P4=P3/r**k;#kPa
print" Final pressure during heat addition process, P4 =",round(P4/1000,4),"MPa"
nth=1-1/r**(k-1);#thermal efficiency
print" Thermal efficiency =",round(nth*100,1)," percent"
q41=Cv*(T1-T4);#/heat for process 4-1 in kJ/kg
wnet=q23+q41;
mep=wnet/(v1-v2);#effective mean pressure n kPa
print" Mean effective pressure =",round(mep,2),"kPa"
```

In [47]:

```
#ques8
#the diesel cycle
#1-compressor inlet
#2-compressor exit
P1=100;#kPa
T1=288.2;#K
R=0.287;#gas constant
v1=R*T1/P1;#specific volume at inlet in m^3/kg
rv=20;#compression ratio given
k=1.4;#constant
T2=T1*rv**(k-1);#K
print" Temperature at compressor exit, T2 =",round(T2,1),"K"
P2=P1*rv**k;#kPa
print" Pressure at compressor exit, P2 =",round(P2/1000,3)," MPa"
v2=v1/rv;#specific heat at exit in m^3/kg
#23-heat addition process
#q23=Cv*(T3-T2)=1800 kJ/kg given
q23=1800;#kJ/kg heat addition, given
Cv=.717;
Cp=1.004;#specific heat at constant pressure in kJ/kg
T3=T2+q23/Cp;#K
print" Initial Temperature during heat addition process, T3 =",round(T3,2),"K"
r=T3/T2;#T3/T2=V3/V2=r
v3=r*v2;
T4=T3/(v1/v3)**(k-1);
print" Final temperature during heat addition process, T4 =",round(T4),"K"
q41=Cv*(T1-T4);#/heat for process 4-1 in kJ/kg
wnet=q23+q41;
mep=wnet/(v1-v2);#effective mean pressure in kPa
qh=1800;#heat transfer in kJ/kg
nth=wnet/qh;#thermal efficiency
print" Thermal efficiency =",round(nth*100,1),"percent"
print" Mean effective pressure =",round(mep,2),"kPa"
```