1 Introduction

Inflation [1, 2] predicts that there is a stochastic gravitational waves (GW) background. Therefore, it’s possible to test inflation scenario experimentally through detection of such a GW background. So far, the B-mode polarization of the cosmic microwave background (CMB) is the most promising probe of this GW background [3,4,5]. In the future, 21cm HI emission from the dark ages will be a complementary and even more sensitive probe of this GW background [6, 7]. Furthermore, there are some not very competitive probes of this GW background, including weak lensing shear [8, 9] and other large-scale structure observables [10, 11]. The goal of this paper is to study the effect of gravitational waves on the inhomogeneity of the Universe with numerical relativity, thereby proposing a possible probe of a GW background.

Although cosmological principle points out that the Universe is homogeneous and isotropic on large scales and can be described by a Friedmann–Lemaitre–Robertson–Walker (FLRW) model, it is inhomogeneous and anisotropic on scales smaller than \(\sim 80\,h^{-1}\,\text {Mpc}\) [12, 13] today. These inhomogeneities can induce nonlinear general relativistic effects which may be detected by forthcoming cosmological surveys [14,15,16]. Moreover, these nonlinear general relativistic effects on small scales may be accompanied by unexpected nonperturbative behavior on larger scales. This “backreaction” is believed to be the reason of the recent cosmic expansion by [17,18,19,20,21,22,23,24]. We will, however, use a restricted simulation setup by using a fixed FLRW background and subjecting perturbations to periodic boundary conditions, which suppresses the large-scale backreaction effect on the global evolution of the background spacetime [25].

Usually, the linear perturbation theory of General Relativity (GR) is used on large scales and Newtonian N-body simulations (or Newtonian gravity) provide a very good approximation on small scales. To study the nonlinear general relativistic effects, one can do general relativistic N-body simulations as [26]. Undoubtedly, the direct numerical integration of Einstein’s equation is the only way without any systematic errors and approximation to study the Universe on all scales. The first cosmological work that is fully non-linear, fully relativistic and does not impose symmetries or dimensional-reductions has been done by [27, 28] using C osmo GR a PH. For cosmological purpose, soon afterward, [29] turned to the wide-used Einstein Toolkit [30] to integrate Einstein’s equation. Macpherson et al. [31] also studied the inhomogeneous cosmology with Einstein Toolkit by developing a new thorn, FLRWSolver.

Here, our work is based on: a new thorn CFLRWSolver (a C language counterpart of FLRWSolver) which takes the tensor perturbation into consideration and initializes an almost FLRW Universe with scalar and tensor perturbations; a self-developing thorn CFLRWAnalysis which calculates several derived variables including the comoving time, scale factor, the tensor component of perturbation and the distribution of overdensity at the end of each evolution step; the thorn McLachlan [32,33,34] which evolves spacetime using the Baumgarte–Shapiro–Shibata–Nakamura (BSSN) formalism [35,36,37] and the thorn GRHydro which evolves the hydrodynamical system [38,39,40].

This paper is organized as follows. In Sect. 2, we give the evolution equations of the FLRW background spacetime and scalar and tensor perturbations through solving the zero-order and first-order of Einstein equations and solutions to them. In Sect. 3, we give the initial conditions of the system with small perturbations needed by the thorn CFLRWSolver. In Sect. 4, we analyse the results of simulations provided by the thorn CFLRWAnalysis. At last, a brief summary and discussion are included in Sect. 5.

In this paper, we adopt the following conventions: Greek indices run in {0, 1, 2, 3}, Latin indices run in {1, 2, 3} and repeated indices implies summation and we are in a geometric unit system with \(G=c=1\).

2 Cosmological perturbations

For a spatially flat FLRW background spacetime, the line element is

$$\begin{aligned} ds^2=a^2(\eta )\left[ -d\eta ^2+\delta _{ij}dx^idx^j\right] , \end{aligned}$$
(1)

where \(\eta \) is the conformal time, a is the scale factor and \(\delta _{ij}\) is the identity matrix. In the conformal Newtonian gauge, the line element that includes both the scalar and tensor perturbations to the metric is

$$\begin{aligned} ds^2= & {} a^2(\eta )\left[ -(1+2\Psi )d\eta ^2+(1-2\Phi )\delta _{ij}dx^idx^j\right. \nonumber \\&\left. + h_{ij}dx^idx^j\right] , \end{aligned}$$
(2)

