  The diffuse medium in and around galaxies can exist in a multi-phase state:
small, cold gas clouds contributing significantly to the total mass embedded in
pressure equilibrium with a hotter, more diffuse volume-filling component.
Modeling this multi-phase state in cosmological simulations poses a significant
challenge due to the requirements to spatially resolve the clouds and
consequently the interactions between the phases. In this paper, we present a
novel method to model this gas state in cosmological hydrodynamical
simulations. We solve the compressible two-fluid hydrodynamic equations using a
moving-mesh finite-volume method and define mass, momentum and energy exchange
terms between the phases as operator-split source terms. Using a stratified
flow model, our implementation is able to maintain volume fraction
discontinuities in pressure equilibrium to machine precision, allowing for the
treatment of both resolved and unresolved multi-phase fluids. The solver
remains second order accurate on smooth hydrodynamics problems. We use the
source and sink terms of an existing two-phase model for the interstellar
medium to demonstrate the value of this type of approach in simulations of
galaxy formation, compare it to its effective equation of state implementation,
and discuss its advantages in future large-scale simulations of galaxy
formation.
