In [2]:

```
from __future__ import division
#Variable Declaration:
Q1 = 500 #Heat extracted by carnot cycle(in kJ/min):
T1 = -16+273 #Temperature of refrigerated space(in K):
T2 = 27+273 #Atmospheric temperature(in K):
#Calculations:
Q2 = Q1*(T2/T1) #Heat rejected(in kJ/min):
W = Q2-Q1 #Work input required(in kJ/min):
#Results:
print "Work input: ",round(W,2),"kJ/min"
```

In [4]:

```
from __future__ import division
#Variable Declaration:
T1 = -5+273 #Operating temperature(in K):
T2 = 27+273
Cpw = 4.18 #Specific heats(in kJ/kg.K):
L = 335 #Latent heat(in kJ/kg):
C = 800 #Capacity(in tons):
#Calculations:
q = C*3.5 #Heat extraction rate(in kJ/s):
q1 = Cpw*(27-0)+L #Heat to be removed per kg of water(in kJ/kg):
m = q/q1 #Ice formation rate(in kg/s):
COP = (T1/(T2-T1)) #COP:
W = q/COP/0.7457 #Work done(in hp):
print "Mass rate of ice formation: ",round(m,2),"kg/s"
print "HP required: ",round(W,2),"hp"
```

In [6]:

```
from __future__ import division
#Variable Declaration:
W = 3 #Work done(in hp):
T1 = -27+273 #Temperature to be maintained(in K):
#Calculations:
COP = 1*3.5/(W*0.7457)#COP:
T2 = T1+T1/COP #Temperature of surroundings(in K):
#Results:
print "COP: ",round(COP,2)
print "Temperature of surroundings: ",round(T2,2),"K"
```

In [7]:

```
from __future__ import division
#Variable Declaration:
r1 = 8 #Pressure ratio:
T1 = -33+273 #Operating temperatures(in K)
T3 = 27+273
nic = 0.85 #Isentropic efficiency of compression:
nie = 0.90 #Isentropic efficiency of expansion:
Cp = 1.005 #Specific heat(in kJ/kg):
r = 1.4 #Adiabatic index of compression:
m = 1 #Air flow rate(in kg/s):
#Calculations:
T2a = T1*(r1)**((r-1)/r) #Temperature at state 2'(in K):
T2 = (T2a-T1)/nic+T1 #Temperature at state 2(in K):
T4a = T3*(1/r1)**((r-1)/r) #Temperature at state 4'(in K):
T4 = T3-(T3-T4a)*nie #Temperature at state 2'(in K):
Wc = Cp*(T2-T1) #Work during compression(in kJ/s):
Wt = Cp*(T3-T4) #Work during expansion(in kJ/s):
Qref = Cp*(T1-T4) #Refrigeration effect(in kJ/s):
W = Wc-Wt #Net work required(in kJ/s):
COP = Qref/W #COP:
#Results:
print "Refrigeration capacity: ",round(Qref,2),"kJ/s"
print "COP: ",round(COP,2)
```

In [9]:

```
from __future__ import division
#Variable Declaration:
T1 = 7+273 #Operating temperatures(in K)
T3 = 27+273
p1 = 1 #Pressures(in bar):
p2 = 5
r = 1.4 #Adiabatic index of compression:
Cp = 1.005 #Specific heat(in kJ/kg):
T2 = T1*(p2/p1)**((r-1)/r) #Temperature at state 2(in K):
T4 = T3/((p2/p1)**((r-1)/r)) #Temperature at state 4(in K):
Q23 = Cp*(T2-T3) #Heat rejected in process 2-3(in kJ/kg):
Q41 = Cp*(T1-T4) #Heat picked during process 4-1(in kJ/kg):
W = Q23-Q41 #Net work(in kJ/kg):
COP = Q41/W #COP:
#Results:
print "COP: ",round(COP,2)
```

In [12]:

```
from __future__ import division
#Variable Declaration:
p1 = 1 #Pressure(in bar):
p2 = 5.5
T1 = -10+273 #Operating temperatures(in K):
T3 = 27+273
m = 0.8 #Air flow rate(in kg/s):
Cp = 1.005 #Specific heat(in kJ/kg):
r = 1.4 #Adiabatic index of compression:
R = 0.287 #Gas constant(in kJ/kg.K):
#Calculations:
T2 = T1*(p2/p1)**((r-1)/r) #Temperature at state 2(in K):
T4 = T3/((p2/p1)**((r-1)/r)) #Temperature at state 4(in K):
C = m*Cp*(T1-T4) #Refrigeration capacity(in kJ/s):
Wc = m*r/(r-1)*R*(T2-T1) #Work required to run the comoressor(in kJ/s):
W = m*Cp*((T2-T3)-(T1-T4)) #Net work input(in kJ/s):
COP = C/W #COP:
#Results:
print "Refrigeration capacity: ",round(C,2),"kJ/s"
print "HP required to run compressor: ",round(Wc/0.7457,2),"hp"
print "COP: ",round(COP,2)
```

In [14]:

```
from __future__ import division
#Variable Declaration:
p1 = 1.2 #Pressure(in bar):
p6 = p1
p3 = 4
p2 = p3
p4 = 1
p7 = 0.9
T1 = 288 #Temperatures(in K):
T6 = T1
T5 = 25+273
T3 = 323
T8 = 30+273
n = 1.45
n1 = 1.3
T2 = T1*(p2/p1)**((n-1)/n) #Temperature at state 2(in K):
T2 = 418.47
Cp = 1.005
#Calculations:
T4 = T3*(p4/p3)**((n1-1)/n1) #Temperature at state 4(in K):
T4 = 234.57
m = 10*3.5/(Cp*(T5-T4)) #Refrigeration effect(in kg/s):
T7 = T6*(p7/p6)**((n1-1)/n1) #Temperature at state 7(in K):
rm = m*(T2-T3)/(T8-T7)+m #Ram air mass flow rate(in kg/s):
W = m*Cp*(T2-T1) #Work input to the compressor(in kJ/s):
COP = 10*3.5/W #COP:
#Results:
print "Air mass flow rate in cabin: ",round(m,2),"kg/s"
print "Ram air mass flow rate: ",round(rm,2),"kg/s"
print "COP: ",round(COP,3)
```

In [16]:

```
from __future__ import division
#Variable Declaration:
p0 = 0.9 #Pressures(in bar):
p1 = 1
p2 = 4
p3 = p2
p4 = p3
p5 = 1.03
T6 = 298 #Temperatures(in K):
T0 = 276
Cp = 1.005 #Specific heat(in kJ/kg):
r = 1.4 #Adiabatic index of compression:
C = 15 #Refrigeration capacity:
nic = 0.9 #Isentropic efficiency for compressor:
nit = 0.8 #Isentropic efficiency for turbine:
#Calculations:
T1 = T0*(p1/p0)**((r-1)/r) #Temperature at state 1(in K):
T2a = T1*(p2/p1)**((r-1)/r) #Temperature at state 2'(in K):
T2 = T1+(T2a-T1)/nic #Temperature at state 2(in K):
T3 = 0.34*T2 #Temperature at state 3(in K):
T4 = T3-10 #Temperature at state 4(in K):
T5a = T4*(p5/p4)**((r-1)/r) #Temperature at state 5'(in K):
T5 = T4-(T4-T5a)*nit #Temperature at state 5(in K):
m = C*3.5/(Cp*(T6-T5)) #Mass flow rate(in kg/s):
W = m*Cp*(T2-T1) #Work input(in kJ/s):
COP = C*3.5/W #COP:
#Results:
print "COP: ",round(COP,2)
print "HP required: ",round(W/0.7457,2),"hp"
```

In [20]:

```
from __future__ import division
#Variable Declaration:
T1 = -15+273 #Operating temperatures(in K):
T2 = 25+273
h2 = 1317.95 #kJ/kg
s2 = 4.4809 #kJ/kg.K
h3 = 99.94 #kJ/kg
s3 = 0.3386 #kJ/kg.K
h9 = -54.51 #kJ/kg
s9 = -0.2132 #kJ/kg.K
s4 = 0.3855 #kJ/kg.K
#Calculations:
h4 = h3
s8 = s3
s1 = s2
C = T1*(s1-s4) #Refrigeration effect(in kJ/kg):
W = h3-h9-T1*(s3-s9)+(T2-T1)*(s1-s8) #Work done(in kJ/kg):
COP = C/W #COP:
#Results:
print "COP: ",round(COP,2)
```

In [22]:

```
from __future__ import division
from math import e
#Variable Declaration:
T1 = -20+273 #Operating temperature(in K):
T3 = 40+273
p2 = 9.61 #Pressures(in bar):
p1 = 1.51
n = 1.13
N = 1200 #Speed(in rpm):
h1 = 178.61 #kJ/kg
h3 = 73.53 #kJ/kg
h4 = h3
s1 = 0.7082 #kJ/kg.K
s2 = s1
sg = 0.682 #kJ/kg.K
Cpg = 0.747 #kJ/kg.K
hg = 203.05 #kJ/kg
vg = 0.1088 #m**3/kg
m1 = 2.86 #ton
C = 0.02 #Clearance volume:
#Calculations:
T2 = T3*(e)**((s1-sg)/Cpg) #Temperature of state 2(in K):
h2 = hg+Cpg*(T2-T3) #Enthalpy after compression(in kJ/kg):
Wc = h2-h1 #Compression work(in kJ/kg):
r = h1-h4 #Refrigeration effect(in kJ/kg):
m = m1*3.5/r #Mass flow rate(in kg/s):
COP = r/Wc #COP:
nv = 1+C-C*(p2/p1)**(1/n) #Volumetric efficiency:
V = m*60*vg/(nv*N) #Piston printlacement(in m**3):
#Results:
print "COP: ",round(COP,3)
print "Piston printlacement: ",round(V*10**6,2),"cm**3"
```

In [24]:

```
from __future__ import division
#Variable Declaration:
#From steam tables:
h1 = 322.28 #kJ/kg
h2 = 342.32 #kJ/kg
s2 = 1.1937 #kJ/kg.K
x1 = 0.961
h1 = 312.08 #kJ/kg
h3 = 144.11 #kJ/kg
h4 = 115.22 #kJ/kg
m1 = 2 #Refrigeration effect(in kW):
#Calculations:
s1 = s2
h5 = h4
r = h1-h5 #Refrigeration effect(in kJ/kg):
m = m1/r #Refrigerant flow rate(in kg/s):
Wc = h2-h1 #Compressor work(in kJ/kg):
COP = r/Wc #COP:
#Results:
print "COP: ",round(COP,2)
print "Mass flow rate: ",round(m,4),"kg/s"
```

In [27]:

```
from __future__ import division
#Variable Declaration:
w = 0.016 #Specific humidity(in gm/kg):
pvsat = 0.03098 #Saturated partial pressure of vapour(in bar):
pv = w/0.622*1.013/(1+w/0.622)#Partial pressure of vapour(in bar):
r = pv/pvsat*100 #Relative humidity:
#Calculations:
print "Partial pressure of vapour: ",round(pv,4)
print "Relative humidity: ",round(r,2),"%"
```

In [28]:

```
from __future__ import division
#Variable Declaration:
r = 0.6 #Relavite humidity
pvsat = 0.0425 #Saturation pressure(in bar):
R = 0.287 #Gas constant(in kJ/kg.K):
Ta = 303 #Surrounding temperature(in K):
hg = 2504.1 #kJ/kg
Cp = 1.005 #Specific heat(in kJ/kg.K):
T = 21.4 #Dew point temperature(in C) from steam table:
pv = 0.0255 #partial pressure of vapour(bar) from steam table:
#Calculations:
pa = 1.013-r*pvsat #Partial pressure of air(in bar):
w = 0.622*(pv/(1.013-pv)) #Humidity ratio:
d = 1.013*10**2*(1+w)/(R*Ta) #Density of mixture(in kg/m**3):
h = Cp*30+w*(hg+1.860*(30-T))#Enthalpy of mixture(in kJ/kg of dry air):
#Results:
print "Partial pressure of air: ",round(pa,4),"bar"
print "Humidity ratio: ",round(w,5),"jg/kg of dry air"
print "Dew point temperature: ",round(T,1),"°C"
print "Density: ",round(d,4),"kg/m**3"
print "Enthalpy of mixture: ",round(h,1),"kJ/kg of air"
```

In [30]:

```
from __future__ import division
#Variable Declaration:
r = 0.80 #Relavite humidity
#From pyschometric chart:
w1 = 0.0086 #kg/kg of air
w2 = 0.01 #kg/kg of air
h1 = 37 #kJ/kg
h2 = 50 #kJ/kg
v2 = 0.854 #m**3/kg
#Calculations:
m = w2-w1 #Mass of water added between states 1 and 2:
ma = r/v2 #Mass flow rate:
m1 = m*ma #Total mass of water added(in kg/s):
q = ma*(h2-h1) #Heat transferred(in kJ/s):
#Results:
print "Mass of water added: ",round(m1,6),"kg/s"
print "Heat transferred: ",round(q,2),"kJ/s"
```

In [32]:

```
from __future__ import division
#Variable Declaration:
m1 = 3 #Mass flow rate(in kg/s):
m2 = 2
Cp = 1.005 #Specific heat(in kJ/kg.K):
Cps = 1.86 #Specofoc heat of stream(in kJ/kg.K):
r1 = 0.30 #Relative humidity:
r2 = 0.85
#From psychometric chart:
pvsat1 = 0.04246 #bar
pvsat2 = 0.005628
hg1 = 2520.7 #kJ/kg
hg2 = 2559.9 #kJ/kg
T1 = 30 #°C
Tdp1 = 10.5
T2 = 35
Tdp2 = 32
#Calculations:
pv1 = pvsat1*r1 #Partial pressure of vapour at 1(in bar):
w1 = 0.622*pv1/(1.013-pv1) #Specific humidity:
h1 = Cp*T1+w1*(hg1-Cps*(T1-Tdp1)) #Enthalpy at state 1(in kJ/kg):
pv2 = pvsat2*r2 #Partial pressure at state 2(in bar):
w2 = 0.622*pv2/(1.013-pv2) #Specific humidity:
h1 = Cp*T2+w2*(hg2-Cps*(T2-Tdp2)) #Enthalpy at state 1(in kJ/kg):
mmix = 1/(m1+m2)*(w1*m1/(1+w1)+w2*m2/(1+w2)) #Mass of vapour:
wmix = mmix/(1-mmix) #Specific humidity of mixture:
pv = 1.013*wmix/0.622/(1+w1/0.622) #Partial pressure of water vapour(in bar):
#Results:
print "Specific humidity of mixture: ",round(wmix,5),"kg/kg of dry air"
print "Partial pressure of water vapour in mixture: ",round(pv,5),"bar"
```

In [35]:

```
from __future__ import division
#Variable Declaration:
r = 3 #Rate at which air enters(in m**3/s):
h1 = 36.4 #kJ/kg #From steam tables:
h2 = 52 #kJ/kg
v1 = 0.825 #m**3/kg
#Calculations:
m = 3/v1 #Mass of air(in kg/s):
q = m*(h2-h1) #Amount of heat added(in kJ/s):
#Results:
print "Heat added: ",round(q,2),"kJ/s"
```