In [1]:

```
# Variables
H = 100.; #height = 100m
M = 1.; #Mass of water = 1Kg
g = 9.8066; #Acceleration due to gravity(m/s**2)
# Calculations and Results
#(a)
PE1 = M*H*g; #[j]
print '(a)Potential energy of Water at the Top',PE1,'J'
#(b)
del_U = 0;
KE1 = 0;
PE2 = 0;
KE2 = PE1; #[j]
print '(b)Kinetic energy of Water',KE2,'J'
#(c)
del_U = KE2;
print '(c)Change in Internal energy when 1kg Water added',del_U,'J'
```

In [2]:

```
# Variables
P_atm = 101.3; #Atm Pressure = 101.3KPa
V1 = 0.1; #Volume1 = 0.1m**3
V2 = 0.2; #Volume2 = 0.2m**3
# Calculations
del_V = V2-V1;
W_by = P_atm*del_V;
W_on = -W_by;
Q = 0;
del_Energy = Q+W_on; #KJ
# Results
print 'Energy Change',del_Energy,'KJ'
```

In [4]:

```
# Variables
W_acb = 40; #J
Q_acb = 100; #J
W_aeb = 20; #J
W_bda = 30; #J
# Calculations and Results
del_U_ab = Q_acb-W_acb;
#(a)
Q_aeb = del_U_ab-W_aeb; #J
print '(a)Heat Flow in acb',Q_aeb,'J'
#(b)
del_U_ba = -del_U_ab; #J
Q_bda = del_U_ba-W_bda;
print '(b)Heat Flow in bda',Q_bda,'J'
```

In [5]:

```
# Variables
#(a)-Liquid Water in equllibrium with its vapour.
N = 1;
pi = 2;
# Calculations and Results
F = 2-pi+N;
print '(a)Degree Of freedom is',F
#(b)-Liquid Water in equllibrium with a mixture of vapour and nitrogen.
N = 2;
pi = 2;
F = 2-pi+N;
print '(b)Degree Of freedom is',F
#(c)-A liquid Soln of alcohol in water in equillibrium with its vapour
N = 2;
pi = 2;
F = 2-pi+N;
print '(c)Degree Of freedom is',F
```

In [1]:

```
from scipy.integrate import quad
# Variables
P = 14.; #Pressure = 14bar
V1 = 0.03; #Initial volume = 0.03m**3
V2 = 0.06; #Final Volume
#Process is isothermal
#(a)-To find the work done by gas in moving the External force
#(b)-To find the work done by gas if external force is suddenly reduced to half its initial value
# Calculations and Results
#(a)
K = P*V1*(10**5); #J
def f3(V):
return 1./V
W1 = round(-K* quad(f3,0.03,0.06)[0],2)
P2 = K/V2; #Final Pressure(Pa)
P2 = P2/(10**5); #bar
print '(a)The work done by gas in moving the External Force is',W1,'J'
#(b)
def f4(V):
return 1
W2 = -P2*(10**5)* quad(f4,0.03,0.06)[0]
n = round((W2/W1)*100,1); #Efficiency
print '(b)The work done by gas if external force is reduced to half is',W2,'J'
print 'Hence the efficiency is',n,'%'
```

In [2]:

```
# Variables
P = 7; #pressure = 7bar
m = 45; #Mass of cube
mt = 23; #mass of piston,piston rod,pan
x = 0.5; #Dismath.tance moved = 0.5m
g = 9.8; #Acceleration Due to gravity(m/s**2)
# Calculations
#Acc to Eqn del_U_sys+del_U_surr+del_PE_surr = 0
del_PE_surr = (m+mt)*g*x;
#ans = del_U_sys+del_U_surr
# Results
print 'Energy Changes in the Process',-del_PE_surr,'J'
```

In [3]:

```
# Variables
m = 1.; #1kg of water
T = 373.15; #Temp = 373.15K(100`C)
P = 101.325; #Pressure = 101.325KPa
V2 = 1.673; #Final Volume[m**3]
V1 = 0.00104; #Initial Volume[m**3]
Sv_liqiud = 0.00104; #Specific Volume of Liqiud
Sv_vapour = 1.673; #Specific Volume of Vapour
del_H = 2256.9; #Heat Added(KJ)
# Calculations
Q = del_H;
del_V = V2-V1;
W = P*del_V; #KJ
del_U = round(del_H-(P*del_V),1);
# Results
print 'Change in Enthalpy',del_H,'KJ'
print 'Change in Internal energy',del_U,'KJ'
```

In [4]:

```
# Variables
P1 = 1.; #Pressure = 1bar
T1 = 298.15; #Temp = 298.15K(25`C)
V1 = 0.02479; #Molar Volume = 0.02479m**3/mol
#Final
P2 = 5. #Pressure = 5bar
Cv = 20.78; #J/mol/K
Cp = 29.10; #J/mol/K
# Calculations and Results
#to Find del_U,del_H by two processes
V2 = V1*(P1/P2); #m**3(1 mol)
print 'Final Volume',V2,'m**3'
#(a)-Cooling at const pressure followed by heating at const Volume
T2 = T1*(V2/V1); #K
print 'Final Temperature',T2,'K'
del_H = round(Cp*(T2-T1)); #J
Q1 = del_H; #J
del_U1 = round(del_H-(P1*(10**5)*(V2-V1))); #J
#Second Step
del_U2 = round(Cv*(T1-T2)); #J
Q2 = del_U2;
Q = Q1+Q2;
del_U = 0;
W = del_U-Q; #J
del_H = 0; #const Temperature
print ('(a) Cooling at const Pressure Followed by Heating at const Volume')
print 'Heat Required',Q,'J'
print 'Work Required',W,'J'
print 'Change in enthalpy',del_H,'J'
print 'Change in Energy',del_U,'J'
#(b)-heating at Const Volume Followed by cooling at const Pressure
T2 = T1*(P2/P1); #K
del_U1 = round(Cv*(T2-T1)); #J
Q1 = del_U1;
del_H = round(Cp*(T1-T2)); #J
Q2 = del_H;
del_U2 = round(del_H-(P2*(10**5)*(V2-V1))); #J
Q = Q1+Q2;
del_U = 0;
W = del_U-Q; #J
del_H = 0; #const Temperature
print '(b) Heating at const Volume Followed by Cooling at const Pressure'
print 'Heat Required',Q,'J'
print 'Work Required',W,'J'
print 'Change in enthalpy',del_H,'J'
print 'Change in Energy',del_U,'J'
#Note
print ('Note : The Answer varies From That in the book because in Book 4956.44 has been rounded to \
4958 which is absurd')
```

In [5]:

```
# Variables
T1 = 277.; #Temp = 277K
P1 = 10.; #Pressure = 10bar
V1 = 2.28; #molar Volume = 2.28m**3/Kmol
T2 = 333.; #Temp = 333K
P2 = 1. #Pressure = 1atm
Cv = 21.; #KJ/Kmol/K
Cp = 29.3; #KJ/Kmol/K
# Calculations
#(a)-Cooled at const Vol to the final pressure
#(b)-Heated at const Pressure to final temperature
T_ = T1*(1./10); #Intermediate temperature
del_Ta = T_-T1;
del_Tb = T2-T_;
del_Ua = Cv*del_Ta; #KJ/Kmol
del_Ha = del_Ua+(V1*(P2-P1)*(10**5)/(10**3)); #KJ/Kmol
V2 = (V1*P1*T2)/(P2*T1); #m**3/kmol
del_Hb = Cp*del_Tb;
del_Ub = del_Hb-(P2*(V2-V1)*(10**5)/(10**3)); #KJ/Kmol
del_U = round(del_Ua+del_Ub,0);
del_H = round(del_Ha+del_Hb,0);
# Results
print 'Change In Internal Energy',del_U,'KJ/Kmol'
print 'Change In Enthalpy',del_H,'KJ/Kmol'
```

In [6]:

```
import math
# Variables
M = 190.; #Mass = 190Kg
T0 = 333.15; #Temperature = 333.15K(60`C)
m = 0.2; #Steady rate of mass(Kg/s)
T = 308.15; #Temperature = 308.15K(35`C)
T1 = 283.15; #Temperature = 283.15K(10`C)
# Calculations and Results
#Using the Eqn (2.29)
t = round(-(M/m)*math.log((T-T1)/(T0-T1)),1); #s
print 'Time Taken for temperature of water to drop from 333.15K to 308.15K',t,'s'
t = round(t/60); #min
print 'Time Taken for temperature of water to drop from 333.15K to 308.15K',t,'min'
```

In [13]:

```
# Variables
rQ = 4.15; #[g/s] flow rate
rQ2 = 12740.; #Rate of Heat addition from resismath.tance heater
# Calculations
#del_z and del_u*2 are negligible if Ws and H1 = 0..then H2 = Q
H2 = round(rQ2/rQ); #[J/g]
# Results
print 'Enthalpy of Steam',H2,'J/g'
```

In [14]:

```
# Variables
V = 600.; #[m/s]
W_compression = 240.; #[KJ/Kg]
# Calculations
#Umath.sing Eqn(2.32a)
Q = (1./2*(V*V)/1000.)-W_compression;
# Results
print 'Thus Heat Removed from each KG of air compressed is',-Q,'KJ/kg'
```

In [7]:

```
# Variables
R = 3.15*10**-3; #[m**3/s] Rate of pumping
rH = -700.; #[KW] Rate of Heat lost
h = 15.; #[m] Height
rW = 1.5; #[KW]
rho = 958.; #[Kg/m**3] at 366.65K
g = 9.805;
gc = 1000.;
del_z = h;
# Calculations and Results
rm = round(R*rho,3); #[Kg/s] Mass flow rate
Q = round(rH/rm,1); #[KJ/Kg]
W = round(rW/rm,3); #[KJ/Kg] Shaft Work
K = round(g/gc*del_z,3);
#using Eqn(2.32b)
del_H = Q+W-K;
#From Steam tables for water at 366.65K
H1 = 391.6; #[KJ/Kg]
H2 = del_H+H1;
print 'Enthalpy',H2,'KJ/Kg'
#From Steam Tables temp at this enthalpy is
T = 311.35; #[K]
print 'Temperature in the Second tank',T,'K'
```