We describe numerical methods for incorporating gas dynamics into
cosmological simulations and present illustrative applications to the cold dark
matter (CDM) scenario. Our evolution code, a version of TreeSPH (Hernquist \&
Katz 1989) generalized to handle comoving coordinates and periodic boundary
conditions, combines smoothed--particle hydrodynamics (SPH) with the
hierarchical tree method for computing gravitational forces. The Lagrangian
hydrodynamics approach and individual time steps for gas particles give the
algorithm a large dynamic range, which is essential for studies of galaxy
formation in a cosmological context. The code incorporates radiative cooling
for an optically thin, primordial composition gas in ionization equilibrium
with a user-specified ultraviolet background. We adopt a phenomenological
prescription for star formation that gradually turns cold, dense,
Jeans-unstable gas into collisionless stars, returning supernova feedback
energy to the surrounding medium. In CDM simulations, some of the baryons that
fall into dark matter potential wells dissipate their acquired thermal energy
and condense into clumps with roughly galactic masses. The resulting galaxy
population is insensitive to assumptions about star formation; we obtain
similar baryonic mass functions and galaxy correlation functions from
simulations with star formation and from simulations without star formation in
which we identify galaxies directly from the cold, dense gas.Comment: compressed postscript, 38 pages including 6 out of 7 embedded
figures. Submitted to ApJ Supplements. Version with all 7 figures available
from ftp://bessel.mps.ohio-state.edu/pub/dhw/Preprint