where \(\Psi \) is the Newtonian potential, \(\Phi \) the spatial curvature perturbation and \(h_{ij}\) is a divergenceless, traceless and symmetric tensor. And for a perfect fluid without the anisotropic stress tensor, its energy–momentum tensor with density \(\rho =\rho _0+\rho _1\), isotropic pressure \(P=P_0+P_1\) and 4-velocity \(u^\mu =a^{-1}[1-\Psi ,v^1_1,v^2_1,v^3_1]\) is

$$\begin{aligned} T_{\mu \nu }=(\rho +P)u_\mu u_\nu +Pg_{\mu \nu }. \end{aligned}$$
(3)

The Einstein equations relate the spacetime curvature to the energy–momentum tensor as

$$\begin{aligned} G_{\mu \nu }=8\pi T_{\mu \nu }. \end{aligned}$$
(4)

The zero-order Einstein equations give the Friedmann constraint and evolution equation for the FLRW background spacetime

$$\begin{aligned} {\mathcal {H}}^2= & {} \frac{8\pi }{3}a^2\rho _0, \nonumber \\ {\mathcal {H}}'= & {} -\frac{4\pi }{3}a^2(\rho _0+3P_0), \end{aligned}$$
(5)

where a prime represents a derivative with respect to the conformal time. According to [31], the dust (\(P\ll \rho \)) solution to (5) is

$$\begin{aligned} a= & {} a_{\mathrm {init}}\xi ^2, \nonumber \\ \rho _0= & {} \rho _{0,\mathrm {init}}\xi ^{-6}, \nonumber \\ \xi= & {} 1+\sqrt{\frac{2\pi \rho _0*}{3a_{\mathrm {init}}}}\eta , \end{aligned}$$
(6)

where \(a_{\mathrm {init}}\) and \(\rho _{0,\mathrm {init}}\) are the values of a and \(\rho _0\) at \(\eta =0\) respectively, \(\xi \) is the scaled conformal time and \(\rho _0*=\rho _0 a^3\) is the conserved comoving density.

From the first-order perturbed Einstein equations, we derive equations describing scalar metric perturbations as [31, 41]

$$\begin{aligned} \nabla ^2\Phi -3{\mathcal {H}}(\Phi '+{\mathcal {H}}\Psi )= & {} 4\pi a^2 \rho _1, \nonumber \\ {\mathcal {H}}\partial _i\Psi +\partial _i\Phi '= & {} -4\pi a^2(\rho _0+P_0)\delta _{ij}v^j_1, \nonumber \\ \Phi= & {} \Psi , \nonumber \\ \Phi ''+3{\mathcal {H}}\Phi '+(2{\mathcal {H}}'+{\mathcal {H}}^2)\Phi= & {} 4\pi a^2P_1. \end{aligned}$$
(7)

[31] also gives the dust (\(P\ll \rho \)) solution to (7) for the growing mode as

$$\begin{aligned} \Phi= & {} f(x^i), \nonumber \\ \frac{\rho _1}{\rho _0}= & {} C_1\xi ^2\nabla ^2f(x^i)-2f(x^i), \nonumber \\ v_1^i= & {} C_2\xi \partial ^if(x^i), \end{aligned}$$
(8)

where \(f(x^i)\) is an arbitrary function of space, \(C_1=\frac{a_{\mathrm {init}}}{4\pi \rho _0*}\) and \(C_2=-\sqrt{\frac{a_{\mathrm {init}}}{6\pi \rho _0*}}\).

From the spatial part of the first-order perturbed Einstein equations, we have a wave equation

$$\begin{aligned} h_{ij}''+2{\mathcal {H}}h_{ij}'-\nabla ^2h_{ij}=0. \end{aligned}$$
(9)

One can expand the tensor perturbation in plane waves

$$\begin{aligned} h_{ij}(\vec {x},\eta )=\int \frac{d^3k}{(2\pi )^3}h^{s}_k(\eta ) \varepsilon ^s_{ij}e^{i\vec {k}\cdot \vec {x}}, \end{aligned}$$
(10)

where \(\varepsilon ^s_{ij}\) with \(s=\times ,+\) are transverse and traceless polarization tensors and each of \(h^{s}_k(\eta )\) evolves independently and satisfies

$$\begin{aligned} {h^s_k}''+2{\mathcal {H}}{h^s_k}'+k^2h^s_k=0. \end{aligned}$$
(11)

According to [42], for modes inside the horizon during matter dominated era, the exact solution is

