# Steam equilibrating with liquid water

Accident scenario: steam leaks into a rigid, insulated tank that is partially filled with water.

The steam and liquid water are not initially at thermal equilibrium, though they are at the same pressure. The steam is at temperature $T_{s,1}$ = 600 C and pressure $P_1$ = 20 MPa. 
The liquid water is initially at $T_{\text{liq},1}$ = 40 C and pressure $P_1$ = 20 MPa.
The total volume of the tank is $V$ = 10 m$^3$ and the volume of the liquid water initially in the tank is $V_{\text{liq},1} = 1 \; \text{m}^3$.

Eventually, the contents of the tank reach a uniform temperature and pressure, $T_2$ and $P_2$. The tank is well-insulated and rigid.

**Problem:** Determine the final temperature and pressure of the water in the tank.


```python
# load necessary modules

# Numpy adds some useful numerical types and functions
import numpy as np

# Cantera will handle thermodynamic properties
import cantera as ct

# Pint gives us some helpful unit conversion
from pint import UnitRegistry
ureg = UnitRegistry()
Q_ = ureg.Quantity
```

First, what are the initial states of the steam and liquid?


```python
steam = ct.Water()
temp_steam1 = Q_(600, 'degC')
pres1 = Q_(20, 'MPa')
steam.TP = temp_steam1.to('K').magnitude, pres1.to('Pa').magnitude
steam()
```

    
      water:
    
           temperature          873.15  K
              pressure           2e+07  Pa
               density         55.0118  kg/m^3
      mean mol. weight          18.016  amu
        vapor fraction               1
    
                              1 kg            1 kmol
                           -----------      ------------
              enthalpy    -1.24332e+07        -2.24e+08     J
       internal energy    -1.27968e+07       -2.305e+08     J
               entropy         10024.8        1.806e+05     J/K
        Gibbs function    -2.11864e+07       -3.817e+08     J
     heat capacity c_p         2808.18        5.059e+04     J/K
     heat capacity c_v         1964.45        3.539e+04     J/K
    



```python
liquid = ct.Water()
temp_liquid1 = Q_(40, 'degC')
liquid.TP = temp_liquid1.to('K').magnitude, pres1.to('Pa').magnitude
liquid()
```

    
      water:
    
           temperature          313.15  K
              pressure           2e+07  Pa
               density         1000.81  kg/m^3
      mean mol. weight          18.016  amu
        vapor fraction               0
    
                              1 kg            1 kmol
                           -----------      ------------
              enthalpy    -1.57857e+07       -2.844e+08     J
       internal energy    -1.58056e+07       -2.848e+08     J
               entropy         4084.54        7.359e+04     J/K
        Gibbs function    -1.70647e+07       -3.074e+08     J
     heat capacity c_p         4128.68        7.438e+04     J/K
     heat capacity c_v         4011.51        7.227e+04     J/K
    


State $s,1$ is in the superheated vapor region (vapor fraction: 1) and state $\text{liq},1$ is in the compressed liquid region (vapor fraction: 0).

We can calculate the mass of liquid water in the tank, and then determine the volume and mass of steam:

$$
m_{\text{liq},1} = \frac{V_{\text{liq},1}}{v_{\text{liq},1}} \\
V_{s,1} = V_{\text{tank}} - V_{\text{liq},1} \\
m_{s,1} = \frac{V_{s,1}}{v_{s,1}}
$$


```python
vol_tank = Q_(10, 'meter^3')
vol_liquid1 = Q_(1, 'meter^3')

mass_liquid1 = vol_liquid1 / Q_(liquid.v, 'm^3/kg')
print(f'Mass of liquid at state 1: {mass_liquid1: .2f}')

vol_steam1 = vol_tank - vol_liquid1
mass_steam1 = vol_steam1 / Q_(steam.v, 'm^3/kg')
print(f'Mass of steam at state 1: {mass_steam1: .2f}')

mass_1 = mass_liquid1 + mass_steam1
print(f'Total mass of system: {mass_1: .2f}')
```

    Mass of liquid at state 1: 1000.81 kilogram
    Mass of steam at state 1: 495.11 kilogram
    Total mass of system: 1495.92 kilogram


