In [2]:

```
#
# Variables
#(a)
m = 50.; #[kg] - Mass of piston
A = 0.05; #[m**(2)] - Area of piston
g = 9.81; #[m/s**(2)] - Acceleration due to gravity
Po = 101325; #[N/m**(2)] - Atmospheric pressure
# Calculations and Results
P = (m*g/A)+Po; #[N/m**(2)]
P = P/100000.; #[bar]
print " (a).Pressure = %f bar"%P
#(b)
print " (b).Since the piston weight and surroundings pressure are the same, \
the gas pressure in the piston-cylinder assembly remains %f bar"%P
```

In [3]:

```
# Variables
P = 1.; #[atm] - Atmospheric pressure
P = 101325.; #[N/m**(2)]
R = 8.314; #[J/mol*K] - Universal gas constant
T = 30.; #[C] - Temperature of air
T = 30.+273.15; #[K]
V = 5.*5*5; #[m**(3)] - Volume of the room
# Calculations
#The number of moles of air is given by
n = (P*V)/(R*T) #[mol]
#Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol
m = n*28.84; #[g]
m = m/1000.; #[kg]
# Results
print "The mass of air is, m = %f kg"%m
```

In [4]:

```
# Variables
P1 = 3.; # [bar] - initial pressure
V1 = 0.5; # [m**(3)] - initial volume
V2 = 1.0; # [m**(3)] - final volume
import math
#(a)
n = 1.5;
# Calculations and Results
#Let P*V**(n)=C # Variables relation
#W (work done per mole)= (integrate('P'%'V'%V1%V2))
#and thus W=((P2*V2)-(P1*V1))/(1-n)
#The above math.expression is valid for all values of n%except n=1.0
P2 = (P1*((V1/V2)**(n))) #[bar] #pressure at state 2
#we have%(V1/V2)=(V1t/(V2t)%since the number of moles are constant.Thus
W = ((P2*V2)-(P1*V1))/(1-n)*10**(5) #[J]
W = W/1000.; #[kJ]
print " (a).The work done (for n=1.5) is %f kJ"%W
#(b)
#For n=1.0%we have% PV=C.
# w(wok done per mol)= (integrate('P'%'V'%V1%V2)) = (integrate('C/V'%'V'%V1%V2)) = C*ln(V2/V1)=P1*V1*ln(V2/V1)
W1 = P1*V1*math.log(V2/V1)*10**(5) #[J]
W1 = W1/1000.; #[kJ]
print " (b).The work done (for n=1.0) is %f kJ"%W1
#(c)
#For n=0%we get P=Constant and thus
P = P1; #[bar]
# w =(integrate('P'%'V'%V1%V2)) = P*(V2-V1)
W2 = P*(V2-V1)*10**(5) #[J]
W2 = W2/1000.; #[kJ]
print " (c).The work done (for n=0) is %f kJ"%W2
```

In [5]:

```
# Variables
#(a)
# Variables
V = 9.; # [m/s] - velocity
d = 1.; #[m] - diameter
A = 3.14*(d/2)**(2) #[m**(2)] - area
P = 1.; #[atm] - pressure
P = 101325.; # [N/m**(2)]
T = 300.; #[K] - Temperature
R = 8.314; #[J/mol*K] - Universal gas constant
# Calculations and Results
E = (V**(2))/2.; #[J/kg]
print " (a).The wind energy per unit mass of air is %f J/kg"%E
#(b)
# Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol
M = 28.84*10**(-3) #[kg/mol]
r = (P*M)/(R*T) #[kg/m**(3)] - density
m = r*V*A; # [kg/s] - mass flow rate of air
pi = m*E; #[Watt] - power input
print " (b).The wind power input to the turbine is %f Watt"%pi
```

In [6]:

```
# Given
P = 1.; # [bar] - atospheric pressure
P1guz = 0.75; # [bar] - gauze pressure in 1st evaporator
P2Vguz = 0.25; # [bar] - vaccum gauze pressure in 2nd evaporator
# Calculations
P1abs = P + P1guz; # [bar] - absolute pressure in 1st evaporator
P2abs = P - P2Vguz; # [bar] -absolute pressure in 2nd evaporator
# Results
#From saturated steam table as reported in the book
print " For P1abs (absolute pressure) = %f bar"%P1abs
print " The saturation temperature in first evaporator is 116.04 C"
print " For P2abs (absolute pressure) = %f bar"%P2abs
print " The saturation temperature in second evaporator is 91.76 C"
```

