The aim here is to numerically solve the Friedmann equations in order to get the scale factor as a function of time for all possible geometries of the Universe. For this purpose, we model the contents of the Universe as a perfect fluid, i.e. a fluid with density $\rho$ and pressure $p$ as the only interesting properties (in terms of the dynamics of the Universe). In this case, the energy-momentum tensor has a simple form, and Einstein's equations reduce to a set of two differential equations (see \eqref{eq1} and \eqref{eq2} below) to compute $R(t)$ as a function of density $\rho$, "cosmic fluid’s" pressure $p$, curvature parameter $k$, and cosmological constant $\Lambda$.

Naturally, the density of matter in the Universe seems to be a crucial parameter in determining its evolution. Indeed, the evolution of the Universe is determined by its own weight : the higher the density, the greater the gravitational attraction it exerts on itself and the more its expansion must slow down.

A perfect fluid can generally be modelled as a state equation with pressure $p$ and energy density $\rho_{e}$; its common expression is $p=w\rho_{e}$ with $w$=0 for matter, $w=1/3$ for radiation and $w=-1$ for dark energy.

In Einstein's equations, the energy density $\rho_{e}$ appears under the form $\rho c^{2}$ (with density of component $\rho$ and speed of light $c$). With energy-momentum tensor modelled as a perfect fluid, one yields the fundamental equations of cosmology :

