In [1]:

```
# Variables
m = 0.1; #mass of superheated steam in the piston cylinder assembly in kg
P1 = 1. #initial pressure of superheated steam in MPa
T1 = 300. #initial temperature of superheated steam in degree celsius
P2 = 0.1 #pressure of steam after expansion in MPa
T2 = 200. #temperature of steam after expansion in degree celsius
# Calculations
#For steam at P1 and T1:
h1 = 3052.1
v1 = 0.2580
#For steam at P2 and T2:
h2 = 2875.4
v2 = 2.1720
del_u = (((h1*10**3)-(P1*10**6*v1))-((h2*10**3)-(P2*10**6*v2)))*10**-3
W = m*(del_u)
# Results
print " The work done by steam = %0.2f kJ"%(W);
```

In [2]:

```
# Variables
P = 3. #pressure of superheated steam in MPa
Ti = 300. #temperature at which the steam enters the turbine in degree celsius
m = 1. #mass flow rate of steam in kg/s
Te = 60. #temperature of dry saturated steam when it leaves the turbine in degree celsius
# Calculations
#For steam at P and Ti:
h1 = 2995.1 #specific entahlpy of steam in kJ/kg
#For saturated steam at Te:
h2 = 2609.7 #specific enthalpy of saturated vapour in kJ/kg
Ws = m*(h1-h2) # Calculations of the power Results of the turbine using Eq.(6.83) in kW
# Results
print " The power Results of the turbine = %0.1f kW"%(Ws);
```

In [3]:

```
# Variables
m = 0.1 #mass of superheated steam in the piston cylinder assembly in kg
P1 = 3. #initial pressure of superheated steam in MPa
T1 = 300. #initial temperature of superheated steam in degree celsius
T0 = 300. #temperature of the reservoir which is placed in thermal contact with the piston-cylinder assembly in degree celsius
P2 = 0.1 #pressure of steam after expansion in MPa
#For steam at P1 and T1:
h1 = 2995.1
v1 = 0.08116
s1 = 6.5422
#For steam at P2 and T2:
h2 = 3074.5
v2 = 2.6390
s2 = 8.2166
# Calculations
T0 = T0+273.15
W = m*(h1-h2-(((P1*v1)-(P2*v2))*10**3)-(T0*(s1-s2)))
# Results
print " The maximum work obtained from steam = %0.2f kJ"%(W);
```

In [4]:

```
import math
# Variables
P1 = 0.1 #pressure at which air enters the compressor in MPa
T1 = 300. #temperature at which air enters the compressor in K
P2 = 1. #pressure at which air leaves the compressor in MPa
T2 = 300. #temperature at which air leaves the compressor in K
T0 = 300. #ambient temperature in K
N = 1. #molar flow rate of air in mol/s
gaamma = 1.4 #ratio of specific heat capacities (no unit)
R = 8.314 #universal gas constant in J/molK
# Calculations
Ws = (-N*T0*(-R*math.log (P2/P1)))*10**-3
# Results
print " The minimum power required to compress one mole per second of air = %0.3f kW"%(Ws);
```