Do a mass balance on the tank for going from state 1 to state 2 (after equilibrium):
\begin{equation}
\frac{dm}{dt} = m_2 - m_1 = 0
\end{equation}
and so $m_2 = m_1$, meaning the mass of water in the tank does not change.
We can then find the specific volume of water in the tank:
\begin{equation}
v_2 = \frac{V_{\text{tank}}}{m_2}
\end{equation}

The tank experiences no heat or work, and does not exhibit any bulk changes in kinetic or potential energy; we can do an energy balance on the tank for the process of going from state 1 to state 2:

$$
Q - W = \Delta KE + \Delta PE + \Delta U \\
\rightarrow 0 = U_2 - U_1 \\
0 = u_2 m_2 - \left( u_{\text{liq},1} m_{\text{liq},1} + u_{s,1} m_{s,1} \right)
$$

Therefore, we can find the specific internal energy of the final state:
\begin{equation}
u_2 = \frac{ u_{\text{liq},1} m_{\text{liq},1} + u_{s,1} m_{s,1} }{m_2}
\end{equation}


```python
mass_2 = mass_1

spec_vol2 = vol_tank / mass_2
print(f'Specific volume of state 2: {spec_vol2: .2e}')

int_energy2 = (
    Q_(liquid.u, 'J/kg')*mass_liquid1 + Q_(steam.u, 'J/kg')*mass_steam1
    ) / mass_2
int_energy2.ito('kilojoule/kg')
print(f'Internal energy of state 2: {int_energy2: .2f}')

water_equilibrium = ct.Water()
water_equilibrium.UV = int_energy2.to('J/kg').magnitude, spec_vol2.to('m^3/kg').magnitude

water_equilibrium()
```

    Specific volume of state 2: 6.68e-03 meter ** 3 / kilogram
    Internal energy of state 2: -14809.79 kilojoule / kilogram
    
      water:
    
           temperature         510.436  K
              pressure     3.18519e+06  Pa
               density         149.592  kg/m^3
      mean mol. weight          18.016  amu
        vapor fraction       0.0887074
    
                              1 kg            1 kmol
                           -----------      ------------
              enthalpy    -1.47885e+07       -2.664e+08     J
       internal energy    -1.48098e+07       -2.668e+08     J
               entropy         6505.97        1.172e+05     J/K
        Gibbs function    -1.81094e+07       -3.263e+08     J
     heat capacity c_p    inf              inf              J/K
     heat capacity c_v         6766.85        1.219e+05     J/K
    


So, at equilibrium, the tank contains a mixture of saturated liquid and vapor, with temperature and pressure:


```python
final_temperature = Q_(water_equilibrium.T, 'K')
final_pressure = Q_(water_equilibrium.P, 'Pa')

print(f'Final temperature: {final_temperature: .2f}')
print(f'Final pressure: {final_pressure.to(ureg.MPa): .2f}')
```

    Final temperature: 510.44 kelvin
    Final pressure: 3.19 megapascal


eff062717b67bbb2234bc3ef8ded65909eb65dc4
ipynb
Jupyter Notebook
book/content/first-law/steam-water-equilibrium.ipynb
kyleniemeyer/computational-thermo
3f0d1d4a6d4247ac3bf3b74867411f2090c70cbd
CC-BY-4.0 BSD-3-Clause
2020-04-01T05:52:06.000Z
2022-03-27T20:25:59.000Z
book/content/first-law/steam-water-equilibrium.ipynb
kyleniemeyer/computational-thermo
3f0d1d4a6d4247ac3bf3b74867411f2090c70cbd
CC-BY-4.0 BSD-3-Clause
2020-04-28T04:02:05.000Z
2020-04-29T17:49:52.000Z
book/content/first-law/steam-water-equilibrium.ipynb
kyleniemeyer/computational-thermo
3f0d1d4a6d4247ac3bf3b74867411f2090c70cbd
CC-BY-4.0 BSD-3-Clause
2020-04-03T14:52:24.000Z
2022-03-29T02:29:43.000Z
Qwen/Qwen-72B
1. YES
2. YES