I am attempting to develop a simulation of the boiler of a steam locomotive for a video game.

Assume we begin with a rigid vessel of volume $V$ entirely filled with known masses of liquid water $m_l$ and steam vapor $m_v$ at pressure $P$. We then inject a quantity of heat $Q$, vaporizing some unknown mass of the water $m_e$ into steam, and the vessel settles into a new equilibrium at higher pressure $P'$.

Simplifying assumptions:

  • The vessel is perfectly rigid, sealed, and insulated, so total volume, mass, and energy are preserved, and the vessel itself does not change in temperature.
  • There is no water in liquid state suspended in the steam, i.e. the steam is dry with 100% quality.
  • Pressures $P$ and $P'$ are sufficiently close that the physical properties of steam and water can be approximated as constant, particularly density and specific heat.
  • The system evolves along the saturation line, so pressure fully determines temperature and vice versa.
  • Likewise, assume temperature is uniform throughout the vessel both at the start and end of the process.
  • If it helps, for most but not all simulation initial conditions, $m_l >> m_v >> m_e$.


  • The final pressure $P'$. Equivalently, the final temperature, or the mass of water that evaporates ($m_e$).

How far I've gotten:

Starting with the conservation of energy, I believe the heat will go into a) heating the water to the final temperature, b) heating the initial vapor to the final temperature, and c) vaporizing some quantity of the (heated) water.

$Q = m_l C_l \Delta T + m_v C_v \Delta T + m_e \Delta H_v$

where $C_l$ is the isochoric specific heat capacity of water, $C_v$ the isochoric specific heat capacity of steam vapor, and $\Delta H_v$ the latent heat of vaporization of water, all at pressure $P$. This gives me two unknowns $m_e$ and $\Delta T$, but I've been unable to relate them to each other, and I'm not sure that I can since the phase transition happens at a single temperature.

Introducing conservation of mass has so far gotten me nothing but a tautology: $m_l + m_v = (m_l-m_e)+(m_v+m_e)$

Working with volume via density has led to the predictable conclusion that volume is conserved if nothing changes:

$V = V_l+V_v = \frac{m_l}{\rho_l} + \frac{m_v}{\rho_v}$

$= \frac{m_l-m_e}{\rho_l} + \frac{m_v+m_e}{\rho_v}$

$= \frac{m_l}{\rho_l} + \frac{m_v}{\rho_v} - \frac{m_e}{\rho_l} + \frac{m_e}{\rho_v}$

$= V_l + V_v + \frac{m_e\rho_l}{\rho_l\rho_v} - \frac{m_e\rho_v}{\rho_l\rho_v}$

Thus $0 = m_e\frac{\rho_l-\rho_v}{\rho_l \rho_v}$.


  1. Will this model approximate reality or am I missing key factors?
  2. Is there an analytic solution for this? As this is for a video game, performance is key and I'm willing to give up considerable physical accuracy to get it.
  • $\begingroup$ Are you allowed to assume that the steam behaves as an ideal gas? It's not too good an assumption that the density of the steam doesn't change. You're kind of on the right track. $\endgroup$ Apr 7, 2021 at 10:11
  • $\begingroup$ The generated steam will be used to drive pistons that turn the train's wheels, so as steam is being generated, it is also being removed from the system. This means that as heat is entering the system, it is also leaving the system. Your simulation will have to include equations that tie all of this together. $\endgroup$ Apr 8, 2021 at 1:03

1 Answer 1


If the steam tables could be used to solve this, it would be really easy. But, with just a couple of minor assumptions, it is not very difficult:

  1. The liquid water behaves like an incompressible liquid

  2. The water vapor behaves like an ideal gas.

With these two assumptions only, we can proceed. Let n be the total number of moles of water in the container. Then the mass balance on the system is:

$$n_L+n_V=n$$ and the constant volume of the container is $$n_Lv_L+n_Vv_V=V$$ where $v_L$ is the molar volume of the liquid water (a constant) and $v_V$ is the molar volume of the water vapor. If we let x represent the mass fraction of water vapor in the container and combine these two equations, we obtain: $$(1-x)v_L+xv_V=\frac{V}{n}$$or$$x=\frac{\frac{V}{n}-v_L}{v_V-v_L}$$From the ideal gas law, it follows that $$v_V=\frac{RT}{P(T)}$$where P(T) is the equilibrium vapor pressure of water at temperature T. So, the mass fraction of water vapor is $$x=\frac{\frac{V}{n}-v_L}{\frac{RT}{P(T)}-v_L}$$So, if we specify the temperature, we can calculate the mass fraction water vapor in the container.

Now for the energy balance. From the first law, we can write for this constant-volume insulated container that $$Q=\Delta U$$The internal energy of the contents is given by $$U=n_Lu_L+n_Vu_V=n[(1-x)u_L+xu_V]$$ where the u's are the molar internal energies. If we let $T_i$ represent a initial temperature of the container, then the molar internal energies at temperature T are given by: $$u_L(T)=u_L(T_i)+C_{vL}(T-T_i)$$and$$u_V(T)=u_V(T_i)+C_{vV}(T-T_i)$$where the C's are the molar heat capacities at constant volume. The molar internal energies of the liquid and vapor at the initial temperature are related to the molar enthalpies at this temperature by: $$h_L(T_i)=u_L(T_i)+P(T_i)v_L$$and$$h_V(T_i)=u_V(T_i)+P(T_i)v_V=u_V(T_i)+RT_i$$So, in terms of the heat of vaporization at temperature $T_i$, $\Delta h_{LV}(T_i)$, the molar internal energies at $T_i$ are related by: $$\Delta h_{LV}(T_i)=u_V(T_i)-u_L(T_i)+RT_i-P(T_i)v_L$$Therefore, our equation for the molar internal energy of the vapor at temperature T becomes: $$u_V(T)=u_L(T_i)+h_{LV}(T_i)-RT_i+P(T_i)v_L+C_{vV}(T-T_i)$$The net result is that, once we specify the final temperature T, we can use the equations developed here to calculate the amount of heat that must be added Q to attain this temperature. In these calculations, the initial molar internal energy of the liquid $u_L(T_i)$ will exactly cancel from the results (as would be expected).

  • $\begingroup$ This was helpful, and in particular I think modelling the liquid and vapor as a mass fraction of the total may be the tool I need to move further on this. For my use case, Q is a known quantity (based on the characteristics of the fire), while the final temperature T is the unknown. I'm looking for a way to determine T directly, but as I understand it this framework would require an iterative solution checking various candidates for T and possibly interpolating between them. $\endgroup$
    – Zeibach
    Apr 8, 2021 at 3:07
  • $\begingroup$ Yes, unless the temperature change is small and you can linearize. $\endgroup$ Apr 8, 2021 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.