In [7]:

```
# Variables
V = 1.; # [kg] - volume of tank
P = 10.; # [bar] - pressure
#Here degree of freedom =1(C=1%P=2%threfore F=1)
#From steam table at 10 bar as reported in the book
V_liq = 0.001127; # [m**(3)/kg] - volume in liquid phase
V_vap = 0.19444; # [m**(3)/kg] - volume in vapour phase
# Calculations
#x*Vv=(1-x)*Vl # since two volumes are equal
x = (V_liq/(V_liq+V_vap)) # [kg]
y = (1-x) #[kg]
# Results
print " Mass of saturated vapour is %f kg"%x
print " Mass of saturated liquid is %f kg"%y
```

In [8]:

```
# Variables
V = 1.; # [m**(3)] - volume of tank
M = 10.; # [m**(3)] - total mass
T = (90+273.15) #[K] - temperature
#From steam table at 90 C as reported in the book
#vapour pressure(pressure of rigid tank) = 70.14[kPa] = 0.7014[bar]
print " Pressure of tank = 0.7014 bar"
# Calculations and Results
V_liq_sat=0.001036; # [m**(3)/kg] - saturated liquid specific volume
V_vap_sat=2.36056; # [m**(3)/kg] - saturated vapour specific volume
#1=(V_liq_sat*(10-x))+(V_vap_sat*x)
x = (1-(10*V_liq_sat))/(V_vap_sat-V_liq_sat) #[kg]
y = (10-x) #[kg]
print " The amount of saturated liquid is %f kg"%y
print " The amount of saturated vapour is %f kg "%x
z = y*V_liq_sat; #[m**(3)] - Volume of saturated liquid
w = x*V_vap_sat; #[m**(3)] - Volume of saturated vapour
print " Total volume of saturated liquid is %f m**(3)"%z
print " Total volume of saturated vapour is %f m**(3)"%w
```

In [9]:

```
# Variables
V = 10.; # [m**(3)] - volume of vessel
P_1 = 1.; # [bar] - initial pressure
V_liq_sat = 0.05; # [m**(3)] - saturated liquid volume
V_gas_sat = 9.95; # [m**(3)] - saturated vapour volume
#At 1 bar pressure
V_liq_1 = 0.001043; # [m**(3/kg)] - specific saturated liquid volume
U_liq_1 = 417.33; # [kJ/kg] - specific internal energy
V_gas_1 = 1.69400; # [m**(3/kg)] - specific saturated vapour volume
U_gas_1 = 2506.06; # [kJ/kg]
# Calculations
M_liq_1 = V_liq_sat/V_liq_1; # [kg] - mass of saturated liqid
M_gas_1 = V_gas_sat/V_gas_1; # [kg] - mass of saturated vapour
M = (M_liq_1+M_gas_1) # [kg] - total mass
U_1t = (M_liq_1*U_liq_1)+(M_gas_1*U_gas_1) # [kJ] - initial internal energy
V_gas_2 = (V/M) #[m**(3/kg)]
#from steam table at 10 bar pressure as reported in the book
V_vap_2 = 0.19444; # [m**(3/kg)]
U_vap_2 = 2583.64; # [kJ/kg]
#from steam table at 11 bar pressure as reported in the book
V_vap_3 = 0.17753; #[m**(3/kg)]
U_vap_3 = 2586.40; #[kJ/kg]
#Now computing pressure when molar volume of saturated vapour=Vg_2
#By interpolation (P2-10)/(11-10)=(Vg_2-Vv_2)/(Vv_3-Vv_2)
P_2 = (((V_gas_2 - V_vap_2)/(V_vap_3 - V_vap_2)*1)+10) # [bar] - final pressure
#By interpolation calculating internal energy at state 2
#(P2-10)/(11-10)=(U2-Uv_2)/(Uv_3-Uv_2)
U_2 = (((P_2-10)/(11-10))*(U_vap_3 - U_vap_2))+U_vap_2; #[kJ/kg]
U_2t = U_2*M; #[kJ]
H = U_2t - U_1t; #[kJ] - Heat supplied
H = H/1000; #[MJ]
# Results
print " Total heat supplied is %f MJ"%H
```

