In [21]:

```
# Variables
#Given:
T1 = 700.; #temperature of heat source(K)
T2 = 300.; #temperature of heat sink(K)
# Calculations
#To calculate the maximum efficiency
eff=((T1-T2)/T1); #efficiency of a heat engine
# Results
print 'Maximum efficiency of heat engine is %f'%eff
```

In [22]:

```
# Variables
#Given:
m = 1.; #mass of water(kg)
T1 = 300.; #temperature of surrounding(K)
T2 = 273.; #temperature of water(K)
Hf = 334.11; #latent heat of fusion of ice(kJ/kg)
# Calculations and Results
#To determine minimum amount of work and heat given upto surrounding
#(a)
Q2 = m*Hf; #heat absobed at temperature T2
W = ((Q2*(T1-T2))/T2); #minimumm amount of work required
print 'Minimum amount of work required is %f kJ'%W
#(b)
#Q1 is the heat given up the surrounding
Q1 = W+Q2;
print 'Heat given upto surrounding is %f kJ'%Q1
```

In [23]:

```
# Variables
#Given:
P_out = 4.5; #output power(hp)
P_in = 6.25; #input power(kW)
T1 = 1000.; #source temperature(K)
T2 = 500.; #sink temperature(K)
# Calculations and Results
#To determine efficiency of proposed engine
ep = ((P_out*745.7)/(P_in*1000)); #proposed efficiency
print 'Efficiency of proposed engine is %f'%ep
em = ((T1-T2)/T1); #maximum efficiency
print 'The maximum efficieny is %f'%em
print 'Hence the claim of the proposed engine is impossible'
```

In [24]:

```
# Variables
#Given:
P = 500.; #pressure of dry saturated steam(kPa)
#From steam tables
Hv = 2106.; #latent heat of vaporisation(kJ/kg)
T = 425.; #saturation temperature(K)
# Calculations
#To calculate the entropy of evaporation
#By equation 4.25 (Page no. 93)
Sv = (Hv/T); #entropy change accompanying vaporisation
# Results
print 'Entropy of evaporation is %f kJ/kg K'%Sv
```

In [25]:

```
# Variables
#Given:
m = 2.; #mass of gas(kg)
T1 = 277.; #initial temperature(K)
T2 = 368.; #final temperature(K)
Cv = 1.42; #specific geat at constant volume(kJ/kg K)
# Calculations
import math
#Using equation 4.31 (Page no. 94)
S = (m*Cv*math.log(T2/T1)); #change in entropy(kJ/K)
# Results
print 'Change in entropy is %f kJ/K'%S
```

In [26]:

```
#Given:
T = 300.; #temperature in K
P1 = 10.; #initial pressure(bar)
P2 = 1.; #final pressure(bar)
R = 8.314; #ieal gas constant
# Calculations
import math
#To calculate the entropy change
#Using equation 4.33(Page no. 94)
S = (R*math.log(P1/P2)); #(kJ/kmol K)
# Results
print 'Entopy change is %f kJ/kmol K'%S
```

In [27]:

```
# Variables
#Given:
T1 = 335.; #initial temperature in K
T2 = 300.; #final temperature in K
P1 = 10.; #initial pressure(bar)
P2 = 1.; #final pressure(bar)
Cp = 29.3; #specific heat constant at constant pressure(kJ/kmol K)
R = 8.314; #ideal gas constant
# Calculations
import math
#To determine change in entropy
#Using equation 4.30 (Page no. 94)
S = ((Cp*math.log(T2/T1))-(R*math.log(P2/P1))); #entropy change(kJ/kmol K)
# Results
print 'Entropy change in the process is %f kJ/kmol K'%S
```

In [28]:

```
# Variables
#Given:
m1 = 10.; #mass of water at 375 K (kg)
m2 = 30.; #mass of water at 275 K (kg)
c = 4.2; #specific heat of water (kJ.kg K)
# Calculations
import math
#To determine the change in entropy
#Let T be the final temperature(K)
T = ((m1*375)+(m2*275))/(m1+m2);
#S1 be change in entropy for hot water
S1 = (m1*c*math.log(T/375)); #[kJ/K]
#S2 be the change in entropy for cold water
S2 = (m2*c*math.log(T/275)); #[kJ/K]
#S be the total entropy change
S = S1+S2;
# Results
print 'The total entropy change is %f kJ/K'%S
```

In [29]:

```
# Variables
#Given:
m1 = 35.; #mass of steel in kg
m2 = 150.; #mass of oil in kg
T1 = 725.; #temperature of steel(K)
T2 = 275.; #temperature of oil(K)
c1 = 0.88; #specific heat of steel (kJ/kg K)
c2 = 2.5; #specific heat of oil(kJ/kg K)
# Calculations
import math
#To calculate the total entropy change
#Let T be the final temperature
T = (((m1*c1*T1)+(m2*c2*T2))/((m1*c1)+(m2*c2)));
#S1 be the in entropy for steel
S1 = (m1*c1*math.log(T/T1)); #[kJ/K]
#S2 be the change in entropy for oil
S2 = (m2*c2*math.log(T/T2)); #[kJ/K]
#S be the total entropy change
S = S1+S2;
# Results
print 'The total entropy change is %f kJ/K'%S
```

