27 the nonlinear regime, the system is expected to achieve a statistical equilibrium state due to violent relaxation or collisional relaxation (finite N effects) [67]. This cor- responds to the inhomogeneous phase. In d = 1, there exists an equilibrium state for any value of energy and temperature. For low energies and temperatures, it is spatially inhomogeneous. In the core of the cluster, the density is so high that we can disregard the effect of the neutralizing background. In that case, the statistical equilibrium state (representing a “galaxy”) is described by the Camm solution like in 1D stellar dynamics. In d = 3, there is no inhomogeneous equilibrium state and, for sufficiently small energies and temperatures, the sys- tem undergoes a gravothermal catastrophe or an isother- mal collapse. In d = 2, the situation is intermediate. There exists an equilibrium state in the microcanonical ensemble for all energies while in the canonical ensemble no equilibrium state exists at low temperatures. Similar behaviours occur in chemotaxis and will be investigated in future papers. Note that for self-gravitating systems, the proper statistical ensemble is the microcanonical en- semble while in chemotaxis (or for the academic model of self-gravitating Brownian particles) the proper statistical ensemble is the canonical one. It is therefore interesting to study these two systems in parallel to describe the analogies and differences between statistical ensembles. mean field Kramers equation (21), with respect to the Smoluchowski equation (28), with respect to the Keller- Segel model (31) and with respect to the kinetic equation (13). We can now determine the values of the normalized inverse temperature η ∗ c and normalized energy Λ ∗ c above which the homogeneous phase becomes unstable. Using Eqs. (51) and (110), we get We obtain The corresponding critical energy is given by Eq. (63) for the modified Newtonian model and by (87) for the screened Newtonian model. η ∗ c = 1 d ( k 2 f + k 2 $_{0}$) R $^{2}$. (130) η ∗ c = π 2 + µ 2 = 9 . 8696044 + µ 2 ( d = 1) , (131) η ∗ c = 1 2 ( j 2 11 + µ $^{2}$) = 7 . 3410008 + µ 2 2 ( d = 2) , (132) η ∗ c = 1 3 ( x 2 1 + µ $^{2}$) = 6 . 7302445 + µ 2 3 ( d = 3) . (133) Appendix A: Equivalent but simpler optimization problems 1. Microcanonical ensemble VI. CONCLUSION In this Appendix, following the approach of Padman- abhan [22] and Chavanis [27], we shall reduce the op- timization problems (3) and (17) to simpler forms. In particular, we shall show that these optimization prob- lems for f ( r , v ) are equivalent to optimization problems for ρ ( r ). To solve the maximization problem (3) we can pro- ceed in two steps. We first maximize the entropy at fixed energy, mass and density profile ρ ( r ). Since the spec- ification of ρ ( r ) determines the mass and the potential energy, this is equivalent to maximizing the entropy at fixed kinetic energy and density profile. Writing In this paper, we have completed the description of phase transitions in self-gravitating systems and bacte- rial populations. We have introduced generalized models in which the ordinary Poisson equation is modified so as to allow for the existence of a spatially homogeneous phase. This avoids the Jeans swindle and leads to a great variety of microcanonical and canonical phase transitions between homogeneous and inhomogeneous states. These generalized models can have application in chemotaxis where the degradation of the chemical leads to a shield- ing of the interaction and in cosmology where the ex- pansion of the universe creates a sort of “neutralizing background”. In this paper, we have only considered equilibrium states. In future works, we shall study the dynamics of some simple models for which the present study can be a useful guide. Our study also allows to explore the link between cos- mology where one studies the evolution of the universe as a whole [12] and stellar dynamics where one studies the structure of individual galaxies [59]. The description of phase transitions in these two disciplines is usually very different [60]. However, our study allows to make some basic connections. In cosmology, one usually starts from an infinite homogeneous distribution and study the appearance of clusters representing galaxies. Our ther- modynamical approach shows that, indeed, the homo- geneous phase is unstable for sufficiently low tempera- tures and energies and leads to clusters. The formation of these clusters can be studied by making a linear sta- bility analysis of the Vlasov or Euler equations. Then, in which is the global entropy maximum with the previ- ous constraints since δ $^{2}$S = − ∫ ( δf ) 2 2 fm d r d v < 0 (the con- this leads to the Maxwellian distribution function δS − βδ (∫ f v 2 2 d r d v ) − ∫ λ ( r ) δ (∫ f d v ) d r = 0 , (A1) f ( r , v ) = ( m 2 πk$_{B}$T ) d/ 2 ρ ( r ) e − mv 2 2 k B T , (A2)