  We develop a spherical self-similar model for the formation of a galaxy
through gas collapsing in an isolated self-gravitating dark matter halo. We
improve upon the existing literature on self-similar collapse in two ways.
First, we include the effects of radiative cooling and the formation of a
pseudo-disk at the center of collapse, in a parametrised manner. More
importantly, we solve for the evolution of gas and dark matter simultaneously
and self-consistently using a novel iterative approach. As a result, our model
produces shell trajectories of both gas and dark matter that qualitatively
agree with the results of full hydrodynamical simulations. We discuss the
impact of various ingredients such as the accretion rate, gas equation of
state, disk radius and cooling rate amplitude on the evolution of the gas
shells. The self-consistent evolution of gas and dark matter allows us to study
the response of the dark matter trajectories to the presence of collapsing gas,
an effect that has gained increasing importance recently in the context of
precision estimates of small-scale statistics like the matter power spectrum.
Our default configuration produces a relaxation relation in qualitative
agreement with that seen in cosmological hydrodynamical simulations, and
further allows us to easily study the impact of the model ingredients mentioned
above. As an initial application, we vary one ingredient at a time and find
that the accretion rate and gas equation of state have the largest impact on
the relaxation relation, while the cooling amplitude plays only a minor role.
Our model thus provides a convenient framework to rapidly explore the coupled
nonlinear impact of multiple astrophysical processes on the mass and velocity
profiles of dark matter in galactic halos. (Abridged)