In [10]:

```
# Variables
#Antoine equation for water ln(Psat)=16.262-(3799.89/(T_sat + 226.35))
P = 2.; #[atm] - Pressure
P = (2.*101325)/1000; #[kPa]
# Calculations
P_sat = P; # Saturation pressure
T_sat = (3799.89/(16.262-math.log(P_sat)))-226.35; #[C] - Saturation temperature
#Thus boiling at 2 atm occurs at Tsat = 120.66 C.
#From steam tables%at 2 bar%Tsat = 120.23 C and at 2.25 bar%Tsat = 124.0 C
#From interpolation for T_sat = 120.66 C%P = 2.0265 bar
#For P_= 2.0265 bar%T_sat% from steam table by interpolation is given by
#((2.0265-2)/(2.25-2))=((Tsat-120.23)/(124.0-120.23))
T_sat_0 = (((2.0265-2)/(2.25-2))*(124.0-120.23))+120.23; #[C]
# Results
print " Saturation temperature (Tsat) = %f C which is close \
to %f C as determined from Antoine equation"%(T_sat_0,T_sat)
```

In [11]:

```
# Variables
# math.log(P)=-(1640/T)+10.56 (solid)
# math.log(P)=-(1159/T)+7.769 (liquid)%where T is in K
# F+P=C+2% at triple point F+3=1+2 or%F=0 i.e%vapour pressure of liquid and solid at triple point are same%we get
# -(1640/T)+10.56 = -(1159/T)+7.769
# Calculations
T = (1640-1159)/(10.56-7.769) #[K]
P = 10**((-1640/T)+10.56) #[torr]
# Results
print " The temperature is %f K"%T
print " The pressure is %f torr (or mm Hg)"%P
```

In [12]:

```
# Variables
M_O2 = 31.999; #molecular weight of oxygen
M_N2 = 28.014; #molecular weight of nitrogen
Y = 1.4; #molar heat capacities ratio for air
# Calculations and Results
#Molecular weight of air(21 vol% O2 and 79 vol% N2)is given by
M_air = (0.21*M_O2)+(0.79*M_N2) #(vol% = mol%)
R = 8.314; #[J/mol*K] - Universal gas constant
R = (R*1/M_air) #[kJ/kg*K]
print " The value of universal gas constant (R) = %f kJ/kg-K "%R
#Y=Cp0/Cv0 and Cp0-Cv0=R
Cv_0 = R/(Y-1) #[kJ/kg*K]
Cp_0 = Y*Cv_0; #[kJ/kg*K]
print " The value of Cp_0 for air is %f kJ/kg-K"%Cp_0
print " The value of Cv_0 for air is %f kJ/kg-K"%Cv_0
```

In [13]:

```
# Variables
Y = 1.4; #molar heat capacities ratio for air
R = 8.314; # [J/mol*K] - Universal gas constant
# Calculations
Cv_0 = R/(Y-1) # [J/mol*K]
Cp_0 = Y*Cv_0; # [J/mol*K]
# Results
print " The molar heat capacity at constant volume (Cv_0) is %f J/mol-K"%Cv_0
print " The molar heat capacity at constant pressure (Cp_0) is %f J/mol-K"%Cp_0
```

In [14]:

```
from scipy.integrate import quad
# Variables
# Cp0=7.7+(0.04594*10**(-2)*T)+(0.2521*10**(-5)*T**(2))-(0.8587*10**(-9)*T**(3))
T_1 = 400.; #[K]
T_2 = 500.; #[K]
# Calculations
def f(T):
return 7.7+(0.04594*10**(-2)*T)+(0.2521*10**(-5)*T**(2))-(0.8587*10**(-9)*T**(3))
#(C)avg = q/(T_2 - T_1) = 1/(T_2 - T_1)*{(integrate('C'%'T'%T_1%T_2))}
#(Cp0)avg = 1/(T_2 - T_1)*{(integrate('Cp0'%'T'%T_1%T_2))}
Cp0_avg = (1/(T_2 - T_1))*quad(f,T_1,T_2)[0]
# Results
print " The mean heat capacity (Cp0_avg) for temerature range of 400 to 500 K is %f cal/mol-K"%Cp0_avg
```