$$\begin{aligned}&h_{k}^s(\eta +\eta _0) \nonumber \\&\qquad =3h_{k}^s(0)\frac{\sin [k(\eta {+}\eta _0)]- [k(\eta {+}\eta _0)]\cos [k(\eta {+}\eta _0)]}{[k(\eta {+}\eta _0)]^3},\nonumber \\ \end{aligned}$$
(12)

where \(\eta +\eta _0\) is the comoving size of horizon.

3 Initial conditions

To integrate Einstein equations, Einstein Toolkit turns to the metric in the form of \((3+1)\) formalism

$$\begin{aligned} ds^2=-\alpha ^2dt^2+\gamma _{ij}(dx^i+\beta ^idt)(dx^j+\beta ^jdt), \end{aligned}$$
(13)

where \(\alpha \) is the lapse function, \(\beta ^i\) is the shift vector and \(\gamma _{ij}\) is the spatial metric and evolves depending on the extrinsic curvature \(K_{ij}\) as

$$\begin{aligned} (\partial _t-{\mathcal {L}}_{\mathbf {\beta }})\gamma _{ij}=-2\alpha K_{ij}. \end{aligned}$$
(14)

Now we will use CFLRWSolver to initialize an almost FLRW Universe with small perturbations. First, we should relate the groups of gird function for basic spacetime variables in the thorn ADMBase to the variables in (2):

$$\begin{aligned} \gamma _{ij}= & {} a^2[(1-2\Phi )\delta _{ij}+h_{ij}], \nonumber \\ K_{ij}= & {} \frac{2a'[(1-2\Phi )\delta _{ij}+h_{ij}]-2a\Phi ' \delta _{ij}+ah_{ij}'}{-2\sqrt{1+2\Psi }}. \end{aligned}$$
(15)

where we have set \(dt=\frac{a\sqrt{1+2\Psi }}{\alpha } d\eta \) and \(\beta ^i=0\). Here we choose the harmonic slicing

$$\begin{aligned} \partial _t\alpha =-\frac{1}{4}\alpha ^2K, \end{aligned}$$
(16)

which describes the evolution of \(\alpha \). Since K is negative in our simulation, this choice of foliation will be with high computational efficiency. Then, we relate the basic variables and grid functions for hydrodynamics evolutions in the thorn HydroBase to the variables in (3):

$$\begin{aligned} \rho= & {} \rho _0+\rho _1, \nonumber \\ P= & {} P_0+P_1, \nonumber \\ v^i= & {} \frac{v_1^i}{a}, \nonumber \\ \Gamma= & {} \left( 1-\gamma _{ij}\frac{v_1^i}{a} \frac{v_1^j}{a}\right) ^{-\frac{1}{2}}. \end{aligned}$$
(17)

According to (6), (8) and (12), we set the initial conditions for a dust system with periodic boundary conditions at \(t=\eta =0\) as

$$\begin{aligned} \Phi= & {} \Phi _0\sum _{i=1}^3\sin \left( \frac{2\pi x^i}{l}\right) , \alpha =\sqrt{1+2\Phi }, \nonumber \\ h_{ij}= & {} 3h_{\frac{2\pi }{L}}^{s}(0)\frac{L^3\sin (\frac{2\pi \eta _0}{L})-2\pi L^2\eta _0\cos (\frac{2\pi \eta _0}{L})}{(2\pi \eta _0)^3}\cos \left[ \frac{2\pi (z+125)}{L}\right] \varepsilon ^{s}_{ij}, \nonumber \\ h_{ij}'= & {} 3h_{\frac{2\pi }{L}}^{s}(0)\frac{[(2\pi \eta _0)^4 L^2{-}3(2\pi \eta _0)^2L^4]\sin (\frac{2\pi \eta _0}{L}){+}3(2\pi \eta _0L)^3 \cos (\frac{2\pi \eta _0}{L})}{(2\pi \eta _0)^6} \nonumber \\&\frac{2\pi }{L}\cos \left[ \frac{2\pi (z+125)}{L}\right] \varepsilon ^{s}_{ij}, \nonumber \\ \gamma _{ij}= & {} a_{\mathrm {init}}^2(\delta _{ij}-2\Phi \delta _{ij}+h_{ij}), \nonumber \\ K_{ij}= & {} \frac{\sqrt{\frac{32\pi \rho _{0,\mathrm {init}}}{3}} a_{\mathrm {init}}^2(\delta _{ij}-2\Phi \delta _{ij}+h_{ij})+ a_{\mathrm {init}}h_{ij}'}{-2\alpha }, \nonumber \\ \rho= & {} \rho _{0,\mathrm {init}}-\rho _{0,\mathrm {init}} \left[ \left( \frac{2\pi }{l}\right) ^2C_1+2\right] \Phi , \nonumber \\ v^i= & {} \frac{1}{a_{\mathrm {init}}}\frac{2\pi }{l}C_2\Phi _0\cos \left( \frac{2\pi x^i}{l}\right) , \nonumber \\ \Gamma= & {} \left( 1-\gamma _{ij}v^iv^j\right) ^{-\frac{1}{2}}, \end{aligned}$$
(18)