In [30]:

```
# Variables
#Given:
n1 = 0.21; #volume % of oxygen in air
n2 = 0.79; #volume % of nitrogen in air
R = 8.314; #ideal gas constant
# Calculations
import math
#To calculate entropy of 1 kmol of air
#Using equation 4.35 (Page no. 96)
S = (-R*(n1*math.log(n1)+n2*math.log(n2))); #[kJ/kmol K]
# Results
print 'The total entropy change is %f kJ/kmol K'%S
```

In [31]:

```
# Variables
H = -2.8318*10**5; #heat of reaction (J/mol)
T = 298.; #temperature of reaction in K
#Absolute entropies for CO, O2, CO2 are (in J/mol K)
S_CO = 198.;
S_O2 = 205.2;
S_CO2 = 213.8;
# Calculations and Results
# To determine the change in entropy for the reaction
# Referring equation 4.36 (Page no. 96)
S_reactant = S_CO + 0.5*S_O2; #entropy change for reactants
S_product = S_CO2; #entropy change for products
S = S_product-S_reactant; #total entropy change
print 'The total entropy change for the reaction is %f J/mol'%S
print 'Since the reaction is highly irreversible, entropy change cannot be calculated as the ratio of heat of reaction to the temperature'
#The energy available for useful work is the difference between heat of reaction and entropy energy due to ireversible nature of the process
W_useful = -H+(T*S); #energy available for useful work (J)
print 'Energy available for useful work is %3.2e J'%W_useful
```

In [32]:

```
# Variables
#Given:
H_steam = 2923.5; #enthalpy of superheated steam (kJ/kg)
S_steam = 6.71; #entropy of superheated steam (kJ/kg K)
H_liquid = 845.; #enthalpy of saturated liquid (kJ/kg)
S_liquid = 2.32; #entropy of saturated liquid (kJ/kg K)
T = 300.; #temperature of system (K)
# Calculations
#To calculate change in entropy and check whether the process is reversible
S_system = S_liquid-S_steam; #change in entropy of steam
#Let Q be the heat given out during condensation
Q = -(H_liquid-H_steam);
S_surrounding = Q/T; #change in entropy of the surrounding
S_total = S_system+S_surrounding; #total entropy change
# Results
print 'The total entropy change is %f kJ/kg'%S_total
print 'Since total entropy change is positive,the process is irreversible'
```

In [33]:

```
# Variables
#Given:
V = 1.; #volume of each compartment in cubic meters
P_sat = 683.6; #pressure of saturated steam (kPa)
P_steam = 101.3; #pressure of supereated steam (kPa)
T_sat = 437.2; #temperature of system (K)
#Referring steam tables
#For saturated steam at pressure 683.6 kPa and temp 437.2 K
H_sat = 2761.; #enthalpy of saturated steam (kJ/kg)
S_sat = 6.7133; #entropy of saturated steam (kJ/kg K)
spvol_sat = 278.9*10**-3; #specific volume of saturated steam (cubic m/kg)
U_sat = 2570.4; #specific internal energy of saturated steam (kJ/kg)
#For superheated steam at 101.3 kPa and 437.2 K
H_steam = 2804.; #enthalpy of superheated steam (kJ/kg)
S_steam = 7.6712; #entropy of superheated steam (kJ/kg K)
spvol_steam = 1976.2*10**-3; #specific volume of superheated steam (cubic m /kg)
U_steam = 2603.3; #specific internal energy of superheated steam (kJ/kg)
# Calculations
#To determine the change in entropy of system
m_sat = V/spvol_sat; #mass of satureated steam(kg)
m_steam = V/spvol_steam; #mass of superheated steam (kg)
m_sys = m_sat+m_steam; #mass of system (kg)
spvol_sys = (2.*V)/m_sys; #specific volume of system (cubic m/kg)
#Since no heat exchange and work interaction occurs so internal energy after mixing remains the same
U1_sat = m_sat*U_sat; #internal energy of saturated steam (kJ)
U1_steam = m_steam*U_steam; #internal enegy of superheated steam (kJ)
U_sys = (U1_sat+U1_steam)/m_sys; #specific internal energy of system (kJ/kg)
#Referring steam tables
#At calculated U_sys and spvol_sys
S_sys = 6.9992; #specific entropy of system (kJ/kg K)
Si = ((m_sat*S_sat)+(m_steam*S_steam)); #initial entropy of system (kJ/K)
Sf = (m_sys*S_sys); #final entropy of system (kJ/K)
S = Sf-Si; #change in entropy
# Results
print 'The change in entropy of the system is %f kJ/K'%S
print 'Since entropy change is positive, the process is irrevresible'
```

In [34]:

```
# Variables
#Given:
V = 1.; #volume of each compartment in cubic m
T = 300.; #temperature of ideal gas in 1st compartment (K)
P = 200.; #pressure of ideal gas in 1st compartment (kPa)
R = 8.314; #ideal gas constant
# Calculations
#To calculate entropy change
#Let n be the number of moles of gas
n = ((P*V)/(R*T));
#Since gas in vessel exchanges no heat and work with surrounding so internal energy remains same
#This implies temperature after mixing is same as that before mixing
#Final conditions:
Tf = 300.; #final temperature (K)
Vf = 2.; #final volume (cubic m)
Pf = 100.; #final pressure (kPa)
#Initial conditions:
Ti = 300.; #initial temperature (K)
Vi = 1.; #initial volume (cubic m)
Pi = 200.; #initial pressure (kPa)
import math
#Using equation 4.33 (Page num 94)
S = n*R*math.log(Vf/Vi); #entropy change of system (kJ/K)
#Since entropy of surrounding does not change
S_total = S; #total entropy change
# Results
print 'The change in total entropy is %f kJ/K'%S_total
```

In [35]:

```
# Variables
#Given:
m_oil = 5000.; #mass flow rate of oil (kg/h)
Tin_oil = 500.; #inlet temperature of oil (K)
Tin_water = 295.; #inlet temperature of water (K)
c_oil = 3.2; #specific heat of oil (kJ/kg K)
c_water = 4.2; #specific heat of water (kJ/kg K)
import math
#To calculate entropy change in the process
#Assuming oil is cooled to minimum permissible temperature
Tout_oil = 305.; #exit temperature of oil (K)
Tout_water = 490.; #exit temperature of water (K)
# Calculations
#Let m_water be the mass flow rate of water
#By enthalpy balance
m_water = ((m_oil*c_oil*(Tin_oil-Tout_oil))/(c_water*(Tout_water-Tin_water))); #(kg/h)
S_oil = m_oil*c_oil*math.log(Tout_oil/Tin_oil); #entropy change of oil (kJ/K)
S_water = m_water*c_water*math.log(Tout_water/Tin_water); #entropy change of water (kJ/K)
S_tot = S_oil+S_water; #total entropy change
# Results
print 'The total entropy change in the process is %f kJ/K'%S_tot
```

In [36]:

```
# Variables
#Given:
To = 275.; #temperature of quenching oil (K)
# Calculations
S_steel = -26.25; #change in entropy os casting (kJ/K)
S_oil = 43.90; #change in entropy of oil (kJ/K)
S_tot = S_steel+S_oil; #total entropy change
#Let W be loss in capacity for doing work
W = To*S_tot; #(kJ)
# Results
print 'The loss in capacity for doing work is %f kJ'%W
```

In [37]:

```
import math
#Given:
m_oil = 5000.; #mass flow rate of hydrocarbon oil (kg/h)
Tin_oil = 425.; #inlet temperature of oil (K)
Tout_oil = 340.; #exit temperature of oil (K)
m_water = 10000.; #mass flow rate of water (kg/h)
Tin_water = 295.; #inlet temperature of water (K)
c_oil = 2.5; #mean specific heat of oil (kJ/kg K)
c_water = 4.2; #mean specific heat of water (kJ/kg K)
#To determine total change in entropy and available work
# Calculations and Results
#(a)
#By energy balance
Tout_water = ((m_oil*c_oil*(Tin_oil-Tout_oil))/(m_water*c_water))+295; #exit temperature of water (K)
S_oil = m_oil*c_oil*math.log(Tout_oil/Tin_oil); #change in entropy of oil (kJ/K)
S_water = m_water*c_water*math.log(Tout_water/Tin_water); #change in entropy of water (kJ/K)
S_tot = S_oil+S_water; #total entropy change
print 'The total entropy change is %f kJ/K'%S_tot
#(b)
To = 295.; #temperature at which heat is rejected to surrounding (K)
#Let Q be heat given out by the oil on cooling
Q = m_oil*c_oil*(Tin_oil-Tout_oil);
#Heat rejected to the surrounding at To by the Carnot Engine is given by
#Q2 = To(Q/T) = -To*S_oil
Q2 = -To*S_oil; #(kJ)
#Let W be the work output of engine
W = Q-Q2;
print 'The work output of the engine would be %4.3e kJ'%W
```

In [38]:

```
# Variables
#Given:
T = 10.; #temperature of metal (K)
Cp = 0.45; #molar heat capacity at 10 K (J/mol K)
# Calculations
#To determine the molar entropy of metal
#Entropy of solid at 10 K is calculated using first integral in equation 4.55 (Page no. 108)
S = Cp/3;
# Results
print 'Molar entropy of meatl at 10 K is %f J/mol K'%S
```

In [39]:

```
# Variables
#Given:
T = 473.; #temperature at entropy is to be determined (K)
Tf = 273.; #base temperature (K)
Tb = 373.; #boiling temperature (K)
Cpl = 4.2; #avearge heat capacity of water (kJ/kg K)
Cpg = 1.9; #avearge heat capacity of water vapour between 373 K and 473 K
Hv = 2257.; #latent heat of vaporisation at 373 K (kJ/kg)
# Calculations
import math
S = (Cpl*math.log(Tb/Tf))+(Hv/Tb)+(Cpg*math.log(T/Tb));
# Results
print 'Absolute entropy of water vapour at 473 K and 101.3 kPa is %f kJ/kg K'%S
print 'It compares favourably with the value reported in steam tables'
```