In [2]:

```
# Variables :
Q2 = 1800.; #KJ/hr
Q2 = Q2/3600; #KJ/sec or KW
W = 0.35; #KW
# Calculations
COP = Q2/W;
# Results
print "COP is : %.4f"%COP
```

In [2]:

```
# Variables :
Q2 = 1; #KJ/sec or KW
W = 0.4; #KW
T2 = -30+273; #K
# Calculations and Results
COP = Q2/W;
print "COP of refrigerator is : ",COP
T1 = T2*(1+COP)/COP; #K
print "Temperature at which heat is rejected in K : ",T1
Q1 = Q2*(1+COP)/COP; #KW
print "Heat rejected per KW of cooling(KW) : ",Q1
```

In [9]:

```
# Variables :
Q2 = 100.; #KJ/sec or KW
T2 = -20.+273; #K
T1 = 35.+273; #K
# Calculations and Results
COP = T2/(T1-T2);
print "COP is : ",COP
W = Q2/COP; #KW
print "Power input in KJ/s or KW : %.2f"%W
COPheatpump = T1/(T1-T2); #
print "COP as heat pump : ",COPheatpump
Eta_engine = (1-T2/T1)*100;
print "Efficiency as an engine in : %.3f"%(Eta_engine)
```

In [10]:

```
# Variables :
Q2dot = 12000.; #KJ/hr
Wdot = 0.75; #KW
Wdot = Wdot*3600.; #KJ/hr
# Calculations and Results
COP = Q2dot/Wdot;
print "Coefficient of Performance is : %.3f"%COP
Q1dot = Q2dot+Wdot; #KJ/hr
print "Heat transfer rate in condenser in KJ/hr : %.0f"%Q1dot
```

In [11]:

```
from numpy import *
# Variables :
Eta1 = 25./100; #efficiency
deltaT = 20.; #degree centigrade
# Calculations
#T2dash = T2-20; #K
#T1dash = T1; #K
deltaEta1 = 30./100;
Eta_dash = 30./100; #efficiency
#Eta1/Eta_dash = (1-T2dash/T1dash)/(1-T2/T1)
#T1-T2 = 100;
#0.75*T1-T2 = 0;
A = array([[1, -1],[0.75, -1]])
B = array([100,0])
X = linalg.solve(A,B);
#Solution for T1 and T2 by matrix
T1 = X[0]; #K
T2 = X[1]; #K
# Results
print "Source temperature in K : %.0f"%T1
print "Sink temperature in K : %.0f"%T2
```

In [12]:

```
# Variables :
T1 = 23.+273; #K
COP_HP = 2.5;
HeatLost = 60000.; #KJ/hr
HeatGenerated = 4000.; #KJ/hr
# Calculations
Q1 = HeatLost-HeatGenerated; #KJ/hr
W = Q1/COP_HP; #KJ/hr
W = W/3600; #KJ/s or KW
# Results
print "Power input in KW : %.3f"%W
```

In [13]:

```
# Variables :
T1 = 400.+273; #K
T2 = 20.+273; #K
T3 = 100.+273; #K
T4 = T2; #K
Q1 = 12000.; #KW
Q3 = 25000.; #KW
# Calculations and Results
Eta1 = 1-T2/T1; #Efficiency
W1 = Eta1*Q1; #KW
print "Power of Engine 1, W1 in KW : %.2f"%W1
Eta2 = 1-T4/T3; #Efficiency
W2 = Eta2*Q3; #KW
print "Power of Engine 2, W2 in KW : %.2f"%W2
print ("W1>W2, The engine 1 delivers more power.");
```

In [14]:

```
from numpy import *
# Variables :
Wdot = 200.; #W
t1 = 40.; #degree centigrade
# Calculations
#Q2dot = 20*(t1-t2); #W
#COP = Q2dot/W2dot = T2/(T1-T2)
#(t1-t2)/(W2dot/20) = (t1+273)/(t1-t2)
#20*t1**2+20*t2**2-20*2*t1*t2-t1*Wdot-273*Wdot
#(t2+273)/(t1-t2) = (t1-t2)/(Wdot/20)
#t2**2-(2*t1+(Wdot/20))*t2-273*(Wdot/20)+t1**2
P = array([1, -(2*t1+(Wdot/20)), -273*(Wdot/20)+t1**2])
t2 = roots(P);
t2 = t2[1]; #degree C
# Results
#Taken only -ve value as t2 cant be greater than t1
print "Temperature of cold space(degree C) %.2f"%t2
```

In [15]:

```
# Variables :
m = 0.8; #Kg
hi = 335.; #KJ/Kg-water
T1 = 24.+273; #K
T2 = 0.+273; #K
Wdot = 400.; #W
Wdot = Wdot/1000.; #KW
# Calculations
Q2 = m*hi; #KJ
ActualCOP = T2/(T1-T2)*30/100;
Q2dot = ActualCOP/Wdot; #KJ/s
T = Q2/Q2dot; #sec
# Results
print "Time required to freeze the water in sec : %.2f"%T
```

In [14]:

