Environmental dependence of the mass-metallicity relation in cosmological hydrodynamical simulations

We investigate the environmental dependence of the gas-phase metallicity for galaxies at $z=0$ to $z\gtrsim 2$ and the underlying physical mechanisms driving this dependence using state-of-the-art cosmological hydrodynamical simulations. We find that, at fixed stellar mass, central galaxies in massive halos have lower gas-phase metallicity than those in low-mass halos. On the contrary, satellite galaxies residing in more massive halos are more metal-rich. The combined effect is that massive galaxies are more metal-poor in massive halos, and low-mass galaxies are more metal-rich in massive halos. By inspecting the environmental dependence of other galaxy properties, we identify that the accretion of low-metallicity gas is responsible for the environmental dependence of central galaxies at high $z$, whereas the AGN feedback processes play a crucial role at low $z$. For satellite galaxies, we find that both the suppression of gas accretion and the stripping of existing gas are responsible for their environmental dependence, with negligible effect from the AGN feedback. Finally, we show that the difference of gas-phase metallicity as a function of stellar mass between protocluster and field galaxies agrees with recent observational results, for example from the MAMMOTH-Grism survey.


INTRODUCTION
Gas-phase metallicity is an important probe of a variety of astrophysical processes, like gas inflow, outflow, and star formation activity, in galaxy formation and evolution. In the past decades, several scaling relations for the gas-phase metallicity have been established based on the galaxy survey data from our local volume to high-z Universe, like the mass-metallicity relation (MZR) (e.g. Tremonti et al. 2004;Erb et al. 2006;Maiolino et al. 2020) and the fundamental metallicity relation (FMR) (e.g. Ellison et al. 2008;Mannucci et al. 2010;Dayal et al. 2013). Meanwhile, theoretical models and numerical simulations have provided us insights into the underlying physical processes that drive these scaling relations (e.g. Bouché et al. 2010;Dayal et al. 2013;Lilly et al. 2013;Dekel & Mandelker 2014;Peng & Maiolino 2014a;Kacprzak et al. 2016).
Galaxy evolution is not only affected by internal processes, but also influenced by external interactions with the surrounding environment (Baugh 2006;Mo et al. 2010). From this perspective, galaxies can be divided into central ones, which live in the center of dark matter halos, and satellite ones, which are accreted by other massive halo and move in the halo until they merge with the central galaxy in the halo center (Wechsler & Tinker 2018). Various astrophysical diagnostics are used to probe the impact of the environment on galaxy evolution, including the gas-phase metallicity. At low z, Pasquali et al. (2012) found that satellite galaxies have higher gas-phase metallicity than central ones with similar stellar mass (see also Peng & Maiolino 2014b;Donnan et al. 2022). Similarly, Maier et al. (2019) found that star-forming cluster galaxies have higher gas-phase metallicity than star-forming field galaxies, even though no difference in the star formation rate (SFR) is seen, indicating that gas-phase metallicity is more sensitive to the environment than SFR.
However, there is still a large diversity for the environmental dependence of the gas-phase metallicity at high z. For example, Shimakawa et al. (2015) found that protocluster galaxies at z > 2 have higher gas-phase metallicity than those in the field by 0.15 dex. Calabrò et al. (2022) found that, at z ∼ 3, galaxies in over-dense regions have lower gas-phase metallicity than those in the field by ∼ 0.1 dex. Chartab et al. (2021) found that galaxies in the field are more metal-rich than their counterparts in over-dense regions at z ∼ 2.3, and the trend reverses at z ∼ 1.5, where galaxies in over-dense regions become more metal-rich. Recently, Wang et al. (2022a) reported the result from the first measurement of the mass-metallicity relation (MZR) at z ∼ 2.3 in one of the MAMMOTH protocluster region via grism spectroscopy (see Cai et al. 2016Cai et al. , 2017Shi et al. 2021;Zheng et al. 2021;Zhang et al. 2022a). They found that massive galaxies in protoclusters have lower gas-phase metallicity than field galaxies, while, for low-mass galaxies, those in protoclusters are more metal-rich.
On the theoretical side, current hydrodynamical simulations can provide some insight into the underlying physics that drives the environmental dependence of gas-phase metallicity (e.g Schaye et al. 2015;Pillepich et al. 2018a;Davé et al. 2019;Rosas-Guevara et al. 2022;Metha & Trenti 2023). Bahé et al. (2017) studied the metallicity of satellite galaxies in the EAGLE simulation, where they found that the metal enrichment of satellite galaxies is driven by the suppression of low-metallicity gas inflow and the stripping of lowmetallicity gas from the galaxy outskirt. Gupta et al. (2018) found that galaxies are chemically enriched even when they have not been accreted into clusters at z < 1.
In this paper, we use state-of-the-art hydrodynamical simulations to investigate the environmental dependence of gas-phase metallicity from z ∼ 2.3 to z = 0. We will show how central and satellite galaxies play different roles, as well as how the gas inflow and outflow processes regulate the gas-phase metallicity. Finally, we will present the MZR difference in protoclusters and the field, which agrees well with observational results in Wang et al. (2022a).
In § 2, we introduce the simulation data used in this paper. The main results are presented in § 3 and summarized in § 4. Throughout this paper, we converted all cosmology-dependent quantities to a concordance ΛCDM cosmology with H 0 = 100h km/s/Mpc, h = 0.7, Ω Λ = 0.75, and Ω m = 0.25.

