We describe similarity solutions that characterize the collapse of collisio
nal gas on to scale-free perturbations in an Einstein-de Sitter universe. W
e consider the effects of radiative cooling and derive self-similar solutio
ns under the assumption that the cooling function is a power law of density
and temperature, Lambda(T, rho) proportional to rho(3/2)T. We use these re
sults to test the ability of smooth particle hydrodynamics (SPH) techniques
to follow the collapse and accretion of shocked, rapidly cooling gas in a
cosmological context. Our SPH code reproduces the analytical results very w
ell in cases that include or exclude radiative cooling. No substantial devi
ations from the predicted central mass accretion rates or from the temperat
ure, density and velocity profiles are observed in well-resolved regions in
side the shock radius. This test problem lends support to the reliability o
f SPH techniques to model the complex process of galaxy formation.