In [5]:

```
# Variables
V_w = 1. ; # Volume of given water -[L]
P_atm = 100. ; # Atmospheric pressure - [kPa]
#W = -p*del_V
V_H2O = 0.001043 ; # Specific volume of water from steam table according to book- [cubic metre]
V_vap = 1.694 ; # Specific volume of vapour from steam table according to book- [cubic metre]
V1 = 0 ; # Initial volume of H2O in bag-[cubic metre]
# Calculations
V2 = (V_w*V_vap)/(1000*V_H2O) ; # Final volume of water vapour -[cubic metre]
W = -P_atm*(V2 -V1)* 1000 ; # Work done by saturated liquid water -[J]
# Results
print ' Work done by saturated liquid water is %.3e J.'%W
```

In [6]:

```
# Variables
m_N2 = 1. ; # Moles of N2 taken -[kg mol]
p = 1000.; # Pressure of cylinder-[kPa]
T = 20. + 273. ; # Temperature of cylinder -[K]
a_pis = 6. ; # Area of piston - [square centimetre]
m_pis = 2. ; # Mass of pston - [kg]
R = 8.31 ; # Ideal gas constant - [(kPa*cubic metre)/(K * kgmol)]
# Calculations
V = (R*T)/p ; # Specific volue of gas at initial stage -[cubic metre/kg mol]
V1 = V * m_N2 ; # Initial volume of gas - [cubic metre]
V2 = 2.*V1 ; # Final volume of gas according to given condition -[cubic metre]
# Assumed surrounding pressure constant = 1 atm
p_atm = 101.3 ; # Atmospheric pressure-[kPa]
del_Vsys = V2 -V1 ; # Change in volume of system -[cubic metre]
del_Vsurr = - del_Vsys ; # Change in volume of surrounding -[cubic metre]
W_surr = -p_atm*del_Vsurr ; # Work done by surrounding - [kJ]
W_sys = -W_surr ; # Work done by system - [kJ]
# Results
print ' Work done by gas(actually gas + piston system) is %.0f kJ.'%W_sys
```

In [7]:

```
# Variables
p_plant = 20. ; # Power generated by plant-[MW]
h = 25. ; # Height of water level - [m]
V = 100. ; # Flow rate of water -[cubic metre/s]
d_water = 1000. ; # Density of water - [ 1000 kg / cubic metre]
g = 9.807 ; # Acceleration due to gravity-[m/square second]
# Calculations
M_flow = V*d_water ; # Mass flow rate of water -[kg/s]
del_PE = M_flow*g*h ; # Potential energy change of water per second -[W]
eff = (p_plant*10**6) /(del_PE) ; # Efficiency of plant
# Results
print ' Efficiency of plant is %.2f .'%eff
```

In [8]:

```
# Variables
LHV = 36654. ; # LHV value of fuel - [kJ/ cubic metre]
Q1 = 16. ; #- [kJ/ cubic metre]
Q2 = 0 ; #- [kJ/ cubic metre]
Q3 = 2432. ; #- [kJ/ cubic metre]
Q4 = 32114. ; #- [kJ/ cubic metre]
Q41 = 6988. ; #- [kJ/ cubic metre]
Q8 = 1948. ; #- [kJ/ cubic metre]
Q9 = 2643. ; #- [kJ/ cubic metre]
Q81 = 2352. - Q8 ; # - [kJ/ cubic metre]
Q567 = 9092. ; # Sum of Q5, Q6 and Q7- [kJ/ cubic metre]
# Calculations and Results
#(a)
G_ef = (LHV+ Q1 +Q2 + Q3 - Q9)/(LHV) ; # Gross efficiency
print '(a) Gross efficiency is %.3f .'%G_ef
#(b)
T_ef = (Q567+Q8)/(LHV+ Q1 +Q2 + Q3) ; #Thermal efficiency
print ' (b) Thermal efficiency is %.3f .'%T_ef
#(c)
C_ef = Q4/(Q4 + Q41) ; # Combustion efficiency
print ' (c) Combustion efficiency is %.3f .'%C_ef
```

In [1]:

```
from scipy.integrate import quad
# Variables
V1 = 5. ; # Volume of gas initially - [cubic feet]
P1 = 1. ; # Initial pressure - [atm]
P2 = 10. ; # Final pressure - [atm]
T1 = 100. + 460 ; # initial temperature - [degree Rankine]
R = 0.7302 ; # Ideal gas constant -[(cubic feet*atm)/(lb mol)*(R)]
#Equation of state pV**1.4 = constant
# Calculations and Results
V2 = V1*(P1/P2)**(1/1.4) ; # Final volume - [cubic feet]
def f(V):
return -(P1)*(V1/V)**(1.4)
W1_rev = quad(f,V1,V2)[0] ; # Reversible work done in compresion in a horizontal cylinder with piston -[cubic feet *atm]
W1 = W1_rev *1.987/.7302 ; # Conversion to Btu -[Btu]
print '(a)Reversible work done in compression in a horizontal cylinder with piston is %.1f Btu . '%W1
#(b)
n1 = (P1*V1)/(R*T1) ; # Number of moles of gas
def f1(P):
return (V1)*(P1/P)**(1/1.4)
W2_rev = quad(f1,P1,P2)[0] # Reversible work done in compresion in a rotary compressor -[cubic feet *atm]
W2 = W2_rev *1.987/.7302 ; # Conversion to Btu -[Btu]
print '(b)Reversible work done in a rotary compressor is %.1f Btu . '%W2
```

In [1]:

```
from scipy.integrate import quad
# Variables
m_water = 1. ; # Mass flow rate of water -[lb/min]
P1 = 100. ; # Initial pressure - [psia]
P2 = 1000. ; # Final pressure - [psia]
T1 = 80. + 460 ; # initial temperature - [degree Rankine]
T2 = 100. + 460 ; # final temperature - [degree Rankine]
h = 10. ; # Difference in water level between entry and exit of stream-[ft]
g = 32.2 ; # Accleration due to gravity - [ft/ square second]
gc = 32.2 ; #[(ft*lbm)/(lbf*square second)]
v1 = .01607 ; # specific volume of liquid water at 80 degree F -[cubic feet/lbm]
v2 = .01613 ; # specific volume of liquid water at 100 degree F -[cubic feet/lbm]
v= 0.0161 ; # -[cubic feet/lbm]
# Calculations
del_PE = (h*g)/(gc*778) ; # Change in potential energy - [Btu/lbm]
def f(P):
return (v)*(12**2/778.)
PV_work = quad(f,P1,P2)[0] # PV work done -[Btu/lbm]
#From eqn. (A)
W = PV_work + del_PE ; # Work per minute required to pump 1 lb water per minute - [Btu/lbm]
# Results
print ' Work per minute required to pump 1 lb water per minute is %.2f Btu/lbm . '%W
```

In [2]:

```
```