Gibbs energy of a mixture and photon gas positron/electron

If you have water and oil it will not produce a homogenous mixture because the Gibbs energy of a homogenous mixture is higher than a seperated phase. This is because the enthalpy is higher than the heat provided by the temperature, thus this will not form. If you increase the temperature sufficiently their will be a mixture.

The reverse is true for a photon gas. If you increase the temperature at sufficiently high temperatures, the photon gas will ‘separate’ into a positron-electron gas. Somehow this has lower gibbs energy than a photon gas on its own. This is also kind of reverse of what we see. Almost like:

\Delta G = \Delta H - T dS

Changes into

\Delta G = T dS - \Delta H

Gibbs of mixture and lagrangian

If you take the gibbs graphs vs x and look at different temperatures of mixtures you compare straight lines with curved lines. It will take the curved path if it is under the straight path.

This seems very similar to lagrangian mechanics where the path gets chosen that is most favourable. I wonder what the exact analogy is.

Source: https://www.researchgate.net/figure/Schematic-showing-the-Gibbs-free-energy-of-mixing-as-a-function-of-composition-at-a_fig1_41398877