In [1]:

```
# Variables
# In first case (T1-T2)/T1=1/6 or T1= 1.2*T2 (i)
# In seond case (T1-(T2-62))/T1= 2/6 or 2*T1 -3*(T2-62)=0 (ii)
# From eq (i) and (ii)
T2= 186/0.6; # in K
# Calculations
T1= 1.2*T2; # in K
# Results
print "Temperature of the source in °C is : ",T2-273
print "Temperature of the math.sink in °C is : ",T1-273
```

In [7]:

```
import math
# Variables
T1 = 25.; # in °C
T2 = 1.; # in °C
T1 = T1 + 273.; # in K
T2 = T2 + 273.; # in K
HT= 2.; # heat transfer across the wall and the roof in MJ/hr
# Calculations and Results
HT= HT*10**6; # in J/hr
Q = HT* (T1-T2); # in J/hr
COP_heat = T1/(T1-T2);
W_net = Q/COP_heat; # in J/hr
print "Power rquired for operating the pump in kW is : %.3f"%(W_net*10.**-3./3600)
# Part (b)
T2= 25.; # in °C
T2=T2+273; # in K
# COP= T2/(T1-T2) (i)
# COP= HT*(T1-T2)/W_net (ii)
# From (i) and (ii)
T1= math.sqrt(W_net*T2/HT)+T2; # in K
T1= T1-273; # in °C
print "The value of T1 in °C is : %.2f"%T1
# rounding off error
```

In [4]:

```
# Variables
heatEngineEffi= 32./100; # heat engine efficiency
COP= 5. # COP of heat pump
# Calculations
# heat engine efficiency = Wnet/Q1 = (Q1-Q2)/Q1
Q1byWnet= 1/heatEngineEffi;
Q2byWnet= (1-heatEngineEffi)*Q1byWnet;
# COP = Q4/Wnet = Q4/(Q4-Q3)
Q4byWnet= COP;
ratio= (Q2byWnet+Q4byWnet)/Q1byWnet; # ratio of heat transferred to the circulating water to heat trasferred to the engine
# Results
print "Ratio of heat trasferred to the circulating water to heat trasferred to the engine is : ",ratio
```

In [1]:

```
# Variables
Q = 88; # in MJ
Q=Q*10**3; # in kJ
T1 = 190.; # in °C
# Calculations
T1 = T1 + 273; # in K
T3 = -15; # in °C
T3 = T3 + 273; # in K
Eta_carnot = (T1 - T3)/T1;
Wnet= Eta_carnot * Q; # in kJ
CarnotPower= Wnet/3600.; # in kWh
# Results
print "The value of Carnot Power in kWh is : %.3f"%CarnotPower
print ("As the actual power produced by the invented engine is more than the Carnot Power, ");
print ("so inverter claim is not true")
```

In [4]:

```
# Variables
T1 = 24.; # in °C
T1 = T1 + 273; # in K
T2 = 2; # in °C
T2 = T2 + 273; # in K
Q = 100; #in MJ/h
Q = Q * 10**3; #in kJ/h
# Calculations and Results
COP_heatPump = T1/(T1-T2);
W = Q/COP_heatPump; #in kJ/h
W = W/3600.; # in kW
print "The theoretical minimum power required to drive the heat pump in kW is : %.3f"%W
COP_refrigerator = T2/(T1-T2);
W = Q/COP_refrigerator; # in kJ/h
W = W/3600.; # in kW
print "The theoretical power required to drive the heat pump when it is used as a refrigerator in kW is : %.2f"%W
```

In [8]:

```
# Variables
Q1= 278.; # in kJ/s
T1= 283.+273; # in K
T2= 50.+273; # in K
print ("Part (a)")
Q2= 208.; # in kJ/s
# Calculations and Results
# By Clausius inequality
V= Q1/T1-Q2/T2;
if V<0:
print ("The cycle is irreversible")
elif V>0:
print ("Reversible or irreversible cycle is not possible and the result is impossible")
else:
print ("The cycle is reversible")
print ("Part (b)")
Q2= 139.; # in kJ/s
V= Q1/T1-Q2/T2;
if V<0:
print ("The cycle is irreversible")
elif V>0:
print ("Reversible or irreversible cycle is not possible and the result is impossible")
else:
print ("The cycle is reversible")
print ("Part (c)")
Q2= 161.5; # in kJ/s
V= Q1/T1-Q2/T2;
if V<0:
print ("The cycle is irreversible")
elif V>0:
print ("Reversible or irreversible cycle is not possible and the result is impossible")
else:
print ("The cycle is reversible")
```

In [5]:

```
# Variables
Wnet_compresser= 3.; # in kW
Wnet_compresser=Wnet_compresser*3600.; # in kJ/h
Qabsorbed= 50.; # in MJ/h
Qabsorbed=Qabsorbed*10**3; # in kJ/h
# Calculations and Results
T1 = 46+273; # in K
T2 = 1+273; # in K
Qrejected= Wnet_compresser+Qabsorbed; # in kJ/h
print "The heat rejected in MJ/h is : ",Qrejected*10**-3
I= -(-Qrejected/T1+Qabsorbed/T2); # in kJ/h
print "Irreversibility in kJ/h is : %.3f"%I
```

