  Diffusive transport has implications for the long-term status of underground
storage of hydrogen (H$_2$) fuel and carbon dioxide (CO$_2$), technologies
which are being pursued to mitigate climate change and advance the energy
transition. Once injected underground, CO$_2$ and H$_2$ will exist in
multiphase fluid-water-rock systems: being partially-soluble, injected fluids
can flow through the porous rack in a connected plume, become disconnected and
trapped as ganglia surrounded by groundwater within the storage rock pore
space, and also dissolve and migrate through the aqueous phase. Recent analyses
have focused on the concentration gradients induced by differing capillary
pressure between fluid ganglia which can drive diffusive transport ("Ostwald
ripening"). However, studies have neglected or excessively simplified important
factors; namely: the non-ideality of gases under geologic conditions, the
opposing equilibrium state of dissolved CO$_2$ and H$_2$ driven by the partial
molar density of dissolved solutes, and entropic and thermodiffusive effects
resulting from geothermal gradients. We conduct an analysis from thermodynamic
first principles and use this to provide numerical estimates at conditions
relevant to underground storage reservoirs. We show that entropic contributions
to the free energy are so significant as to cause a reversal in the direction
of diffusive transport in systems with geothermal gradients. For CO$_2$, even
geothermal gradients less than 10 C/km induce downwards diffusion at depths
relevant to storage. Diffusive transport of H$_2$ is less affected, but still
reverses direction under typical gradients. Contrary to previous studies, we
find that in diffusion and convection will likely work in concert - both
driving CO$_2$ downwards, and both driving H$_2$ upwards - for conditions
representative of their respective storage reservoirs.