In [15]:

```
# Variables
#(a)
P_1 = 0.2; # [MPa] - pressure
x_1 = 0.59; # mole fraction
# Calculations and Results
#From saturated steam tables at 0.2 MPa
H_liq_1 = 504.7; # [kJ/kg] - Enthalpy of saturated liquid
H_vap_1 = 2706.7; # [kJ/kg]- Enthalpy of saturated vapour
H_1 = (H_liq_1*(1-x_1))+(x_1*H_vap_1) # [kJ/kg]
print " (a).Enthalpy of 1 kg of water in tank is %f kJ/kg"%H_1
#(b)
T_2 = 120.23; # [C] - temperature
V_2 = 0.6; # [m**(3)/kg] - specific volume
#From saturated steam tables at 120.23 C% as reported in the book
V_liq_2=0.001061; # [m**(3)/kg]
V_vap_2=0.8857; # [m**(3)/kg]
#since V_2 < Vv_2%dryness factor will be given by% V = ((1-x)*V_liq)+(x*V_vap)
x_2 = (V_2- V_liq_2)/(V_vap_2 - V_liq_2)
#From steam table%at 120.2 C%the vapour pressure of water is 0.2 MPa.So%enthalpy is given by
H_2 = (H_liq_1*(1-x_2))+(H_vap_1*x_2) #kJ/kg]
print " (b).Enthalpy of saturated steam is %f kJ/kg"%H_2
#(c)
P_3 = 2.5; #[MPa]
T_3 = 350; #[C]
#From steam tables at 2.5 MPa%T_sat = 223.99 C%as reported in the book
#since%T_3 > Tsat% steam is superheated
print " (c).As steam is superheated%from steam table%enthalpy (H) is 3126.3 kJ/kg"
#(d)
T_4 = 350; #[C]
V_4 = 0.13857; #[m**(3)/kg]
#From steam table%at 350 C% V_liq = 0.001740 m**(3)/kg and V_vap = 0.008813 m**(3)/kg.Since%V > V_vap%therefore it is superheated.
#From steam table at 350 C and 1.6 MPa% V = 0.17456 m**(3)/kg
#At 350 C and 2.0 MPa% V = 0.13857 m**(3)/kg. So%
print " (d).The enthalpy of superheated steam (H) is 3137.0 kJ/kg"
#(e)
P_4 = 2.0; #[MPa]
U_4 = 2900; # [kJ/kg] - internal energy
#From saturated table at 2.0 MPa% U_liq = 906.44kJ and U_vap = 2600.3 kJ/kg
#scince%U_4 > Uv% it is saturated.
#From superheated steam table at 2.0 MPa and 350 C% as reported in the book
U_1 = 2859.8; #[kJ/kg]
H_1 = 3137.0; #[kJ/kg]
#At 2.0 MPa and 400 C%
U_2 = 2945.2; #[kJ/kg]
H_2 = 3247.6; #[kJ/kg]
T = (((U_4 - U_1)/(U_2 - U_1))*(400 - 350)) + 350; #[C] - By interpolation
H = (((T - 350)/(400 - 350))*(H_2 - H_1)) + H_1; #[kJ/kg]
print " (e).The enthalpy value (of superheated steam) obtained after interpolation is %f kJ/kg"%H
#(f)
P_5 = 2.5; #[MPa]
T_5 = 100; #[C]
#At 100 C%P_sat=101350 N/m**(2). Since P_5 > P_sat%it is compressed liquid
P_sat = 0.101350; #[MPa]
H_liq = 419.04; #[kJ/kg] - At 100 C and 0.10135 MPa
V_liq = 0.001044; #[m**(3)/kg] - At 100 C and 0.10135 MPa
H_0 = H_liq + (V_liq*(P_5 - P_sat))*1000; #kJ/kg]
print " (f).The enthalpy of compressed liquid is %f kJ/kg"%H_0
```