\begin{equation}
\dfrac{R^{''}}{R}=-\dfrac{4\pi G}{3}\big(\rho+\dfrac{3p}{c^{2}}\big)+\dfrac{\Lambda c^2}{3}
\label{eq1}
\end{equation}
and
\begin{equation}
\bigg(\dfrac{R^{'}}{R}\bigg)^{2}=\dfrac{8\pi G \rho}{3}+\dfrac{\Lambda c^2}{3}-\dfrac{k c^2}{R^{2}}
\label{eq2}
\end{equation}
Additionally, we can specify :
\begin{equation}
\dfrac{\text{d}(\rho c^{2} R^{3})}{\text{d}t}=-p\dfrac{\text{d}R^{3}}{\text{d}t}
\label{eq3}
\end{equation}

which can be derived from the first two. These "Friedmann equations" describe the general class of Friedmann-Lemaître models. They are the underlying equations of the big bang models whereby the structure of the Universe can be determined by its content.

The first of these equations yields the second derivative of the scale factor, which expresses acceleration or deceleration of expansion. Note that, even with the simplifying assumptions mentioned (homogeneity, perfect fluid), density and pressure are not sufficient to determine the geometry and dynamics of the Universe. The cosmological constant is required as well. Its impact on model outcomes will become apparent in the results below.

What we call matter in cosmology, as opposed to other forms of energy described below, is characterized by very low thermal agitation velocity ($v_{th} \ll c$) and negligible pressure ($p=\rho v_{th}^{2} \ll \rho c^{2}$). It is "cold" or "non-relativistic". Thus, we neglect the pressure term $p$ to the density term $\rho c^{2}$. The error is negligible. In other words, we apply the approximation $p=0$ to matter. Cold matter is diluted proportionally to $R^{-3}$ (cf \eqref{eq3}); we model density as :

Radiation consists of photons (or more generally, particles without mass), moving at the speed of light. Its very high pressure cannot be neglected, and the state equation can be written as $p=\rho c^{2}/3$. We know of three possible components: electromagnetic radiation (photons), gravitational waves and neutrinos, if these are massless (see here). The contribution of gravitational waves is currently negligible. The dynamic influence of electromagnetic radiation, omnipresent in the Universe, is currently low, but it was much higher at the beginning of cosmic history. This applies to (massless) neutrinos as well. One can demonstrate that radiation dilutes as :

It dilutes quicker than classical matter. We will see below the definition of parameter $\Omega_r^{0}$ which determines contribution of radiation into critical density.

Astronomers know the different forms of matter recorded, bright stars (made of hot gases), grouped in galaxies, gases, dusts, planets, etc. They count the number of galaxies in the Universe. They analyse mass $M$ and luminosity $L$, and establish an average value $< M/L >$ of mass to luminosity for each of these. The product of a galaxy’s luminosity and $< M/L >$ gives its mass. Finally, the mass density of matter is expressed as: $\rho_{galaxies}=N_{galaxies}$ < $M/L$ > <$L$> with $N_{galaxies}$ the number of galaxies into $dV$ volume. According to recent estimates, density $\rho_{galaxies}$ is equal roughly to $10^{-31}g.cm^{-3}$. This is the visible baryonic contribution to the density of the Universe.

Dynamic analyses of galaxies or clusters of galaxies are not consistent with these estimates. The simplest and most common interpretation of this discrepancy suggests that these objects contain more mass than we see: as well as visible mass, there may be large amounts of hidden (or invisible) mass also known as dark matter. Additional contributions of the dynamic mass of clusters are estimated as $\Omega^{0}_{m}=0.2-0.3$ (see below definition of $\Omega^{0}_{m}$). Another theory yields an estimate of the same order. It is based on the computation of primordial nucleosynthesis from big bang models: their results are only consistent with observations of light elements if the contribution $\Omega^{0}_{b}$ of baryons to $\Omega^{0}_{m}$ is approximately $0.01-0.05$.

Matter and radiation, these two forms of energy are the archetypes of the content of the Universe. However, a third form of energy with negative pressure has recently emerged in cosmology. According to quantum field theory, the ground state of a quantum field may have exerted a dynamic influence in cosmology. We call this "vacuum energy". Vacuum refers to the ground state relative to which we measure excitations of the fields. The theory suggests that the energy density of this state is $\rho_{vacuum}$, and it is as if we could also assign a negative pressure $p=-\rho_{vacuum}$ !

Note that the contribution of this vacuum energy is in some cases formally identical to that of a cosmological constant $\Lambda=8\pi G \rho_{vacuum}$. However, this only applies if vacuum energy is measured in Minkowski‘s space-time, without curvature or evolution. Clearly, this does not comply with cosmological conditions (eg vacuum energy is a priori variable during cosmic evolution whereas $\Lambda$ is strictly constant by definition).

This "parameter" or "Hubble constant" measures the current rate of expansion :
\begin{equation}
H_{0}=\bigg(\dfrac{R^{'}}{R}\bigg)_{0}
\label{eq6}
\end{equation}

The deceleration parameter is defined as follows:
\begin{equation}
q_{0}=-\bigg(\dfrac{R^{''}R}{(R^{'})^{2}}\bigg)_{0}
\label{eq7}
\end{equation}
It measures the acceleration or deceleration (negative value) of expansion. These quantities indexed by 0 refer to the present values.

We introduce the critical value of density :
\begin{equation}
\rho_{critical,0}=\dfrac{3 H_{0}^{2}}{8\pi G}
\label{eq8}
\end{equation}

Models of matter (with $\Lambda=0$) are classified into two categories depending on whether density is lower or higher than this value. The critical density value being a natural unity, the density parameter $\Omega^{0}_{m}$ is thus :

Taking $H_{0}=70\,km/s/Mpc$, density $\rho_{critical,0}$ is equal roughly to $10^{-29}g.cm^{-3}$, thus $\Omega^{0}_{m}=0.04$ or also $\sim 5 m_{p}/m^{3}$ ($m_{p}$ proton mass).

Radiation is defined by a similar parameter $\Omega^{0}_{r}$ :
\begin{equation}
\Omega^{0}_{r}=\dfrac{\rho_{r,0}}{\rho_{critical,0}}
\label{eq10}
\end{equation}

The value of $\Omega^{0}_{r}$ is currently of order $10^{-4}$.

We define also a "reduced" cosmological constant $\Omega^{0}_{\Lambda}$ :
\begin{equation}
\Omega^{0}_{\Lambda}=\dfrac{\Lambda c^2}{3 H_{0}^{2}}
\label{eq11}
\end{equation}

\eqref{eq1} and \eqref{eq2} involve the first and second derivative of the scale factor. The aim is to combine these two equations to obtain a second order differential equation in matrix form. We solve them using Matlab ODE. We introduce the normalized scale factor $y(t)=R(t)/R_{0}$. \eqref{eq1} can be written as :

Thus we derive the value of $\Omega^{0}_{k}$ as a function of $\Omega^{0}_{m}$, $\Omega^{0}_{\Lambda}$ and $\Omega^{0}_{r}$ (we take into account of $\Omega^{0}_{r}$ even if we are in matter area, see above).

The following equation is useful in understanding the results, especially those concerning the sign of the deceleration parameter $q_{0}$. Thus :

See below the graph created with the program (same $\Omega^{0}_{r}\simeq 10^{-4}$ is taken for the 4 curves). We can identify :

black curve corresponds to a spherical Universe ($k=1$). After an initial phase of expansion, the Universe contracts ("Collapse Model"): this is the "Big Crunch" scenario. Speculative cosmogonies refer to it a cyclical "expanding/collapsing" model called "Big Bounce".

magenta curve corresponds to a quasi-euclidean geometry ($\Omega^{0}_{k}\simeq 0$) with a zero cosmological constant. Density is exactly equal to the critical density : this is the Einstein - de Sitter model. Expansion is eternal while decelerating ($q_{0}=0.5$ see \eqref{eq18}).

blue curve displays a hyperbolic geometry ($k=-1$). Expansion is eternal, and its rate decreases in time ($q_{0}=0.15$).

red curve best matches current observations : this is the $\Lambda\text{CDM}$ model. $\Omega^{0}_{m}$ equals 0.3 and $\Omega^{0}_{\Lambda}$ equals 0.7, thus $q_{0}=-0.55$. According to \eqref{eq16}, we see that $\Omega^{0}_{k}\simeq 0$, therefore geometry is almost euclidean. Expansion accelerates indefinitely ($q_{0} < 0$) to a value such that astrophysical objects themselves are dislocated: this is the "Big Rip" scenario. We estimate the age of the Universe with this curve, starting from $y=0$ to $y=1$; we get a value of approximately 13 billion years.