The first law of thermodynamics states that
where is the heat added to system, dW is the work done by system, and dE is the energy change of the system. Rewriting,
Including chemical potential energy,
where is the chemical potential energy for species i.