{'fraction_non_alphanumeric': 0.023007543161646892, 'fraction_numerical': 0.01305201000954147, 'mean_word_length': 4.424609375, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Comparison of Gas Dynamics in SPH and Semi-analytic Models of Galaxy Formation

We compare the results of two techniques used to calculate the evolution of cooling gas during galaxy formation: Smooth Particle Hydrodynamics (SPH) simulations and semi-analytic modelling. We improve upon the earlier statistical comparison of Benson et al. by taking halo merger histories from the dark matter component of the SPH simulation, which allows us to compare the evolution of galaxies on an object-by-object basis in the two treatments. We use a ``stripped-down'' version of the semi-analytic model described by Helly et al. which includes only shock heating and radiative cooling of gas and which is adjusted to mimic the resolution and other parameters of a comparison SPH simulation as closely as possible. We compare the total mass of gas that cools in halos of different mass as a function of redshift as well as the masses and spatial distribution of individual ``galaxies.'' At redshift z=0, the cooled gas mass in well-resolved halos agrees remarkably well (to better than ~20%) in the SPH simulation and stripped-down semi-analytic model. At high redshift, resolution effects in the simulation become increasingly important and, as a result, more gas tends to cool in low mass halos in the SPH simulation than in the semi-analytic model. The cold gas mass function of individual galaxies in the two treatments at z=0 also agrees very well and, when the effects of mergers are accounted for, the masses of individual galaxies and their 2-point correlation functions are also in excellent agreement in the two treatments. Thus, our comparison confirms and extends the earlier conclusion of Benson et al. that SPH simulations and semi-analytic models give consistent results for the evolution of cooling galactic gas.


INTRODUCTION
A range of physical processes are responsible for the formation and evolution of the galaxies we see in the universe today. The starting point for current hierarchical cold dark matter models of galaxy formation is the gravitational amplification and eventual collapse of primordial density fluctuations to form the dark matter halos in which stars and galaxies may form. This process is now quite well understood, and predictions of halo mass functions from analytic techniques such as Press-Schechter theory (Press & Schechter 1974) and its extensions (Bond et al. 1991;Bower 1991;Lacey & Cole 1993;Sheth & Tormen 2001) are in good agreement with numerical simulations (e.g. Gross et al. 1998; Governato et al. 1999;Jenkins et al. 2001).
Unfortunately, the behaviour of the baryonic compo-nent of the universe is more complex and less well understood. While the dynamics of the dark matter are determined by gravitational forces alone, gas is subject to hydrodynamical forces and radiative effects. The situation is further complicated by the absence of a complete theory of star formation and the fact that star formation involves length and mass scales many orders of magnitude smaller than the galaxies themselves forces those modelling galaxy formation to resort to recipes and prescriptions to obtain star formation rates. Nevertheless, semi-analytic models have met with considerable success, for example in reproducing the local field galaxy luminosity function and distributions of colour and morphology (e.g. Cole 1991;Cole et al. 1994Cole et al. , 2000White & Frenk 1991;Lacey & Silk 1991;Somerville & Primack 1999) and galaxy clustering properties (e.g. Kauff-mann et al. 1999;Benson et al. 2000;Wechsler et al. 2001).
In this work, we compare two possible ways of modelling the process which provides the raw material for star formationthe cooling of gas within dark matter halos. Such a model is a necessary part of almost any treatment of the hierarchical formation of galaxies, yet there is still some uncertainty as to which of the approaches currently in use are reliable and whether they are in good agreement. While Eulerian numerical techniques may be employed in the modelling of galaxy formation in cosmological volumes (e.g. Cen & Ostriker 2000), here we concentrate on the Lagrangian method known as smoothed particle hydrodynamics (SPH), first described by Lucy (1977) and Gingold & Monaghan (1977). SPH simulations have been able to predict the formation of objects of approximately galactic mass with appropriate abundances in a cosmological context (e.g. Katz, Hernquist & Weinberg 1992;Navarro & White 1993;Evrard, Summers & Davis 1994;Steinmetz & Müller 1995;Katz, Weinberg & Hernquist 1996;Frenk et al. 1996;Navarro & Steinmetz 1999;Pearce et al. 1999Pearce et al. , 2001 and allow the investigation of the dynamics of galaxies within clusters and the spatial distribution of galaxies.
Semi-analytic and SPH galaxy formation models rely on very different sets of assumptions and approximations. For example, semi-analytic models assume that dark matter halos are spherically symmetric and that infalling gas is shock-heated to the virial temperature of the halo, whereas SPH simulations impose no restrictions on halo geometry but assume that continuous distributions of gas and dark matter may be well represented by a limited number of discrete particles. Consequently, SPH and semi-analytic models have complementary strengths and weaknesses. Semianalytic models are computationally much cheaper than simulations, which allows extremely high mass resolution in halo merger trees and more thorough investigation of the effects of varying parameters or the treatment of particular processes. SPH simulations contain fewer simplifying assumptions but have limited dynamic range and without sufficiently large numbers of particles may suffer from numerical effects.
The aim of this paper is to compare SPH and semianalytic treatments of the gas dynamics involved in galaxy formation in order to gauge the effects of the uncertainties present in the two techniques. A previous comparison carried out by Benson et al. (2001a) found that SPH and semi-analytic models give similar results for the thermodynamic evolution of cooling gas in cosmological volumes. In particular, the global fractions of hot gas, cold dense gas and uncollapsed gas agreed to within 25% and the mass of gas in galaxies in the most massive halos differed by no more than 50%. However, their analysis was restricted to a statistical comparison because their semi-analytic model employed merger histories created using a Monte-Carlo algorithm, that of Cole et al. (2000). We improve on the work of Benson et al. by calculating the merger trees directly from the simulations so that the merger histories of the halos in the semi-analytic and SPH treatments are the same. This removes a source of uncertainty from the comparison, since any differences between the models must be due entirely to differences in the treatment of the baryonic component. Our method also allows a comparison between halos on an individual basis and lets us investigate whether the dependence of the cold gas mass on the halo's merger history is the same in the SPH and semi-analytic cases.
Our approach is that of "modelling a model", using a semi-analytic model to reproduce the behaviour of the simulation including the effects of limited mass resolution. Since we are interested primarily in the rate at which cooling occurs in the two models, we use a simulation which allows radiative cooling but which does not include any prescription for star formation or feedback. We attempt to model this simulation using a "stripped down" semi-analytic model which also neglects these phenomena. Hierarchical models of galaxy formation without feedback predict that most of the gas in the universe cools in low mass objects at high redshift (e.g. White & Rees 1978;Cole 1991;White & Frenk 1991). Consequently, we cannot expect either our SPH simulation or our stripped down semi-analytic model to cool realistic quantities of gas, and where differences between the two approaches are found it may not be possible to conclude that one is more "correct" than the other. However, the changes which must be made to the semi-analytic model to match the SPH simulation may provide insight into the level of agreement between the two techniques and the reasons for any discrepancies.
The layout of this paper is as follows. In Section 2 we describe our semi-analytic model and give details of the SPH simulation we use. In Section 3 we compare properties of the two models, including galaxy masses, cold gas mass in halos as a function of redshift and the spatial distribution of the galaxies. In Section 4 we present our conclusions.

The SPH Simulation
SPH is a Lagrangian numerical method which follows the motion of a set of gas elements represented by discrete particles. The thermal energy and velocity of each particle are known at any given time and each particle has a fixed mass. Properties of the gas at the position of a particle can be estimated by smoothing these quantities over the NSPH nearest neighbouring particles. The gas properties are then used to calculate the forces acting on each particle in order to update the positions and velocities. In cosmological simulations both dark matter and gas particles are included and the particles are initially distributed in a manner consistent with a cosmological power spectrum. If the process of galaxy formation is to be simulated then radiative cooling of the gas must also be included.
The SPH simulation used here was performed using the Hydra code. This particular implementation includes a modification, described by Pearce et al. (2001), to prevent the rate of cooling of hot gas being artificially increased by nearby clumps of cold, dense gas, or "galaxies". Any gas hotter than 10 5 K is assumed not to interact with gas at temperatures below 12 000K. Thus, for cooling purposes the density estimate for a hot particle near a galaxy is based only on the neighbouring hot particles and the cooling rate is unaffected by the presence of the galaxy.
The simulation has 80 3 gas and 80 3 dark matter particles with individual masses of 2.57 × 10 9 h −1 M⊙ and 2.37 × 10 10 h −1 M⊙ respectively, contained in a cube of side 50h −1 Mpc. The power spectrum is that appropriate to a cold dark matter universe with the following parameter values: mean mass density parameter Ω0 = 0.35, cosmological constant Λ0 = 0.65, baryon density parameter Ω b = 0.0377, Hubble constant h = 0.71, power spectrum shape parameter Γ = 0.21 and rms linear fluctuation amplitude σ8 = 0.90. The gravitational softening length is 25h −1 kpc, fixed in physical coordinates.
The metallicity of the gas in the simulation, measured in terms of the mass fraction of metals, Z, is uniform and varies linearly with time according to: where Z⊙ denotes the solar metallicity, t(z) is the age of the universe at redshift z and t0 is the age of the universe at z = 0. This simulation makes no attempt to treat star formation and does not include any heating or feedback processes.

The N-body GALFORM Model
The semi-analytic model used here, which we will refer to as N-body galform, is a galaxy formation model which uses the output from an N-body simulation to calculate halo merger histories and semi-analytic techniques to model baryonic processes. Briefly, halo merger trees are constructed by identifying halos at each simulation output time using the friends-of-friends (FOF) algorithm of Davis et al. (1985). Each halo at each output time is identified as a progenitor of whichever halo contains the largest fraction of its mass at the next output time. The merger history of each halo at the final time can then be traced back. Semi-analytic techniques are used to treat the shock heating of gas during the formation of a halo, the cooling of gas within halos and, in the general case, the formation of stars and the merging of galaxies within halos. The full model predicts a wide range of galaxy properties including luminosity, stellar masses of the bulge and disk components and cold gas mass. Galaxy positions can be obtained since each galaxy is associated with a particle in the N-body simulation. Initially, this will be taken to be the most bound particle of the halo in which the galaxy formed, but if the galaxy subsequently merges with the central galaxy of another halo it will be associated with the most bound particle of that halo.
The semi-analytic methods employed in this work are taken from the galform model of Cole et al. (2000), who use a Monte-Carlo algorithm to generate realisations of halo merger histories. Helly et al. (2002) describe the N-body galform model and the technique used to obtain merger trees in detail, and investigate the effects of using simulation derived merger trees on the predicted galaxy populations.
In order to allow a direct comparison between the predictions of this model and those of the SPH simulation, the merger trees must be calculated from the dark matter component of the SPH simulation. Consequently, the time and mass resolution in the halo merger trees are determined by the properties of the SPH simulation and differ from the time and mass resolution of the simulation employed by Helly et al. We have a total of 61 outputs from the SPH simulation, the first 26 of which are logarithmically spaced in expansion factor between redshifts z ∼ 10 and z ∼ 1.5. The remaining outputs are equally spaced in time between z ∼ 1.5 and z = 0. This is something of an improvement in time resolution over the simulation used by Helly et al. (2002). However, the predictions of the galform model were not significantly affected when the number of timesteps was increased, so we do not expect this difference to be important.
There are two parameters which we vary in order to model the SPH simulation. The N-body galform model assumes that the distribution of mass in dark matter halos is described by the radial density profile found by Navarro, Frenk & White (1996, 1997. This profile contains a single free parameter, which can be expressed as the concentration parameter, c, defined by Navarro, Frenk & White or a halo scale radius, rNFW = r virial /c, where r virial is the virial radius of the halo. Like Cole et al. (2000), we set rNFW using the method described in the appendix of Navarro, Frenk & White (1997). No scatter is included in the scale radius as a function of halo mass. The radial density profile we assume for the hot gas within halos is described by Helly et al. This profile also contains one parameter, the core radius rcore, which we specify as a fraction of rNFW and may be held at a fixed value or allowed to increase with time from an initial value r 0 core . See Helly et al. (2002) for details. We also allow ourselves the freedom to vary the rate at which mergers occur between galaxies in the same dark matter halo. This is specified in terms of a merger timescale parameter, f df , which is a prefactor in the standard dynamical friction timescale. Reducing f df increases the rate at which mergers occur. See Cole et al. (2000) for details of the merger scheme we use.

COMPARISON BETWEEN SPH AND N-BODY GALFORM
In this section we compare the results of the SPH simulation with the N-body galform model, which uses merger trees derived from the dark matter component of the SPH simulation. Fig. 1 shows the positions and masses of the galaxies which form in a 5h −1 Mpc thick region in both the SPH simulation and N-body galform . The SPH "galaxies" (i.e. clumps of cold gas) shown here were identified using a FOF group finder on gas particles with temperatures between 8 000 and 12 000K (see Section 3.1.1).

Modelling SPH with N-body GALFORM
In order to produce a semi-analytic model of the SPH gas simulation using N-body galform we must first remove the treatment of star formation, feedback and chemical enrichment from galform. We set the metallicity of the gas to be the same as that in the simulation, using eqn.
(1). The cooling rate of the gas in our simulation depends on its density, which is estimated by searching for the NSPH nearest neighbours. The density of gas in halos with less than NSPH = 32 gas particles, or a total gas mass less than 8.2 × 10 10 h −1 M⊙, will in general be severely underestimated with an associated suppression of the cooling rate. Consequently, the mass of gas which cools is dependent on the particle mass.
In order to model this effect in the semi-analytic treatment, we first investigate the variation of the mean estimated density of gas in halos in the SPH simulation with Figure 1. Positions and masses of galaxies in a 5h −1 Mpc thick slice through the simulation volume. The panel on the left shows galaxies found in the SPH simulation using a friends of friends algorithm to identify clumps of cold gas particles. The panel on the right shows the galaxies predicted by the N-body galform model. Each circle represents a galaxy, and the area is proportional to the mass of the galaxy. Dark matter particles are shown as dots. Only galaxies with masses greater than 32 gas particle masses, or 8.2 × 10 10 h −1 M ⊙ , are shown. halo mass. A characteristic volume for each gas particle can be obtained by dividing its mass by its SPH density estimate. The total volume of the gas in a halo is calculated by summing the volumes of its constituent gas particles. The total volume is then divided by the mass of gas in the halo to obtain an estimate of the mean gas density. Fig. 2 shows this density estimate plotted against halo mass, at redshift z = 0. In halos identified using the FOF group finder with b = 0.2 we expect the mean gas density to be several hundred times the universal mean gas density. The dotted line shows the median of the mean densities of halos of a given mass. Halos with more than 32 particles have approximately constant mean density, although the density does increase somewhat with halo mass.
The estimated density rapidly drops once the halo mass falls below 32 dark matter particle masses. Since the cooling time of the gas is inversely proportional to its density this could significantly affect the amount of gas which cools in the smaller halos in the simulation. We incorporate this effect into the semi-analytic model by increasing the cooling time for gas in halos of fewer than 32 particles. A least squares fit to Fig. 2 gives: whereρSPH is the mean gas density estimated from the SPH simulation and M halo is the mass of the halo. The cooling time in our model is inversely proportional to the mean den-sity of the gas in the halo. In halos of fewer than 32 particles we replace the cooling time, τ cool , with a longer cooling time, τ SPH cool , given by where ρcrit is the critical density. We set the constant of proportionality, k, in this relation by requiring that the cooling time for halos of 32 particles be unchanged.

Halo by halo comparison
The masses of individual galaxies in the N-body galform model depend on the rate at which galaxy mergers occur within dark matter halos. Since the merger rate in the SPH simulation may not be the same as that in the semi-analytic model, we first compare the total amount of gas which cools in halos of a given mass. This quantity should be independent of the merger rate, at least in the semi-analytic case, and can be used to compare the treatment of cooling in the two models. In the SPH simulation a large galaxy forming at the centre of a halo through mergers may gravitationally affect the density, and hence the cooling rate, of nearby gas, but we do not expect this to be a large effect and the mass of gas which cools should be only weakly dependent on the merger rate. We adopt two different models for the evolution of the gas density profile in the semi-analytic treatment. The first is that used by Cole et al. (2000) in which the core radius in the gas profile increases with time in order to maintain the gas density at the virial radius. We may vary the initial core radius, r 0 core , in order to adjust the amount of gas which cools (the standard choice adopted by Cole et al. was r 0 core = 0.33rNFW. The second is a simpler model in which the core radius remains a constant fraction of the halo scale radius, rNFW. Again, the size of this fixed core may be varied in order to adjust the rate at which cooling occurs.
In order to quantify the mass of cold gas present in halos in the SPH simulation, we first associate gas particles with dark matter halos. A gas particle is considered to belong to a halo if it lies within a linking length b = 0.2 of a dark matter particle which belongs to that halo. In the unlikely event that dark matter particles from more than one halo are found within the linking length, the gas particle is assigned to the halo containing the nearest dark matter particle. The linking length used in this procedure is the same as that used to identify dark matter halos with the FOF group finder. This ensures that the condition for a gas particle to be associated with a halo is consistent with the definition of halo membership used for the dark matter particles.
The cooling function in our simulation permits gas to cool only to a temperature of 10 4 K. This allows us to distinguish between gas which has been heated and has subsequently cooled to 10 4 K and the diffuse cold gas in voids which has never been heated and is at much lower temperatures. The mass of gas which has cooled in each halo is obtained by summing the masses of all gas particles associ-ated with the halo and having temperatures between 8 000K and 12 000K. In the N-body galform model, the amount of cold gas in each halo is simply the mass of gas which has cooled from the hot phase, since the model includes no star formation. Fig. 3 shows the mean fraction of gas which has cooled as a function of halo mass, in both N-body galform and the SPH simulation. Here we consider four different N-body galform models. We vary the initial core radius in the gas profile between r 0 core = 1.0rNFW and 0.15rNFW and either fix the core radius as a fraction of the NFW scale radius or allow it to increase with time as described earlier. In the case of a fixed core, rcore = r 0 core at all times. The dotted lines in Fig. 3 show N-body galform models which include the modification to the cooling time in low mass halos described by eqn. (3). All four models reproduce the quantities of cold gas observed at redshift z = 0 in the SPH simulation remarkably well, for halos of mass greater than about 10 12 h −1 M⊙ or around 40 dark matter particles -in all but the worst case the difference is less than 50%. We find that if the core radius in the gas density profile is allowed to increase as gas cools, the fraction of cold gas is not particularly sensitive to the choice of intitial core radius, although a small initial value, r 0 core = 0.15rNFW, gives a slightly better match than if the core is initially larger. If the core radius is fixed as a fraction of the NFW scale radius a much larger value, r 0 core = 1.0rNFW, is necessary. The dashed lines in the figure show the fraction of gas which cools if cooling is allowed to occur at the normal rate in halos of all masses down to the mass of the smallest halo we can resolve in the simulation. Surprisingly, this appears to have little effect on halos with fewer than 32 dark matter particles for which the cooling rate has been altered. The fraction of gas which has cooled in larger halos also increases by a similar amount. The extra cold gas in these halos must have cooled in progenitors of fewer than 32 particles before being incorporated into larger halos. Overall, the change is not large, with some halos having around 10-20% more cold gas on average. This suggests that our results are not particularly sensitive to the way in which we model the loss of cooling efficiency in low mass halos, although in both cases the agreement between the SPH simulation and the semianalytic model is poor in such halos. Fig. 4 shows a direct comparison between the masses of cold gas in individual halos in the SPH simulation and the four N-body galform models of Fig. 3, again using the modified cooling time for low mass halos. The mass of cold gas predicted by N-body galform is plotted against the mass of cold gas in the simulation for each halo, with the initial core radius set to rNFW in the upper panels and 0.15rNFW in the lower panels. In the models shown on the left-hand side the core radius remains fixed at its initial value at all times. The long-dashed lines show where the points would lie if the simulation and the semi-analytic models were in perfect agreement.
Again, in all four cases the mass of cold gas in the SPH simulation is well correlated with the mass of cold gas in the N-body galform model. The small scatter, at least at high masses, shows that the dependence of cold gas mass on merger history must be similar in the SPH simulation and the semi-analytic model. N-body galform with a gas density profile with a fixed core radius appears to cool on Figure 3. Mean fraction of halo gas which has cooled at redshift z = 0 as a function of halo mass. The solid lines show the mean cooled gas fraction in halos in the SPH simulation and are the same in all four panels. The dotted lines show the cold gas fraction in N-body galform models where the cooling time in low mass halos is increased according to eqn (3). The dashed lines show N-body galform models without this adjustment. In the upper panels the initial core radius is set equal to the NFW scale radius of the halo. In the lower panels the core radius is set to 0.15 times the scale radius. In the panels on the left hand side the core radius remains fixed at its initial value for all redshifts, in the panels on the right it is allowed to increase to maintain the density of gas at the virial radius. average more gas in halos of all masses than the SPH simulation. This can be alleviated to some extent by increasing the size of the core in the gas profile but it appears that a rather large core in the gas distribution would be required to obtain good agreement. Allowing the core radius to increase as gas cools reduces the rate of cooling and results in closer agreement with the simulation; the best agreement is obtained for a small initial core radius of around 0.15rNFW, although the mass of cold gas in each halo is clearly not particularly sensitive to the initial core radius in this galform model.  . Halo cold gas mass, M cold , in four different N-body galform models plotted against halo cold gas mass in the SPH simulation at redshift z = 0. Each point corresponds to a single dark matter halo. The upper panels show N-body galform models with r 0 core = 1.0r NFW . The lower panels have r 0 core = 0.15r NFW . In the panels on the left, the core radius in the gas density profile is a fixed fraction of the NFW scale radius. In the panels on the right the core radius is allowed to grow in order to maintain the gas density at the virial radius.
at that redshift. Particles are associated with halos using the method described earlier in this section and, as before, "cold" particles are those with temperatures in the range 8 000-12 000K. Similarly, the mass of cold gas in the N-body galform model is obtained by summing the masses of the galaxies in the progenitor halos. Here we show results for two models, one with rcore fixed at r 0 core = 1.0rNFW (dotted lines) and the other with a growing core which has an initial core radius r 0 core = 0.15rNFW (dashed lines). The model of Cole et al. used a gas profile with a larger initial core radius, r 0 core = 0.33rNFW.
The long dashed lines show the mass of cold gas in progenitors in the simulation if instead of associating gas particles with halos directly, we use the FOF group finder to first identify clumps of cold gas and then associate clumps with dark matter halos. A clump is assigned to a halo if a dark matter particle from that halo is found within a dark matter linking length of the clump's centre of mass. If particles belonging to several halos are found in this region, the nearest to the centre of mass is used. A linking length b = 0.02 is used to identify the clumps and a minimum group size of 10 particles is imposed on the clumps. These lines are shown in Fig. 5 only to illustrate that there is some dependence on the way in which we define "cold halo gas" in the simulation. This second method will certainly underestimate the mass of cold gas because the group finder imposes a minimum mass on the clumps, missing smaller groups of cold particles. Also, at high redshift the gravitational softening length exceeds the linking length used to identify the clumps, so particles which ought to be considered part of a clump may not have collapsed to sufficiently high densities to be picked up by the group finder. We find that most of the discrepancy between these two SPH results is due to cold particles in small groups of fewer than five particles, at least with b = 0.02.
It is also possible that the first method of counting individual gas particles associated with halos overestimates the mass of cold gas in smaller halos, where the linking length becomes a significant fraction of the radius of the halo. Any particle within a linking length of the outer dark matter particles of the halo may be associated with that halo. Despite this uncertainty, it appears that more of the cold gas found in the simulation cooled at high redshift than in either of the N-body galform cases considered. At redshift 2 the discrepancy is approximately a factor of 2. Allowing the core radius to increase from a small initial value helps somewhat by encouraging more cooling initially and slightly suppressing it later, but the improvement is small compared to the size of the discrepancy with the SPH simulation for redshifts greater than around 2. Reducing the initial core radius in this model further has little effect on these results.
We have tried to model the effect of limited resolution on cooling in SPH blobs of fewer than 32 dark matter particles, but in the N-body galform model no cooling is possible in halos of fewer than 10 dark matter particles. It appears that in our SPH simulation some cooling does occur in these halos. However, it may not be useful to model the rate of cooling in this regime, since it is entirely artificial and likely to be dependent on the details of the particular SPH implementation. In any case, when halos in the SPH simulation first grow to 10 dark matter particles they may have already cooled some gas. These halos will eventually be incorporated into larger halos, where the cold gas mass becomes dominated by material which cooled in well resolved halos so that at late times the SPH and galform calculations converge. Fig. 6 shows the number density of galaxies as a function of mass in the SPH simulation and in the N-body galform model at redshift z = 0. Here, SPH "galaxies" are groups of particles identified by the FOF group finder applied to all particles with temperatures in the range 8 000-12 000K. We use a linking length b = 0.02 and impose a minimum group size of 10 particles. The results are insensitive to the specific choice of b within reasonable bounds. Two N-body galform cases are shown, one with a core of fixed size rcore = rNFW in the gas density profile, the other with a growing core of initial size r 0 core = 0.15rNFW. In both cases N-body galform predicts about 50% more galaxies with masses around Figure 6. Galaxy number density as a function of cold gas mass at redshift z = 0. The solid line shows galaxy number density in the SPH simulation. The other lines correspond to N-body galform models with 1) a fixed core radius rcore = r NFW (dotted line) and 2) a growing core which initially has r 0 core = 0.15r NFW (dashed line). The horizontal dot-dashed line shows the number density equal to one object per simulation volume. The vertical dot-dashed line is at a mass equal to 32 gas particle masses.

Galaxy by galaxy comparison
3×10 11 h −1 M⊙ or less and fewer galaxies with masses greater than this for the latter choice of r 0 core . The deficit in the number of massive galaxies is more apparent in the model with a large, fixed gas core radius. Since we know that the total amount of gas cooled in the semi-analytic models in each halo is similar to the amount that cooled in the simulation (see Fig. 4), this suggests that there is more merging occurring in the simulation. This does not necessarily indicate a failure of the semi-analytic model, however, since it is possible that numerical effects in the simulation contribute significantly to the merger rate.
To test this hypothesis, we varied the merger timescale parameter, f df in the semi-analytic models. Fig. 7 shows galaxy number density as a function of mass for three Nbody galform models with f df = 0.5, 1.0 and 2.0. All three have gas profiles with growing cores of initial radius r 0 core = 0.15rNFW. Doubling the merger timescale (f df = 2.0) drastically reduces the number of more massive galaxies and prevents the formation of any galaxies more massive than 10 12 h −1 M⊙. Halving the merger timescale (f df = 0.5) improves agreement with the simulation by increasing the masses of the largest galaxies and reducing the number of small galaxies. However, the improvement is relatively small and, in any case, the treatment of mergers in the N-body galform model reproduces the distribution of masses observed in the simulation reasonably well with our default f df = 1.0.
The N-body galform model described in Section 3 does not allow semi-analytic galaxies to be compared with their SPH counterparts on a one to one basis because mergers between galaxies in N-body galform are treated in a The dotted lines correspond to an N-body galform model with a fixed core radius in the gas density profile with rcore = r NFW . The short dashed lines correspond to a model with a growing core radius of initial value r 0 core = 0.15r NFW .
statistical manner. While the agreement between the galaxy mass distributions suggests that the overall merger rate in the N-body galform model is similar to that seen in the simulation, we cannot expect mergers to occur between the same galaxies in the two cases, and hence it is not possible to identify clumps of cold gas particles with individual semi-analytic galaxies.
This problem could be avoided by following the substructure within dark matter halos to determine when merg-ers between galaxies occur, using a method similar to that of Springel, White, Tormen & Kauffmann (2001). Unfortunately the halos in our simulation typically contain too few particles for this to be practical. Any dark matter substructure is rapidly destroyed by numerical effects.
In order to compare the masses of individual galaxies directly, we need an alternative way to ensure that the same galaxies merge in each model. We do this by using information from the baryonic component of the SPH simulation Figure 7. Galaxy number density as a function of cold gas mass at redshift z = 0 for N-body galform models with three different merger rates. All three models have gas profiles with a growing core radius which is initially set to r 0 core = 0.15r NFW . The merger timescale parameter f df is varied between 0.5 (dotted line), 1.0 (short dashed line) and 2.0 (long dashed line). The short dashed line is identical to the short dashed line in Fig. 6. The solid line shows the galaxy number density in the SPH simulation and is identical to the solid line in Fig. 6. The horizontal dot-dashed line shows the number density corresponding to one object per simulation volume. The vertical dot-dashed line is at a mass equal to 32 gas particle masses. The curves are truncated at 10 gas particle masses.
to merge N-body galform galaxies. We first populate the simulation volume with galaxies calculated using the N-body galform model, with merging of galaxies completely suppressed. We find the halo in which each semi-analytic galaxy first formed, and identify the gas particles associated with that halo as those with indices corresponding to the indices of the dark matter particles in the halo -this is possible because in our SPH simulation gas and dark matter particles with the same indicies are initially at the same locations and tend to remain in the same halos at later times. By redshift z = 0 some of these particles will be contained within SPH galaxies. Each semi-analytic galaxy is assigned to the SPH galaxy which contains the largest number of gas particles from the halo in which it formed. This procedure often results in several semi-analytic galaxies being assigned to the same blob of cold gas at redshift z = 0. These galaxies are assumed to have merged and their masses are added together. It is possible to think of rare situations where our method might incorrectly merge galaxies, but this is the best that can be done within the limitations of the SPH simulation.
We are only able to detect SPH galaxies with 10 particles or more, so it is inevitable that sometimes a semianalytic galaxy will not be assigned to any SPH galaxy. This would occur if the semi-analytic galaxy formed in a halo which, in the simulation, failed to cool enough particles to constitute a group by redshift z = 0. Such galaxies are generally found in small, recently formed halos and typically have masses of around 10 gas particle masses or less. These galaxies account for about 20% of the total semi-analytic galactic mass in the simulation volume. We also find that a small number (about 2%) of the SPH galaxies have no corresponding semi-analytic galaxy. Almost all of these are poorly resolved objects close to the 10 particle threshold.
Since the unmatched semi-analytic galaxies largely correspond to SPH galaxies which have yet to gain enough cold particles to be identified by the group finder, we simply omit them from the comparison shown in Fig. 8. Here, we compare the masses of the merged semi-analytic galaxies with the corresponding galaxies in the SPH simulation. Each point on the plot represents a single SPH galaxy which has been associated with one or more semi-analytic galaxies. We have split the galaxies into two categories -central galaxies (left panel) and satellite galaxies (right panel). This allows us to test the assumption made in the galform model that no gas cools onto satellite galaxies. If this is not true, galaxies which are considered to be satellites in the N-body galform model will have systematically lower masses than their SPH counterparts. It therefore makes sense, for this purpose, to use information from the semi-analytic model (and not the SPH simulation) to determine whether each galaxy is a satellite. The semi-analytic mass of each galaxy shown in Fig. 8 is the sum of the masses of the galform galaxy fragments which have been associated with the corresponding SPH galaxy. We identify the galaxy as a central galaxy if any one of those fragements was a central galaxy before we applied our SPH merging scheme. If all of the fragments were satellites, the galaxy is considered to be a satellite.
There is clearly a very strong correlation between the mass of each simulated galaxy and its semi-analytic counterpart, although the N-body galform galaxies appear to be systematically more massive by up to 25% at low masses. The scatter in this plot is comparable to that in Fig. 4. There appears to be little or no systematic difference between satellite and central galaxies, which suggests that no significant amount of cooling of gas onto satellite galaxies is occurring in the simulation. There are a few outlying points where the galform and SPH masses are drastically different -these are mainly satellites, but there are as many with much higher galform masses than SPH masses as there are with lower masses. These are most likely a result of the SPH merging algorithm assigning galform galaxy fragments to the wrong SPH galaxy.
Finally, we compare the clustering of galaxies in the two models. While the spatial distribution of dark matter halos in the N-body galform model is identical to that in the simulation, the number of galaxies in each halo and their distribution within the halo may differ. Fig. 9 shows two point galaxy correlation functions for galaxies in the SPH simulation and two different N-body galform models, both of which have gas profiles with growing core radii which are initially set to r 0 core = 0.15rNFW. In the first galform model, merging between galaxies is treated using the dynamical friction approach of Cole et al. with f df = 0.5, which gives a closer match to the distribution of galaxy masses in the simulation than our default value of 1.0 (see Fig. 7.) In the second galform model, we use the SPH based merging scheme described earlier in this section and put each Figure 8. Comparison between galaxy masses in the SPH and N-body galform models. The merger scheme described in Section 3.1.2 is used to identify N-body galform galaxies with SPH galaxies. Galaxies lying on the dashed line have equal masses in both models.
The panel on the left shows only galaxies which are considered to be central galaxies in the N-body galform model. The panel on the right shows only galaxies which are satellites in the N-body galform model. merged galform galaxy at the position of its associated SPH galaxy. In each case, we include only the 700 (left panel of Fig. 9) or 300 (right panel) most massive galaxies in our calculation. This ensures that the overall density of galaxies in the volume is the same in each sample. Picking the 700 largest galaxies excludes all galaxies less massive than about 8 × 10 10 h −1 M⊙ or 30 gas particles. Picking the 300 largest galaxies corresponds to a minimum mass of approximately 1.5 × 10 11 h −1 M⊙ or around 60 gas particles.
The correlation function has been calculated on scales of up to 25h −1 Mpc. This is half of the size of the simulation box, so the results presented here should not be treated as predictions of the true galaxy correlation function. Instead, the plots in Fig. 9 are intended to compare the relative clustering of galform and SPH galaxies in our small simulation volume. All three models show qualitatively similar behaviour. When we consider the larger sample of galaxies (left panel in Fig. 9), we see an anti-bias relative to the dark matter on scales of less than a few h −1 Mpc, with galaxies tracing the dark matter on larger scales. This behaviour agrees with previous semi-analytic (e.g. Kauffmann et al. 1999;Benson et al. 2000) and SPH simulation (e.g. Pearce et al. 2001) results. If we include only the 300 most massive galaxies in the simulation volume (right panel in Fig. 9), we see that on large scales these more massive galaxies are more strongly clustered than the dark matter in all three cases.
The N-body galform model with f df = 0.5 is in close agreement with the SPH simulation on scales larger than a few h −1 Mpc when we use the 700 most massive galaxies. This is to be expected since we have the same distribution of dark matter halos in each case and the merger rate in the semi-analytic model has been adjusted to reproduce roughly the distribution of galaxy masses in the simulation. On length scales smaller than this, where the correlation function is sensitive to the details of our treatment of galaxy mergers within halos, there is a difference of almost a factor of 2 between the SPH simulation and the galform model with f df = 0.5. The treatment of mergers in this model reproduces the overall distribution of galaxy masses but the merger rates and galaxy distributions in halos of a given mass may not be in close agreement. When we merge galform galaxies by associating them with groups of cold gas in the SPH simulation (short dashed lines in Fig. 9), the correlation functions agree to within about 25% on these small scales. If we consider only the 300 most massive galaxies in each case, the correlation function for the model with f df = 0.5 drops to almost an order of magnitude below that of the SPH simulation on scales of about 0.3h −1 Mpc. Again, this is due to differences in the merger rates in halos of a given mass since the discrepancy disappears if we use our SPH-based merging algorithm.
Once we ensure that the same galaxies merge in each model, any remaining differences between the correlation functions shown must be due to differences in the galaxy masses. The most massive 700 objects in the SPH model must be a somewhat different population to the 700 most massive objects in the semi-analytic model. In fact, we find that the two samples possess only 590 objects (about 85%) in common. This is an inevitable consequence of the scatter in the relation between SPH and semi-analytic galaxy masses shown in Fig. 8. Unless there is zero scatter, there will always be galaxies just massive enough to be included in the correlation function for one model which will not be included in the sample for the other. This explains why the level of agreement is reduced when we consider only the most massive galaxies, where we might have expected to obtain improved agreement. By increasing the minimum mass required for a galaxy to be included in each sample we increase the proportion of galaxies which have masses close to the threshold and the fraction of galaxies common to both samples falls slightly to 237 out of 300, or about 80%.

DISCUSSION AND CONCLUSIONS
In this paper we have used the N-body galform model of Helly et al. (2002) to compare the results of a semi-analytic calculation of the radiative cooling of gas in halos with results from a cosmological SPH simulation. We have tried to reproduce the results of the simulation by adjusting the semi-analytic cooling prescription and modelling the effects of limited mass resolution on the SPH cooling rate.
We compared properties of halos in the simulation with the properties of the same halos in the N-body galform model. First, we looked at a global property of the halo population, the average fraction of cooled gas at redshift z = 0 as a function of halo mass. We found that a model in which the gas density profile with an initially small core radius which is able to increase with time provided the best match to the mean cold gas fractions seen in the SPH simulation among those considered. The level of agreement was excellent for halos with masses above the resolution limit of the SPH simulation.
Our method also enabled us to compare the cool gas content of individual halos. For the gas density profile described above, and also for a profile with a fixed core radius, the total mass of cold gas in each halo was found to be in remarkably good agreement at cold gas masses greater than about 10 12 h −1 M⊙. In poorly resolved halos with lower cold gas masses the scatter in this comparison increased substantially, to a factor of about 3. We found that much of the cold gas found in the more massive halos in the N-body galform model generally cooled at later times than the gas in the same halos in the SPH simulation. By a redshift of 2 in the N-body galform case, the progenitors of the halos contained only half as much cold gas as was present in the simulation. As the redshift increases, the mass of cold gas in the SPH simulation becomes dominated by material which cooled in very small halos, where the cooling rate may be strongly affected by resolution effects and depends sensitively on the SPH implementation (Springel & Hernquist 2002). These effects are difficult to model reliably and so the discrepancy between the galform and SPH cold gas masses increases at higher redshifts.
We then turned our attention to the properties of individual "galaxies" (i.e. cold gas clumps) at redshift z = 0. Our best fit model gave a distribution of galaxy masses in good agreement with those in the SPH simulation for galaxies of more than 32 particles when we used the merger timescale of Cole et al. (2000), although the N-body galform model contained a somewhat greater number of low mass galaxies and fewer very massive galaxies than the simulation. Doubling the merger rate in the galform model improved the agreement at all masses, but note that the merger rates in the SPH simulation may not be reliable due to the effects of artificial viscosity .
In our semi-analytic approach, galaxy mergers are treated in a probabilistic fashion based on the dynamical friction timescale. Thus, a direct identification of semianalytic and SPH galaxies is not possible. In order to circumvent this problem, we suppressed all merging in the N-body galform model and then used information from the SPH simulation to merge the semi-analytic galaxies and to associate the merged galaxies with groups of cold gas particles in the simulation. This gave us a semi-analytic mass for each galaxy in the SPH simulation. We found that these masses were generally similar (within about 50% for larger galaxies) with a scatter close to that seen in the comparison of halo cold gas masses.
Finally, we examined the clustering properties of the more massive galaxies in the SPH simulation and two Nbody galform models. The first used the dynamical friction treatment of galaxy mergers, the second used our SPH merging scheme. We found that the correlation functions of galaxies in both galform models agreed well with the SPH simulation on scales larger than typical group and cluster sizes, but that on scales of a few h −1 Mpc or less the correlation function of galaxies in the galform model with merging based on the dynamical friction timescale was higher by almost a factor of 2. Using the SPH merging scheme reduced this discrepancy to about 25%.
Our comparison shows that it is possible to reproduce accurately gas cooling, and to a lesser extent galaxy merger rates, in an SPH simulation using semi-analytic methods. Benson et al. (2001a) demonstrated that the overall rate of cooling, globally and in halos of a given mass, predicted by SPH and semi-analytic models show remarkable consistency. They found that the overall fractions of hot gas, cold, dense gas and uncollapsed gas agreed to within 25% at z = 0. The cold gas fractions in halos of a given mass were found to agree to within 50%, with the SPH simulation cooling more gas than the semi-analytic model. This is consistent with the results presented here, since our best semi-analytic model assumes a gas density profile with a smaller core radius than that of Benson et al. , resulting in a higher central gas density in each halo and more rapid cooling.
Here we have shown that, with only minor changes to the semi-analytic model, very close agreement can be obtained on a halo by halo basis when merger trees are taken from the SPH simulation. The agreement between SPH and semi-analytic masses for individual halos indicates that the dependence of the cooling rate on merger history is very similar in the two cases. Given the quite different limitations and assumptions inherent in the two techniques, this is a remarkable result. While we have allowed ourselves some freedom to adjust the semi-analytic model in order to maximise the level of agreement with the simulation, it should be noted that in our best fit model, the only changes we have made to the cooling model of Cole et al. (2000) are a slightly smaller core in the gas density profile and an increased cooling time in small halos. Neither of these changes have a large effect on the mean cold gas fraction at z = 0. Springel & Hernquist (2002) show that when SPH is formulated in terms of the thermal energy equation, substantial overcooling may occur in halos of fewer than several thousand particles -for example, gas may cool as it passes Figure 9. Two point galaxy correlation functions for three different models -the SPH simulation (solid lines), an N-body galform model with merger rate parameter f df = 0.5 (dotted lines) and an N-body galform model using the SPH based merger scheme described in Section 3.1.2 (short dashed lines). The long dashed lines show the correlation function for the dark matter in the SPH simulation. The 700 most massive galaxies in each case are included in the calculation for the left panel and only the 300 most massive galaxies are included in the right panel. Both N-body galform models have a gas density profile with a core radius which is allowed to grow from an initial value of r 0 core = 0.15r NFW .
through shocks which have been artificially smoothed out by the SPH algorithm. They demonstrate that a new formulation ('entropy SPH') using entropy rather than thermal energy as an independent variable, which conserves both energy and entropy, can significantly reduce this problem. This conclusion would seem to suggest that the quantities of gas cooling in the majority of halos in our SPH simulation may be overestimated. This could explain why a gas profile with a smaller core radius than that used by Cole et al. is required in our semi-analytic model to reproduce the quantities of cold gas in the simulation. However, the Hydra SPH code which we use in this work is significantly different from the GADGET code (Springel, Yoshida & White 2001) employed by Springel & Hernquist and it is not clear to what extent our simulation suffers from the overcooling effect.
In an independent investigation carried out concurrently with this one, Yoshida et al. (2002) compared gas cooling in SPH simulations carried out using GADGET with a semi-analytic model based on that of Kauffmann et al. (1999). This model contains a simpler cooling prescription than used in this work -the gas within each halo is assumed to trace the dark matter exactly at all times so there is no core radius. Yoshida et al. adopt a similar approach to our own, taking halo merger histories from the dark matter in their SPH simulations and neglecting star formation and feedback in both models. They show results for two of the SPH implementations investigated by Springel & Hernquist -one is the entropy SPH implementation discussed above, the other is a 'conventional' implementation based on taking the geometric means of the pairwise hydrodynamic forces between neighbouring particles. Yoshida et al. find good agreement between the masses of individual galaxies in their semi-analytic model and the entropy SPH implementation. SPH galaxy masses, however, can differ by a factor of 2 between the two SPH implementations considered, but Yoshida et al. believe the entropy SPH to be the more reliable technique and note that their 'conventional' SPH implementation actually suffers the overcooling problem more severely than other conventional implementations, including the Hydra code which we have used here.
Overall, it appears that the differences between cooling rates predicted by SPH and semi-analytic techniques are small, and quite possibly comparable to the uncertainty in the SPH results. As well as providing evidence to support the treatment of cooling in current semi-analytic galaxy formation models, these results show that semi-analytic modelling provides a convenient, alternative way to add a baryonic component to an N-body simulation, which is at least as reliable as an SPH simulation. When used to investigate star formation and feedback prescriptions this approach allows the investigation of large regions of parameter space at little computational cost and so can provide an indication of how these phenomena may be included in full hydrodynamic simulations.