```
# Variables :
T1 = 727.+273; #K
T2 = 27.+273; #K
Wdot = 76.; #KW
FuelBurned = 4.; #Kg/hr
FuelBurned = 4./3600; #Kg/sec
FuelHeatingValue = 75000.; #KJ/Kg
# Calculations and Results
Q1dot = FuelBurned*FuelHeatingValue; #KJ/s or KW
Eta = Wdot/Q1dot*100; #%
print "Actual Efficiency of Engine in % : ",Eta
Eta_c = (1-T2/T1)*100; #%
print "Carnot Efficiency of Engine in % : ",Eta_c
print ("Claim of inventor is wrong as actual efficiency is greater than carnot efficiency.");
```

In [5]:

```
# Variables :
T1 = 24.+273; #K
T2 = 10.+273; #K
Q1 = 1500.; #kJ/min
Q1 = Q1/60.; #kW
# Calculations
COP_ideal = T1/(T1-T2);
ActualCOP = COP_ideal*30/100;
W = Q1/ActualCOP; #kW
# Results
print "Power required in kW : %.3f"%W
#Answer is wrong in the book as calculation for Q1 is wrong.
```

In [33]:

```
# Variables :
T1 = 450.; #K
T2 = 280.; #K
Q1 = 1200.; #KJ
W = 0.15; #KWh
W = W*3600.; #KJ
# Calculations and Results
Eta_a = W/Q1*100; #%
print "Actual Efficiency of Engine in % : ",Eta_a
Eta_c = (1-T2/T1)*100; #%
print "Carnot Efficiency of Engine in %% : %.1f"%(Eta_c)
print ("We would not issue a patent as actual efficiency is greater than carnot efficiency.");
```

In [31]:

```
# Variables :
T1 = 1000.; #K
T3 = 100.; #K
Q1 = 1680.; #KJ
#Eta_a = Eta_b : 1-T2/T1 = 1-T3/T2
T2 = math.sqrt(T1*T3); #K
Eta_a = 1-T2/T1;
Eta_b = Eta_a;
W1 = Eta_a*Q1; #KJ
Q2 = Q1-W1; #KJ
Q3 = (1-Eta_b)*Q2; #KJ
print "Heat rejected by engine B in KJ : ",Q3
print "Temperature at which heat is rejected by engine A in K : %.2f"%T2
print "Workdone by engine A in KJ ; %.2f"%W1
W2 = Eta_b*Q2; #KJ
print "Workdone by engine B in KJ ; %.2f"%W2
#If W1 = W2
#Q/T = constant
T2 = (T1+T3)/2; #K
Eta_a = (1-T2/T1)*100; #%
Eta_b = (1-T3/T2)*100; #%
print ("If Engine A & B deliver equal work.")
print "of Engine A in %% : %.2f"%Eta_a
print "of Engine B in %% : %.2f"%Eta_b
```

In [34]:

```
# Variables :
T1 = 800.+273; #K
T2 = 30.+273; #K
T3 = 30.+273; #K
T4 = -15.+273; #K
Q1 = 1900.; #KJ
W2 = 290.; #KJ
# Calculations and Results
#Eta = 1-T2/T1 = W1/Q1
W1 = (1-T2/T1)*Q1; #KJ
Q2 = Q1-W1; #KJ
W3 = W1-W2; #KJ
#COP = T4/(T3-T4) = Q4/W3
Q4 = T4/(T3-T4)*W3; #KJ
print "Heat absorbed by refrigerant in KJ : %.2f"%Q4
Q3 = W3+Q4; #KJ
TotalHeat = Q2+Q3; #KJ
print "Total Heat transferred to reservoir at 30 degree centigrade in KJ : %.2f"%TotalHeat
```

In [35]:

```
# Variables :
T1 = 840.+273; #K
T2 = 60.+273; #K
T3 = 5.+273; #K
W3 = 30.; #KW
Q3 = 17.; #KJ/s
# Calculations
#Q3/T3 = Q4/T4
T4 = T2; #K
Q4 = Q3/T3*T4; #KJ/s
W2 = Q4-Q3; #KJ/s
W1 = W2+W3; #KJ/s
Q1subQ2 = W1; #KJ/s
#Q1/T1 = Q2/T2
Q1ByQ2 = T1/T2;
#Q1subQ2 = Q1subQ2*Q2-Q2
Q2 = Q1subQ2/(Q1ByQ2-1); #KW
Q1 = Q1ByQ2*Q2; #KW
# Results
print "Rate of heat supply from 800 degree C source in KW : %.1f"%Q1
print "Rate of heat rejection to sink in KW : %.3f"%(Q2+Q4)
```

In [6]:

```
# Variables :
T1 = 27.+273; #K
T2 = -23.+273; #K
W = 1.; #KW
Q2 = 20000.; #KJ/hr
# Calculations and Results
Q2 = Q2/3600; #KJ/s
ActualCOP = Q2/W;
print "COP of machine : %.3f"%ActualCOP
IdealCOP = T2/(T1-T2);
print "Ideal COP of machine : %.0f"%IdealCOP
print ("ActualCOP>IdealCOP, Inventor's claim is wrong.");
```

