The equilibrium criterion in an isolated system is that its entropy is maximum. An isolated system that is not in material equilibrium exhibits chemical reactions or flow of matter between phases. These irreversible processes produce an increase in the entropy of the system. When these processes cease, entropy reaches its highest value and the system is in equilibrium.

For closed systems, the equilibrium condition is the maximization of the entropy of the system plus that of its surroundings ($S_{sis}+S_{ent})$ maximum in equilibrium.

Using entropy as a criterion of spontenity forces us to know how the entropy of the environment varies in the case of closed systems. Since it is easier to work with the thermodynamic properties of the system, forgetting about the environment, we must look for another thermodynamic function that gives us an equilibrium criterion.

Most of the chemical reactions take place maintaining constant temperature and volume or temperature and pressure. Thus, the reactions between gases are carried out in a container of volume V inside a thermostatic bath at temperature T. The reactions in solutions are carried out in open containers, keeping the system at atmospheric pressure and temperature T.

To find equilibrium criteria in both reaction conditions, we will study a system at temperature T immersed in a bath also at temperature T. The system and its surroundings are isolated. We assume that the system is in thermal and mechanical equilibrium, but not material. For its part, the environment is in thermal, mechanical and material equilibrium. Imagine that an endothermic reaction occurs in the system, producing a flow of heat from the surroundings to the system, $dq_{sis}=-dq_{ent}$ or: \begin{equation} dq_{sis}+dq_{ent }=0 \end{equation} The chemical reaction that takes place in our system is an irreversible process, which implies an increase in entropy of the universe. \begin{equation} dS_{uni}=dS_{sis}+dS_{ent}>0 \end{equation} Since the surroundings remain in thermodynamic equilibrium during the course of the reaction, its entropy change will be given by: \begin{equation} dS_{ent}=\frac{dq_{ent}}{T} \end{equation} However, the entropy change of the system cannot be equal to $dq_{sis}/T$ since would imply that $dS_{uni}=0$. Therefore: \begin{equation} dS_{sis}>\frac{dq_{sis}}{T} \end{equation} Once the reaction reaches equilibrium if it will be true that $dS_{sis}=dq_{sis }/T$. Combined both equations we have: \begin{equation} dS\geq \frac{dq}{T} \end{equation} This last equation applies to closed systems in thermal and mechanical equilibrium with material change. Note that the equality holds when the system reaches material equilibrium.

Using the first law of thermodynamics $dq=dU-dw$ we transform the previous inequality into: \begin{equation} dU-dw\leq TdS \end{equation} or \begin{equation}dU\leq TdS +dw \end{equation}