where \(l=500\) is the half length of one side of our simulation box with \(x^i\) in \([-375, 625]\), \(\Phi _0\) is the amplitude of spatial curvature perturbation and \(h_{\frac{2\pi }{L}}^{s}(0)\) is the amplitude of monochromatic primordial tensor perturbation with wave number \(k=\frac{2\pi }{L}\) before horizon-crossing. For simplicity, we set the initial scale factor \(a_{\mathrm {init}}=1\). And we set \(L<4000\) and \(\rho _{0,\mathrm {init}}=10^{-6}\) so that \(\frac{2\pi \eta _0}{L}>1\) which implies the tensor perturbation has crossed inside the horizon \(\eta _0\simeq 2\sqrt{\frac{3}{8\pi \rho _{0,\mathrm {init}}}}\) at the beginning of simulation. To keep the linear approximation remains valid and save the computational time as much as possible, we set \(\Phi _0=10^{-4}\) which means the density contrast is about \(10^{-3}\). Here we will run three simulations at resolution \(100^3\) with \(h_{\frac{2\pi }{L}}^{s}(0)=0\), \(h_{\frac{2\pi }{500}}^{+}(0)=10^{-3}\) and \(h_{\frac{2\pi }{500}}^{\times }(0)=10^{-3}\) to study the effect of tensor perturbation on the inhomogeneity of universe.

4 Results

We can analyse the effect of tensor perturbation by comparing the outputs of several variables in the CFLRWAnalysis derived from the basic ones in the ADMBase and HydroBase from those simulations performed above directly. Firstly, the relation \(dt=\frac{a\sqrt{1+2\Psi }}{\alpha } d\eta \) gives

$$\begin{aligned} \xi (t)=\left( \sqrt{\frac{6\pi \rho _{0,\mathrm {init}}}{1+2\Phi }} \int \alpha (t)dt+1\right) ^{1/3}, \end{aligned}$$
(19)

from which we can use (6) to obtain the evolution of a and \(\rho _0\) with the comoving time \(\eta \) , hence the evolution of \(h^{\times }(\eta _0+\eta )\)

$$\begin{aligned} h^{\times }(\eta _0+\eta )=\frac{\gamma _{12}(\eta )}{a^2(\eta )}, \end{aligned}$$
(20)

and \(\frac{\rho _1}{\rho _0}(\eta )\)

$$\begin{aligned} \frac{\rho _1}{\rho _0}(\eta )=\frac{(\rho _1+\rho _0)(\eta )- \rho _0(\eta )}{\rho _0(\eta )}, \end{aligned}$$
(21)

where \(\gamma _{12}(t)\) and \((\rho _1+\rho _0)(t)\) are basic variables in ADMBase and HydroBase. Since the background quantities including a, \(\rho _0\) and \(\eta \) are slightly space-dependent in an inhomogeneous spacetime, especially in the nonlinear region in a dynamical gauge like (16), here these quantities are the average ones taken across the simulation box, which will introduce an element of inaccuracy and gauge dependence.

Figure 1 shows the evolution of \(\frac{h^{\times }(\eta _0+\eta )}{h^{\times }(0)}\) at the point (0, 0, 375)Footnote 1 of our cubic domain in two simulations with \(h_{\frac{2\pi }{L}}^{s}(0)=0\) (red solid curve) and \(h_{\frac{2\pi }{500}}^{\times }(0)=10^{-3}\) (black solid curve). We can see that the scalar perturbations can produce the tensor perturbations due to the nonlinear effects (red solid curve) as pointed by [43], and the evolution of primordial tensor perturbation (black solid curve) follows the exact solution \(\frac{j_1[k(\eta _0+\eta )]}{k(\eta _0+\eta )}\) (green solid curve), where \(j_1(z)=\frac{\sin z-z\cos z}{z^2}\) is the spherical Bessel functions of order one.

Fig. 1
figure 1

The evolution of \(\frac{h^{\times }(\eta _0+\eta )}{h^{\times }(0)}\) at the point (0, 0, 375) of our simulation box (black and red solid curves)

