  In a hierarchical picture of galaxy formation virialization continually
transforms gravitational potential energy into kinetic energies of the baryonic
and dark matter. For the gaseous component the kinetic, turbulent energy is
transformed eventually into internal thermal energy through shocks and viscous
dissipation. Traditionally this virialization and shock heating has been
assumed to occur instantaneously allowing an estimate of the gas temperature to
be derived from the the virial temperature defined from the embedding dark
matter halo velocity dispersion. As the mass grows the virial temperature of a
halo grows. Mass accretion hence can be translated into a heating term. We
derive this heating rate from the extended Press Schechter formalism and
demonstrate its usefulness in semi-analytical models of galaxy formation. Our
method explicitly conserves energy unlike the previous impulsive heating
assumptions. Our formalism can trivially be applied in all current
semi-analytical models as the heating term can be computed directly from the
underlying merger trees. Our analytic results for the first cooling halos and
the transition from cold to hot accretion are in agreement with numerical
simulations.