DATA
We are using the EAGLE hydrodynamical simulation Crain et al. 2015;McAlpine et al. 2016;The EAGLE team 2017), which consists of a suite of cosmological hydrodynamical simulations of different box sizes, resolutions, and subgrid recipes. The analysis in this paper is mainly based on the simulation labeled with Ref-L100N1504. This specific simulation contains 1504 3 dark matter particles with each weighing 9.70 × 10 6 M and 1504 3 baryonic particles with each weighing 1.81 × 10 6 M in a (100cMpc) 3 cubic box.
Dark matter halos are identified by applying the Friends-of-friends (FoF) method on all dark matter particles, and these halos are called main halos. Subhalos are identified by applying the SUBFIND algorithm on all types of particles (Springel et al. 2001). Then, for each identified substructure, the baryonic part is defined as a galaxy and the dark matter part is defined as a subhalo. In each FoF halo, the subhalo with the lowest gravitational potential is defined as the central subhalo and the galaxy in it is defined as the central galaxy, while others are satellite galaxies. The subhalo merger trees are built with the SUBLINK algorithm (Rodriguez-Gomez et al. 2015).
The mass for each main halo is defined as the total mass within a radius where the mean density enclosed is 200 times the critical density. For each galaxy, the stellar mass is defined as the total mass of star particles within 30 pkpc, and SFR is defined as the sum of SFR for all star-forming gas particles within the same aperture 1 . The specific SFR (SSFR) is defined as SSFR = SFR/M * . The inter-stellar medium (ISM) mass for each galaxy is defined as the total gas mass within the same aperture. The gas-phase metallicity is quantified with the relative abundance of oxygen and hydrogen, log(O/H), for all star-forming gas particles. In this work, we only include star-forming galaxies with non-zero SFR.