Fig. 2
figure 2

The evolution of \(\frac{\rho _1}{\rho _0}\) at the point (375, 375, 375) of our simulation box without primordial tensor perturbations (left), and the primordial tensor perturbation’s contribution to \(\frac{\rho _1}{\rho _0}\) at the point (375, 375, 375) (right)

Figure 2 shows the evolution of \(\frac{\rho _1}{\rho _0}\) at the point \((375,375,375)\) of our simulation box without primordial tensor perturbations (left), and the primordial tensor perturbation’s contribution to \(\frac{\rho _1}{\rho _0}\) at the point (375, 375, 375) (right). We can see that the simulation result (black solid curve) deviates from the linear analytic solution (red solid curve) due to the nonlinear effects. Moreover, even though the primordial tensor perturbation die off quickly after the horizon-crossing as shown in Fig. 1, their contribution to \(\frac{\rho _1}{\rho _0}\) grow up quickly in nonlinear regions.

Figure 3 shows the distribution of \(\frac{\rho _1}{\rho _0}\) on the x–y plane of \(z=375\) at the beginning \((\eta =0)\) and end \((\eta =12000)\) of simulation without primordial tensor perturbations. We can see that the locations of the maximum of \(\frac{\rho _1}{\rho _0}\) are fixed at points \((-125,-125,375)\), \((375,-125,375)\), (375, 375, 375) and \((-125,375,375)\). That is to say there is almost no interaction between the perturbation peaks. The left one of Fig. 4 shows the contribution of primordial tensor perturbation with just \(h^{\times }\) component to \(\frac{\rho _1}{\rho _0}\), while the right one shows the contribution from primordial tensor perturbation with only \(h^{+}\) at the end of our simulation. We can see that the contributions of both cases are too small to modify the right one of Fig. 3. However, primordial tensor perturbation with different component do leave a characteristic imprint on the distribution of \(\frac{\rho _1}{\rho _0}\): the tensor perturbation with \(h^{\times }\) enhances the overdensity; the tensor perturbation with \(h^{+}\) enhances the overdensity alone the lines \((-125,y,375)\) and (375, y, 375) but suppresses the overdensity alone the lines \((x,-125,375)\) and (x, 375, 375).

Fig. 3
figure 3

The distribution of \(\frac{\rho _1}{\rho _0}\) on the x–y plane of \(z=375\) at the beginning and end of simulation without primordial tensor perturbations

Fig. 4
figure 4

The final contribution of primordial tensor perturbation with just \(h^{\times }\) component (left) or \(h^{+}\) component (right) to \(\frac{\rho _1}{\rho _0}\)

5 Summary and discussion

We have performed three simulations using Einstein Toolkit in this paper: The first one gives the evolution of overdensity \(\frac{\rho _1}{\rho _0}\) in a spatially flat FLRW background spacetime with a spatial curvature perturbation; In the next two, we added an evolving primordial tensor perturbation with just \(h^{\times }\) or \(h^{+}\) component to the spacetime and find that these two components leave a characteristic imprint on the distribution of the fractional density perturbation in the nonlinear region. More precisely: The primordial tensor modes do decay rapidly and never leave the linear regime as shown in Fig. 1. Before they die out, however, they have modified the profile of overdensity slightly, and the modification is amplified with time as shown in the right one of Fig. 2. The Fig. 4 shows the final modification in the nonlinear region, so the FIG.4 can only be produced by the nonlinear numerical relativity code which is a necessary here.

These imprints may be a possible probe of a GW background in the future. We do try to suggest exactly how or how much these tenor modes may affect observables including 2D angular power spectrum of large-scale structure tracers (as Fabian Schmidt et al. proposed [10, 11], but unfortunately here we just study the scalar modes with wave length \(l=500\) and there is no suitable primordial power spectrum on hand.

And it’s worth pointing out that much of the infrastructure for our work was developed and the development of tensor perturbations from scalar perturbations was already demonstrated in the MacPherson et al. paper [31]. For simplicity and correctness, our work takes advantage of their configuration for simulation directly. That is to say their work serves as an important tool for our work. On the other hand our work also goes beyond their work: (a) additional primordial tensor modes have been added to the initial conditions and their evolution has been shown in Fig. 1. (b) Their contribution to the evolution of overdensity has been shown in the right one of Fig. 2. (c) Their final imprint on the distribution of the fractional density perturbation in the nonlinear region also has been given in Fig. 4.