In [39]:

```
from numpy import *
# Variables :
#Heat Pump in winter
Q1 = 2400.; #KJ/hr/degree temperature difference
t1 = 20.; #degreeC
t2 = 0.; #degreeC
# Calculations and Results
Q1 = Q1*(t1-t2)/3600; #KJ/s
T1 = t1+273; #K
T2 = t2+273; #K
COP = T1/(T1-T2);
W = Q1/COP; #KW
print "Power required to drive heat pump in KW : %.2f"%W
#Refrigerating unit in summer
T4 = 20+273; #K
#Q4 = 2400*(T3-T4)/3600; #KJ/s
Q3subQ4 = W; #KJ
#COP = Q4/(Q3subQ4) = T4/(T3-T4);
#T3**2-2*T3*T4+T4**2-T4*3600/2400*(Q3subQ4) = 0
P = array([1, -2*T4, T4**2-T4*3600./2400*(Q3subQ4)])
T3 = roots(P);
T3 = T3[0]; #K(Maximum outside temperature)
print "Maximum outside temperature in K : %.0f"%T3
print "in degree C : %.0f"%(T3-273)
```

In [40]:

```
# Variables :
VcByVa = 14.; #Overall expansion ratio
T1 = 257+273.; #K
T2 = 27+273.; #K
Gamma = 1.4;
Ta = T1; #K
Tb = T1; #K
Tc = T2; #K
Td = T2; #K
# Calculations and Results
VcByVb = (Tb/Tc)**(1/(Gamma-1)); #Expansion ratio for Adiabatic Process :
print "ratio for adiabatic process : %.2f"%VcByVb
VbByVa = VcByVa/VcByVb; #Expansion ratio for Isothermal Process :
print "Expansion ratio for Isothermal process : %.3f"%VbByVa
Eta = (1-T2/T1)*100; #%
print "Thermal Efficiency of carnot cycle in %% : %.1f"%Eta
```

In [41]:

```
# Variables :
W = 10.; #KW
#For flat plate collector
T1 = 90.+273; #K
T2 = 27.+273; #K
Tmax = T1; #K
IE = 1.; #KW/m**2 incident energy
EtaCollection = 60./100;
# Calculations and Results
#Eta = 1-T2/T1 = W/Q1
Q1 = W/(1-T2/T1); #KJ/s
A1 = Q1/IE/EtaCollection; #m**2
print "Solar Collector Area required in m**2 : %.3f"%A1
#For parabolic collector
T3 = 250.+273; #K
T4 = 27.+273; #K
Tmax = T3; #K
IE = 1.; #KW/m**2 incident energy
EtaCollection = 50./100;
#Eta = 1-T2/T1 = W/Q1
Q3 = W/(1-T4/T3); #KJ/s
A2 = Q3/IE/EtaCollection; #m**2
print "Parabolic Solar Collector Area required in m**2 : %.3f"%A2
#Answer of 2nd part is wrong in the book.
```

In [42]:

```
# Variables :
T1 = 40.+273; #K
T2 = 5.+273; #K
T3 = 400.+273; #K
T4 = T1; #K
Q2 = 1500.; #KJ/min
# Calculations and Results
COP_R = T2/(T1-T2);
print "COP of refrigerator is : %.3f"%COP_R
Q2dot = Q2/60; #KJ/s
Wdot = Q2dot/COP_R; #KW
print "Work Input to refrigerator in KW : %.4f"%Wdot
Eta = (1-T4/T3); #%
Q3dot = Wdot/Eta; #KW
OverallCOP = Q2dot/Q3dot; #
print "Overall COP of refrigerator : %.4f"%OverallCOP
#Ans of overall COP is wrong in the book.
```

In [43]:

```
# Variables :
T1 = 1500.; #K
T2 = 450.; #K
T3 = 150.; #K
Q3 = 250.; #KJ
# Calculations and Results
COP_CR = T3/(T2-T3);
print "COP of cold refrigerator is : %.1f"%COP_CR
COP_HR = T2/(T1-T2);
print "COP of hotter refrigerator is : %.4f"%COP_HR
COP = T3/(T1-T3);
print "COP of composite system is : %.3f"%COP
```

In [45]:

```
# Variables :
T1 = 870.; #K
T2 = 580.; #K
T3 = 290.; #K
Wdot = 85.; #KW
Q3 = 3000.; #KJmin
Q3 = Q3/60.; #KJ/s
Q1plusQ2 = Wdot+Q3; #KJ
#sigma(Q/T) = 0
#Q1/T1+Q2/T2 = Q3/T3
#Q1/T1+(Q1plusQ2-Q1)/T2-Q3/T3 = 0
Q1 = (-Q3*T1*T2/T3+Q1plusQ2*T1)/(T1-T2); #KW
print "Heat Supplied by source1 in KW : %.0f"%Q1
Q2 = Q1plusQ2-Q1; #KW
print "Heat Supplied by source2 in KW : %.0f"%Q2
Eta = Wdot/(Q1+Q2)*100; #%
print "Efficiency of engine in %% : %.2f"%Eta
```