In [7]:

```
#Exa 6.17
import math
# Variables
T1 = 12.; # in °C
T2 = 92.; # in °C
T1 = T1 + 273.; # in K
T2 = T2 + 273.; # in K
del_T = T2 - T1; # in K
m = 20; # in kg
C_v = 4.187;
s= 1;
# Calculations and Results
Q = m * s * del_T; # in cal
Q = Q * 4.18; # in J
H = 2; # heat given by the heater in kw
H = H * 10**3; # in J/sec
t = Q/H; #time taken by the heater to raise the temp. in sec
print "Time taken by the heater to raise the temperature in sec is : %.2f"%t
del_phi = m * C_v * math.log(T2/T1); # in kJ/K
print "Entrophy generated during the process in kJ/K is : %.2f"%del_phi
```

In [2]:

```
# Exa 6.18
import math
# Variables
Q1 = 1000.; # in kW
Q2 = 492.; # in kW
T1 = 285.; # in °C
T1 = T1 + 273; # in K
T2 = 5.; # in °C
T2 = T2 + 273; # in K
# Calculations and Results
Eta_carnot = (T1-T2)/T1*100; # in percentage
print "Carnot efficiency in %% is : %.2f"%Eta_carnot
Eta_heat = (Q1 - Q2)/Q1*100; # in percentage
print "Efficiency of the heat engine in % is : ",Eta_heat
if Eta_heat>Eta_carnot:
print ("As the efficiency of heat engine cannot be more than Carnot efficiency, Hence\
engine cannot execute irreversible cycle.")
```

In [13]:

```
# Variables
n = 1080.; # in cycle/min
Q_s = 57.; # in J/cycle
T1 = 12.; # in °C
T1 = T1 + 273; # in K
T2 = 2.; # in °C
T2 = T2 + 273; # in K
# Calculations
# 1-(Q_r/Q_s) = 1- (T2/T1)
Q_r = (T2/T1)*Q_s; # in J/cycle
W = Q_s - Q_r; # in J/cycle
P_o = W * n; # in J/min
P_o = P_o/60; # in W
# Results
print "The output of the engine in watt is",P_o
```

In [10]:

```
# Variables
Q2 = 10.**5; # in kJ/hr
T1 = -3.; # in °C
T1 = T1 + 273; # in K
T2 = 22.; # in °C
T2 = T2 + 273; # in K
# Calculations
COP_heat = 1./(1-T1/T2);
W = Q2/COP_heat; # in kJ/hr
W = W/3600.; # in kW
# Results
print "Minimum power required in kW is : %.3f"%W
```

In [12]:

```
# Variables
T_A= 927.+273; # in K
T_B= 127.+273; # in K
T_C= T_B; # in K
# Calculations
# Q_A= Q_B+Q_C+W = 2*Q_B+W (math.since Q_B=Q_C) (i)
# Q_A/T_A= Q_B/T_B+Q_C/T_C or
# Q_A= 2*Q_B*T_A/T_B (ii)
# From eq (i) and (ii)W= 2*Q_B*(T_A/T_B-1) (iii)
# Dividing (iii) by (ii)
WbyQ_A= (T_A/T_B-1)/(T_A/T_B);
# Results
print "engine efficiency in %% is : %.1f"%(WbyQ_A*100)
```

In [13]:

```
# Variables
T_A= 700.; # in K
T_B= 600.; # in K
T_C= 500.; # in K
Q_A= 1200.; # in kJ
# Calculations
# Q_B+Q_C= Q_A-200 (i)
# Q_A/T_A = Q_B/T_B+Q_C/T_C (ii)
# From eq(i) and (ii)
Q_B= (Q_A*(1/T_B-1/T_A)-200/T_B)/(1/T_B-1/T_C); # in kJ
Q_C= Q_A-Q_B-200; # in kJ
# Results
print "The heat rejected at B in kJ is : %.2f"%Q_B
print "The heat rejected at C in kJ is : %.2f"%Q_C
```

In [18]:

```
# Variables
T1= 180+273; # in K
T2= 20+273; # in K
# Calculations
# W_A/Q1= 1-T3/T1 (i)
# W_B/QB= 1-T2/T3 (ii)
# W_A= W_B (iii)
# Q1= Q_B+W_A (iv)
# From eq(i),(ii),(iii) and (iv)
T3= (T1+T2)/2; # in K
# Results
print "intermediate temperature in °C is : ",T3-273
```

In [14]:

```
# Variables
Q2 = 1.75; # in kJ/sec
T1 = -15; # in °C
T1 = T1 + 273; # in K
T2 = 30; # in °C
T2 = T2 + 273; # in K
# Calculations
del_T = T2 - T1; # in K
# Q2/W_net = T2/(del_T)
W_net = Q2 * del_T/T1; # in kW
# Results
print "Least power required in kW is : %.3f"%W_net
```