RESULTS
1 This stellar mass definition in the EAGLE simulation is recommended by Schaye et al. (2015), where they emphasized that this aperture constraint can give results close to the Petrosian apertures that are often used for observation, which is used to tune the parameters in subgrid recipes in the EAGLE simulation. They also emphasized that this aperture effect is negligible for galaxies with M * < 10 11 M , where Figure 9 in Schaye et al. (2015) shows that the effective radius for galaxies with M * < 10 11 M is usually smaller than 10kpc. Meanwhile, we also found that our main results do not change if we adopted a different stellar mass definition, e.g. total stellar mass bound to the subhalo.  Note-N is the number of galaxies in each bin, and log p is the 10-based logarithm of the p value from the KS test for the gas-phase metallicity residual between galaxies in each stellar mass bin and galaxies in each stellar mass and halo mass bin. log p < −1.3 indicates that the probability that the two samples in question come from the same distribution is smaller than 5%.
Note-The log p values for bins with less than 10 galaxies are omitted.
In this section, we first presented the MZR measurements for simulated galaxies in the EAGLE simulation, together with their environmental dependence, in § 3.1. Then, we analyzed the physical origin of the environmental dependence by studying the gas content, halo mass, and black hole mass of these galaxies in § 3.2. Finally, we presented the MZR results at high z in protocluster and field regions in § 3.3.
3.1. The environmental dependence of MZR Figure 1 shows the gas-phase metallicity as a function of stellar mass for galaxies at z = 0, z = 1, and z = 2.3 in the EAGLE simulation. The shaded regions are for all galaxies with non-zero SFR, and the results of central and satellite galaxies are presented in magenta and cyan symbols, respectively. The fitting results from Zahid et al. (2014) are also shown in red curves. As one can see, also noted by Schaye et al. (2015), the EAGLE simulation over-predicts the gasphase metallicity compared with observational results at z ∼ 0, especially for low-mass halos. Schaye et al. (2015) argued that observations tend to under-estimate the gas-phase metallicity due to a non-negligible fraction of metal condensed on dust grains (e.g. Dwek 1998;Mattsson et al. 2014). Besides, gas-phase metallicity starts to decline above 10 10.5 M at z 1 (see also Torrey et al. 2019), which is not seen in observation. It is noteworthy that De Rossi et al. (2017) found that AGN feedback can effectively suppress the gas-phase metallicity for these massive galaxies. Currently, there is no evidence showing that this discrepancy depends on environment due to the lack of observational data at z ∼ 1. The next-generation surveys, like MOONS ) and PFS (Takada et al. 2014), enable us Here one can see that the gas-phase metallicity monotonically increases towards low z at fixed stellar mass. And the metallicity of satellite galaxies is higher than central galaxies by ∼ 0.1 dex.
to study the environmental dependence of MZR (Wang et al. 2020a(Wang et al. , 2021 and compare them with simulations. At fixed stellar mass, one can see that satellite galaxies are more chemically enriched than central galaxies, consistent with previous observational and theoretical results (e.g. Ellison et al. 2009;Davé et al. 2011;Pasquali et al. 2012;Peng & Maiolino 2014b;Bahé et al. 2017). Figure 2 shows the residual gas-phase metallicity with respect to the median MZR in Figure 1 (shaded region) for galaxies with different stellar mass and host halo mass. At low-mass end, galaxies in massive halos are more metal-rich than those in low-mass halos, and the trend is reversed for massive galaxies, where those in massive halos are more metal-poor. Figure 8 presents the results obtained in finer halo mass bins with a bin width of 0.3 dex, where one can still see a similar trend as in Figure 2, showing that our results are not biased by the halo mass bin width adopted. Table 1 presents the number of galaxies in each stellar mass and halo mass bin at three redshift snapshots for centrals and satellites, respectively. For galaxies in each stellar mass bin, we also perform Kolmogorov-Smirnov tests between those in different halo mass bins and all galaxies in the whole host halo mass range, and the logarithmic p values are presented in Table 1. We note that a log p value smaller than -1.3 means that the probability that two samples in question come from the same distribution is smaller than 5%, indicating that the difference between these two samples are statistically significant. For example, for central galaxies with 10 10 M ≤ M * < 10 10.2 M at z = 2.3, we have log p values of -2.9 and -8.7 for those with 10 11 M ≤ M h < 10 12 M and 10 12 M ≤ M h < 10 13 M , respectively, indicating that the dependence of the gas-phase metallicity on host halo mass for these central galaxies is not due to statistical fluctuation. Results in Table 1 confirms that the halo mass dependence shown in Figure 2 is statistically significant. For clarity, we plot those points with p ≤ 0.05 using filled symbols and those with p > 0.05 using open symbols in Figure 2.
To understand the environmental dependence of gasphase metallicity for galaxies with different stellar mass, we present the gas-phase metallicity residuals for central and satellite galaxies separately on the middle and bottom panels of Figure 2. For central galaxies, those in massive halos are more metal-rich than their counterparts in low-mass halos. On the contrary, satellite galaxies in more massive halos are more metal-rich than those in low-mass halos. Combined with that the satellite fraction monotonically decreases with increasing stellar mass (e.g. Zheng et al. 2005;Yang et al. 2008), the environmental dependence of gas-phase metallicity shown on top panels can be explained by the relative abundance of central and satellite galaxies at different stellar mass bins, where central galaxies dominate the massive end and satellite galaxies dominate the low-mass end.
It is noteworthy that the IllustrisTNG simulation can also produce similar environmental dependence of gasphase metallicity for central and satellite galaxies, as shown in Appendix B and Figure 9, despite the difference in their subgrid recipes.

Physical causes of the environmental dependence of MZR
The gas-phase metallicity is regulated by a variety of processes (see e.g. The median gas phase metallicity as a function of stellar mass for galaxies with different halo mass at z = 0, z = 1, and z = 2.3. The number of galaxies in each bin is presented in Table 1. For clarity, we show the metallicity offset with respect to the average MZR in Figure 1. The top panels show the results for all of the galaxies in three halo mass bins, while the middle and bottom panels show the results for central and satellite galaxies separately. Error bars show the standard deviation of the bootstrap sample. In each stellar mass bin, the difference in the gas-phase metallicity residual distribution for galaxies in each halo mass bin and those without halo constraint is quantified by a p value from the KS test, as give in Table 1. Here we plot those points with p ≤ 0.05 using filled symbols and those with p > 0.05 using open symbols. Our results show that, with stellar mass fixed, central galaxies in massive halos are more metal-poor than those in less-massive halos, and the trend is reversed for satellite galaxies, where satellites in more massive halos are more metal-rich. which can be grouped into three categories. The first one is star formation. This process consumes cold gas to form new stars, which can reduce the cold gas amount. Moreover, the stellar wind and the supernovae feedback can enrich the gas-phase metal content by returning metal into the ISM. The overall effect of the star formation activity is to enrich the metal content in ISM. The second one is gas inflow processes through either gas accretion or galaxy merger. The impact on the global gas-phase metallicity depends on the relative metallicity of the accreted gas and the existing ISM. Previous studies found that usually accreted gas is more chemically pristine than the ISM (e.g. Wright et al. 2021), so that the gas inflow can dilute the ISM content and reduce the gas-phase metallicity (Ceverino et al. 2016).
The last one is gas outflow driven by various processes (e.g. Finlator & Davé 2008;Bouché et al. 2007;Davé et al. 2011;Feldmann 2015;Trussler et al. 2020). First of all, gas outflows can reduce the ISM amount so that the gas-phase metallicity becomes easier to be altered by other processes. Then, some outflow processes prefer to eject gas whose metallicity deviates from the globally averaged value so that the global metallicity can be increased or decreased, depending on the sign of the deviation. For example, the AGN feedback process prefer to accelerate/heat gas in the galaxy center so that these gas are preferentially ejected. On the contrary, the ram-pressure stripping effect prefers to affect gas on the galaxy outskirt. If the galaxy of interest exhibit a nonzero metallicity gradient (e.g. Wang et al. 2017Wang et al. , 2019Wang et al. , 2020bCollacchioni et al. 2020;Hemler et al. 2021;Tissera et al. 2022;Wang et al. 2022b;Li et al. 2022b), the above two outflow processes can also change the global metallicity (van Loon et al. 2021). It is noteworthy that the differential wind assumption, where metals are more efficiently ejected than other elements through outflow, is adopted by many analytical models to explain observational results (e.g. Recchi et al. 2008;Dayal et al. 2013).
Next, we will explore the physical causes for the environmental dependence of gas-phase metallicity from these three aspects for central and satellite galaxies, separately.
3.2.1. Central galaxies Figure 2 shows that, at z ∼ 2.3, central galaxies in massive halos are more metal-poor than those in lowmassive halos. The gas-phase metallicity difference is about 0.1 dex for central galaxies in ∼ 10 11.5 M and ∼ 10 12.5 M halos. Figure 3 shows the difference of other properties as a function of stellar mass for central galaxies in different halo mass bins, where one can see that central galaxies in massive halos have more abundant ISM content, which can dilute the metallicity if the excess fraction of ISM is metal-poor. Actually, Mitchell et al. (2020) studied the gas accretion onto central galaxies in the EAGLE simulation, where they found that the gas accretion rate onto central galaxies at z ∼ 2 is almost proportional to their host halo mass, and 50% of these accreted gas is pristine (see also Kereš et al. 2005;Dekel et al. 2009;Kereš et al. 2009;Zhang et al. 2023). Consequently, at given stellar mass, central galaxies living in massive halos can obtain more low-metallicity gas through accretion, which can effectively dilute the gasphase metallicity of these galaxies. Besides, Figure 3 also shows that central galaxies in more massive halos are more actively forming new stars than those in lowmass halos, which is expected from FMR (e.g. Ellison et al. 2008;Mannucci et al. 2010). Even though the excess star formation activities can chemically enrich the ISM, it still cannot compensate the dilution effect brought by the gas inflow. Finally, we find that massive halos prefer to host more massive black holes than those low-mass halos by ∼ 0.1 dex. In order to figure out whether central super-massive black holes and their feedback effects play a role here, we compare the environmental dependence for simulations with and without AGN feedback in Figure 11, where one can see that the dependence of MZR on halo mass is still present when the AGN feedback is disabled (dashed lines) at z ∼ 2.3. This indicates that AGN feedback effects only play a minor role here. Figure 2 shows that central galaxies in massive halos at z = 0 have lower gas-phase metallicity than their counterparts in low-mass halos by 0.1-0.2 dex. However, as shown in Figure 3, there is nearly no difference in their ISM content, so the dilution effect discussed above does not apply here. Neither do we see any obvious difference in their SSFR. Finally, there is a strong dependence of black hole mass on the host halo mass, where central galaxies in massive halos prefer to harbor more massive black holes than their counterparts in low-mass halos. In the EAGLE simulation, due to the simple one-mode AGN feedback recipe adopted, the feedback energy is proportional to the mass of black holes, so that central galaxies in massive halos, which possess more massive black holes, are able to trigger more powerful AGN feedback and expel more gas out of the halo. This scenario is supported by Mitchell et al. (2020), where they found that the AGN feedback is responsible for the majority of gas outflow on both galaxy and halo scales for halos with M h ≥ 10 12 M . The impact of gas outflow induced by AGN feedback on the metallicity of central galaxies is two-fold. First, the EAGLE simulation predict negative gradients in the spatial distribution of gas-phase metallicity for central galaxies (see Bahé et al. 2017;Tissera et al. 2019Tissera et al. , 2022, and the AGN feedback preferentially heat the gas in the galaxy center, so that the AGN feedback process is able to expel these metal-rich gas in the galaxy center and decrease the global metallicity. Second, since we did not see any difference in the ISM content for central galaxies in different mass of halos, the ISM deficiency caused by AGN feedback is compensated by the accretion of gas, which is more metal-poor than the existing gas in the galaxy and can effectively dilute the metal content in the ISM. Yang et al. (2022) studied the relation between the gas-phase metallicity and the halo mass for central galaxies at fixed stellar mass using clustering strength to indicate halo mass. For massive galaxies above 10 10 M , they detect no clustering difference due to poor statistics, while both EAGLE and IllustrisTNG predict more massive halos prefer to host metal-poor central galaxies at fixed stellar mass. More observational data is required to test the prediction of these hydrodynamical simulations.
At z = 1, one can simultaneously see the excess of the ISM content and more massive black holes for central galaxies in massive halos, showing that both the accretion of low-metallicity gas and the AGN feedback play a role in reducing their global metallicity.   Figure 2, except here the p-values are calculated for the residual ISM mass fraction, SSFR, and black hole mass. At high z, central galaxies in more massive halo possess more ISM, while, at low z, central galaxies in more massive halo harbor more massive black holes.
In Appendix C and Figure 11, we present the gasphase metallicity difference of central galaxies with different halo mass in a simulation where the AGN feedback is disabled. Compared with the reference simulation, the no-AGN case exhibits less environmental dependence of the gas phase metallicity for central galaxies at z = 0, while the dependence at high z is unchanged. This result indicates that AGN feedback does play a role in amplifying the MZR difference for central galaxies with different halo mass at low z. And its impact becomes negligible at high z.

Satellite galaxies
Compared with central galaxies, satellite galaxies are also subject to various environmental effects. First of all, when a galaxy falls into other massive halos and be-comes a satellite galaxy, its accretion of dark matter and baryons is reduced, or even terminated (e.g. Behroozi et al. 2014), and its ambient gas, i.e. the circum-galactic medium (CGM), can be stripped, so that its ISM replenishment is blocked. Without the dilution from the accreting gas, the gas-phase metallicity increases persistently during the star-forming phase, until the cold gas content is consumed and the galaxy is quenched. This effect is called strangulation (e.g. Larson et al. 1980;Peng et al. 2015). In addition, satellite galaxies also suffer from the ram-pressure stripping effect which can strip the ISM content out of these satellite galaxies when they are moving in the hot intra-group/cluster medium of host halos (e.g. Gunn & Gott 1972;Vulcani et al. 2010Vulcani et al. , 2016Poggianti et al. 2017). This effect preferentially affect the gas on the outskirt of satellite galaxies   Figure 3, except for satellite galaxies. Satellite galaxies in more massive halos have less ISM due to strangulation and stripping, and consequently, their SSFR is decreased. Meanwhile, there is no halo mass dependence of black hole mass for satellite galaxies.
since it is relatively loosely bound compared with those in the galaxy center (e.g. Boselli et al. 2022). Bahé et al. (2017) studied the environmental dependence of the gasphase metallicity for satellite galaxies at z = 0 in the EAGLE simulation, and they identified that both the stripping of low-metallicity gas on the satellite outskirt and the lack of low-metallicity gas replenishment into the galaxy center through accretion are the key drivers of the metallicity enhancement in satellite galaxies. Figure 2 shows that satellite galaxies in massive halos are more metal-rich than those in low-mass halos by 0.2 dex, indicating that those environmental effects are already operating on satellite galaxies from z ∼ 2.3. Figure 4 shows the ISM content, SSFR and black hole mass for satellite galaxies as a function of stellar mass in different mass of host halos. The ISM content is mostly stripped for satellite galaxies in massive halos, and SSFR is also reduced. These results are consistent with the two drivers identified in Bahé et al. (2017), which can reduce the ISM content and diminish SSFR simultaneously. Finally, the black hole mass for satellite galaxies has no dependence on the host halo mass when the stellar mass is fixed, as shown in the bottom panels of Figure 4, indicating that AGN feedback is not important in setting the environmental dependence of MZR for satellite galaxies. Wang et al. (2022a) found that massive galaxies in protocluster region are more metal-poor than those in the field region. And the trend is reversed for low-mass galaxies, where those in protoclusters are more metalrich. Here we want to see whether the EAGLE simulation can produce similar results. To this end, we trace each galaxy at z ∼ 2.3 to z = 0 and define the host halo mass there as the descendant halo mass, which is denoted as M 0 . Then, we can study the dependence of gas-phase metallicity on M 0 . Satellite Figure 5. The residual MZR for galaxies at z ∼ 2.3 with descendant halo mass, i.e. log(M0/M ), in bins of [11,12), [12, 13), and [13, 15), and they are shown in blue, green, and red colors, respectively. The difference between filled and open symbols are similar to Figure 2, except here we are binning in descendant halo mass instead of halo mass. Central galaxies in protoclusters (high M0) have lower metallicity and dominate the high-M * end, while satellite galaxies in protoclusters have higher metallicity and dominate the low-M * end. Figure 5 shows the gas-phase metallicity as a function of stellar mass for galaxies at z ∼ 2.3 in different descendant halo mass bins. As one can see here, EAGLE predicts a similar environmental dependence of MZR to the result reported in Wang et al. (2022a), where massive galaxies are more metal-rich in the field (low M 0 ) and low-mass galaxies are more metal-rich in protoclusters (high M 0 ). By separating the contribution from central and satellite galaxies, one can see that central galaxies with high M 0 are more metal-poor, which dominates the massive end, while satellite galaxies with high M 0 are more metal-rich, which dominates the low-mass end. Figure 6 shows that central galaxies end up in massive halos (high M 0 ) prefer to live in massive halos at high z and possess more abundant ISM. This is consistent with the picture presented in § 3.2.1, where galaxies in more massive halos can accumulate more abundant gas through cold-mode accretion which can effectively dilute the gas-phase metallicity. Figure 7 shows that satellite galaxies end up in massive halos (high M 0 ) prefer to be satellite galaxies of massive halos at high z, and, consequently, their ISM is reduced more by various environmental effects. These results are consistent with our analysis in § 3.2.2.

SUMMARY
Gas-phase metallicity is an important probe for a variety of astrophysical processes in galaxy formation and evolution. Here we use the state-of-the-art hydrodynamical simulations to investigate the environmental dependence of gas-phase metallicity for central and satellite galaxies separately, as well as their physical origins. Our main results are summarized as follows.
1. From z ∼ 0 to z ∼ 2.3, massive galaxies in lowmass halos are more metal-rich than their counterparts in massive halos. For low-mass galaxies, the trend reverses, where those in more massive halos are more metal-rich. By separating the contribution from central and satellite galaxies, we find that the environmental dependence at the massive end is dominated by central galaxies, while satellite galaxies dominate the trend at the low-mass end (see Figure 2 and Figure 9).
2. We found that, at high z, central galaxies in massive halos tend to have more ISM than those in low-mass ones with stellar mass fixed. The difference in the ISM fraction is presumably responsible for the halo mass dependence of central galaxy metallicity. At low z, the AGN feedback process also helps to decrease the metallicity of central galaxies in massive halos by ejecting metal-rich gas (see Figure 3 and Figure 11).
3. For satellite galaxies, the strangulation effect and the striping of ISM is responsible for the metallicity difference in satellite galaxies in different host halo mass bins, which is consistent with previous studies. Moreover, we did not see any difference in their black hole mass, indicating that the AGN feedback effect is not important here (see Figure 4).
4. We also studied the dependence of gas-phase metallicity for high-z galaxies on their descendant halo mass, M 0 . We found that massive galaxies in protoclusters (high M 0 ) are more metal-poor than those in the field (low M 0 ). And low-mass galaxies exhibit a reversed trend, where those in protoclus-  [11,12), [12, 13), and [13, 15), and they are shown in blue, green, and red colors, respectively. The difference between filled and open symbols are similar to Figure 3, except here we are binning in descendant halo mass instead of halo mass. Central galaxies in protoclusters (high M0) tend to live in more massive halos and possess more abundant ISM than those in the field (low M0).
ters are more metal-rich. This result qualitatively agrees with the observational results in Wang et al.
5. The M 0 -dependence of gas-phase metallicity for high-z galaxies is a combined effect of central and satellite galaxies. The massive and low-mass ends are dominated by central and satellite galaxies, respectively. Meanwhile, central galaxies in protoclusters prefer to live in more massive halos and possess more ISM than their counterparts in the field. Satellite galaxies in protoclusters prefer to live in more massive halos so that they suffer more from environmental effects (see Figure 6 and Figure 7).  Figure 6, except for satellite galaxies. Satellite galaxies in protoclusters (high M0) prefer to live in more massive halos and have lower ISM content than those in the field (low M0).
In this work, we investigated the environmental dependence of gas-phase metallicity on the host halo mass for central and satellite galaxies using the hydrodynamical simulations of EAGLE and IllustrisTNG. We also found that the environmental dependence of gas-phase metallicity at high z can be qualitatively explain by both simulations.
Both simulations also predict that the scatter in the stellar mass-halo mass relation correlates with the gasphase metallicity, in the sense that galaxies in more massive halos are more metal-poor (see Wang et al. 2023;Cui et al. 2021;Zhang et al. 2022b, for correlation with other galaxy properties). This prediction can be tested in our local Universe and high z using the galaxy group catalog (Yang et al. 2008;Wang et al. 2020a;Yang et al. 2021;Li et al. 2022a). Besides, the observational measurements of the gas-phase metallicity difference between protocluster and field galaxies can be further improved with the coming high-z spectroscopic galaxy surveys (Takada et al. 2014;Maiolino et al. 2020;Wang et al. 2021).
Finally, it is noteworthy that the currently available sample of metallicity measurements in over-dense regions still suffers from the small number statistics which precludes a more quantitative comparison with our theoretical investigation presented here. With more observational results to be obtained from the ongoing MAMMOTH-Grism survey (HST-GO-16276, P. I. Wang), we can derive a more robust scaling relation of metallicity offset versus overdensity, in order to compare with our theoretical models in a more meaningful way.  Figure 8 shows the residual MZR in different halo mass bins at three redshift snapshots for total, central, and satellite galaxies, respectively. Here we adopted finer halo mass bins with a width of 0.3 dex, where one can still see the trends shown in Figure 2.

B. THE ENVIRONMENTAL DEPENDENCE OF MZR IN ILLUSTRISTNG
Here we use the TNG100 cosmological megneto-hydrodynamical simulation of the Illustris TNG project (Weinberger et al. 2017;Pillepich et al. 2018a,b;Marinacci et al. 2018;Nelson et al. 2018;Springel et al. 2018;Naiman et al. 2018). It simulates galaxy formation and evolution in a box with a side length of 100cMpc with 1820 3 dark matter particles and 1820 3 baryonic particles. Each dark matter particle weighs ∼ 7.5 × 10 6 M and each baryonic particle weighs ∼ 1.4 × 10 6 M .
Dark matter halos are identified with the FoF algorithm Subhalos and galaxies are identified with the SUBFIND algorithm. In each FoF halo, the subhalo with the lowest gravitational potential is defined as the central subhalo and the galaxy in it is defined as the central galaxy, while others are satellite galaxies. Stellar mass is defined as the total mass of star particles within twice the half stellar mass radius, R * , where R * is the radius that enclosed half of the stellar mass in each subhalo. The gas phase metallicity is defined as the abundance ratio between oxygen and hydrogen for all gas particles within 2R * .
The top panels in Figure 9 show the gas phase metallicity difference for galaxies with different host halos, while the middle and bottom panels show the results for central and satellite galaxies separately. Central galaxies in massive halos are more metal-poor than those in low-mass halos. On the contrary, satellite galaxies in massive halos are more metal-rich than those in low-mass ones. Despite different subgrid recipes adopted in TNG and EAGLE, the environmental dependence of the gas phase metallicity agree with each other quite well. Finally, Figure 10 shows the gas-phase metallicity as a function of stellar mass for galaxies with different descendant halo mass, M 0 . Again, these results agree with those obtained in the EAGLE simulation quite well.
C. MZR FOR CENTRAL GALAXIES WITHOUT AGN FEEDBACK Figure 11 shows the MZR difference of central galaxies in halos with different mass for the reference EAGLE simulation and the one with AGN feedback disabled. Here one can see that the gas phase metallicity difference for central galaxies in different mass of halos is reduced when the AGN feedback is disabled, especially for massive galaxies at low z. Meanwhile, the MZR difference at high z is not affected.