Introduction
Numerical tools have become an essential component in the study of cosmological perturbations and the interpretation of large-scale structure observations. Einstein–Boltzmann solvers such as CLASS [1 ] and CAMB [2 ] provide accurate predictions for the evolution of linear perturbations and the corresponding cosmological observables in the standard cosmological framework. Extensions such as hi_class [3 , 4 ] , mochi_class [5 ] , and EFTCAMB [6 ] have generalised this framework to scalar–tensor theories by incorporating Horndeski gravity [7 ] , allowing the evolution of the background and linear perturbations to be computed for a broad range of dark-energy and modified-gravity models. In particular, hi_class provides two complementary descriptions of Horndeski theories: one based on the α \alpha α functions introduced within the effective field theory description of dark energy [8 ] and another based on the underlying covariant Lagrangian [4 ] . This has made it possible to confront a wide range of scalar–tensor theories with cosmological data.
While linear Einstein–Boltzmann calculations provide accurate predictions for a wide range of cosmological observables, current and forthcoming large-scale structure surveys, such as Euclid and DESI [9 , 10 ] , motivate the development of accurate predictions beyond the linear regime. In modified gravity theories, this requires numerical frameworks capable of following the coupled evolution of matter, metric perturbations, and additional degrees of freedom on nonlinear scales [11 ] . Relativistic N N N -body simulations provide such a framework by extending conventional structure formation simulations with a consistent treatment of relativistic gravitational effects. The gevolution code [12 , 13 , 14 ] incorporates relativistic metric perturbations within a weak-field formulation of general relativity and provides a relativistic description of cosmological structure formation.
A number of N N N -body frameworks have been developed to study nonlinear structure formation in modified-gravity and scalar–tensor theories, including recent implementations based on the effective field theory of dark energy and Galileon-type models [15 , 16 ] . Building upon the relativistic gevolution framework, several extensions have incorporated additional scalar-field dynamics, including k k k -essence in k k k -evolution [17 , 18 ] and scalar-field domain formation and associated relativistic signatures of the (a)symmetron model in Asimulation [19 , 20 , 21 ] . More recently, we extended this framework in KGB-evolution to kinetic gravity braiding (KGB) models, incorporating the braiding interaction into the relativistic simulation framework and studying its signatures in nonlinear structure formation and relativistic observables [22 , 23 ] . The progression from k k k -evolution to KGB-evolution established the numerical workflow that we generalise here towards a broader treatment of Horndeski gravity.
In this work, we introduce Mercury, extending the KGB-evolution code to the general linear Horndeski α-basis. The code incorporates the Horndeski background and perturbation dynamics, with the linear perturbation sector described by the time-dependent α \alpha α functions α K \alpha_{\mathrm{K}} α K , α B \alpha_{\mathrm{B}} α B , α M \alpha_{\mathrm{M}} α M and α T \alpha_{\mathrm{T}} α T , together with the evolution of the effective Planck mass M ∗ 2 M_*^2 M ∗ 2 . The corresponding scalar contribution is implemented as an effective stress–energy tensor source on the simulation lattice, while the evolution of the effective Planck mass is consistently incorporated into the gravitational sector. Following the approach adopted in KGB-evolution, the additional scalar degree of freedom is evolved using the linear Horndeski equations while remaining consistently coupled to the nonlinear matter and metric sectors. A key feature of Mercury is its direct connection to the linear Horndeski framework implemented in hi_class [3 , 4 ] . Following the same model description, Mercury supports both approaches available in hi_class: the effective-theory approach, in which the α \alpha α functions are parametrised directly, and the covariant-theory approach, in which the model is specified through its underlying Horndeski Lagrangian and the corresponding α \alpha α functions are determined from the covariant dynamics. We validate the implementation by recovering the known k k k -essence and KGB limits, comparing the linear regime with hi_class predictions, and testing the framework using both effective-theory and covariant descriptions of Horndeski models.
The paper is organised as follows. In § 2 , we introduce the Horndeski framework and the description of the background and linear perturbation dynamics adopted in Mercury. § 3 presents the implementation of the Horndeski contributions within the relativistic simulation framework, including the construction of the effective scalar sources in real space and the solution of the equations in Fourier space. In § 4 , we describe the numerical workflow of Mercury, from the specification of Horndeski models and the computation of the background evolution to the generation of initial conditions and the nonlinear evolution in the main simulation loop. § 5 presents the numerical validation of Mercury and the results for six representative Horndeski scenarios, comprising three phenomenological EFT parametrisations and three covariant Horndeski models, comparing the background evolution and perturbation spectra with hi_class and examining the deviations that emerge in the nonlinear regime. Finally, we summarise our results and discuss future perspectives in § 6 .
Horndeski gravity
We consider the Horndeski class of scalar–tensor theories [7 ] , which constitutes the most general covariant theory of a metric and a single scalar field whose equations of motion contain derivatives up to second order. This second-order structure avoids the additional unstable degree of freedom that generically arises in non-degenerate higher-derivative theories, commonly associated with the Ostrogradsky instability [24 ] . In the formulation used in this work, the equations are kept in the Jordan frame and organised such that the effects of the Horndeski scalar can be treated as effective dark-energy contributions to the metric equations. The scalar sector is therefore represented by an effective stress–energy tensor, while the non-minimal gravitational coupling is captured by the time-dependent effective Planck mass M ∗ 2 M_*^2 M ∗ 2 . This representation is particularly convenient for the implementation in gevolution, since the Horndeski contributions can be incorporated as additional gravitational sources while retaining the overall structure of the existing metric solver. At the same time, the minimal coupling of matter in the Jordan frame allows the particle equations of motion to retain their standard gevolution form.
Horndeski action and α \alpha α -basis description
Throughout this work we assume that the Einstein equivalence principle is respected. All matter species are therefore minimally and universally coupled to the same Jordan-frame metric g μ ν g_{\mu\nu} g μν , with no direct coupling between the matter fields and the Horndeski scalar. Under these assumptions, the total action can be written as1
S t o t = ∫ d 4 x − g [ M P l 2 ∑ i = 2 5 L i + L m ( g μ ν , ψ m ) ] , (1) S_{\mathrm{tot}} = \int d^4 x \sqrt{-g} \left[ M_{\mathrm{Pl}}^2 \sum_{i=2}^{5} \mathcal{L}_i + \mathcal{L}_{\mathrm{m}}(g_{\mu\nu},\psi_{\mathrm{m}}) \right] , \tag*{(1)} S tot = ∫ d 4 x − g [ M Pl 2 i = 2 ∑ 5 L i + L m ( g μν , ψ m ) ] , (1)
where L i \mathcal{L}_i L i are given by
L 2 = G 2 ( ϕ , X ) , \mathcal{L}_2 = G_2(\phi,X), L 2 = G 2 ( ϕ , X ) ,
L 3 = − G 3 ( ϕ , X ) □ ϕ , \mathcal{L}_3 = -G_3(\phi,X)\Box\phi, L 3 = − G 3 ( ϕ , X ) □ ϕ ,
L 4 = G 4 ( ϕ , X ) R + G 4 X [ ( □ ϕ ) 2 − ( ∇ μ ∇ ν ϕ ) 2 ] , \mathcal{L}_4 = G_4(\phi,X)R + G_{4X}\left[(\Box\phi)^2 - (\nabla_\mu\nabla_\nu\phi)^2\right], L 4 = G 4 ( ϕ , X ) R + G 4 X [ ( □ ϕ ) 2 − ( ∇ μ ∇ ν ϕ ) 2 ] ,
L 5 = G 5 ( ϕ , X ) G μ ν ∇ μ ∇ ν ϕ − 1 6 G 5 X [ ( □ ϕ ) 3 − 3 □ ϕ ( ∇ μ ∇ ν ϕ ) 2 + 2 ( ∇ μ ∇ ν ϕ ) 3 ] . \mathcal{L}_5 = G_5(\phi,X)G_{\mu\nu}\nabla^\mu\nabla^\nu\phi- \frac{1}{6}G_{5X}\left[(\Box\phi)^3 - 3\Box\phi(\nabla_\mu\nabla_\nu\phi)^2 + 2(\nabla_\mu\nabla_\nu\phi)^3\right]. L 5 = G 5 ( ϕ , X ) G μν ∇ μ ∇ ν ϕ − 6 1 G 5 X [ ( □ ϕ ) 3 − 3 □ ϕ ( ∇ μ ∇ ν ϕ ) 2 + 2 ( ∇ μ ∇ ν ϕ ) 3 ] .
The freedom of the theory is encoded in the functions G i ( ϕ , X ) G_i(\phi,X) G i ( ϕ , X ) , which are arbitrary functions of the scalar field ϕ \phi ϕ and its canonical kinetic term X ≡ − 1 2 ∇ μ ϕ ∇ μ ϕ X \equiv-\frac{1}{2}\nabla^\mu\phi\nabla_\mu\phi X ≡ − 2 1 ∇ μ ϕ ∇ μ ϕ . We denote derivatives with respect to X X X by a subscript, G i X ≡ ∂ G i / ∂ X G_{iX} \equiv\partial G_i/\partial X G i X ≡ ∂ G i / ∂ X .
Several well-known dark energy and modified gravity models are recovered as particular choices of the functions G i G_i G i . For instance, minimally coupled quintessence and k k k -essence correspond to fixing G 4 = 1 / 2 G_4 = 1/2 G 4 = 1/2 and G 3 = G 5 = 0 G_3 = G_5 = 0 G 3 = G 5 = 0 , so that the scalar dynamics are entirely determined by G 2 ( ϕ , X ) G_2(\phi, X) G 2 ( ϕ , X ) . Allowing in addition a non-vanishing G 3 ( ϕ , X ) G_3(\phi, X) G 3 ( ϕ , X ) while keeping G 4 = 1 / 2 G_4 = 1/2 G 4 = 1/2 and G 5 = 0 G_5 = 0 G 5 = 0 gives the kinetic gravity braiding (KGB) subclass, where the scalar kinetic structure mixes with the metric through the braiding interaction [25 ] . More general choices of G 4 G_4 G 4 and G 5 G_5 G 5 introduce non-minimal interactions between the scalar field and curvature, affecting the effective gravitational coupling and the dynamics of metric perturbations.
To describe cosmological perturbations, we work around a spatially flat Friedmann–Lemaître–Robertson–Walker (FLRW) background and adopt the Poisson gauge, which is the gauge used by gevolution. The line element is written as
d s 2 = a 2 ( τ ) [ − e 2 Ψ d τ 2 − 2 B i d x i d τ + ( e − 2 Φ δ i j + h i j ) d x i d x j ] , (2) ds^2 = a^2(\tau)\left[-e^{2\Psi}d\tau^2 - 2B_i dx^i d\tau+ \left(e^{-2\Phi}\delta_{ij} + h_{ij}\right)dx^i dx^j\right], \tag*{(2)} d s 2 = a 2 ( τ ) [ − e 2Ψ d τ 2 − 2 B i d x i d τ + ( e − 2Φ δ ij + h ij ) d x i d x j ] , (2)
where a ( τ ) a(\tau) a ( τ ) is the scale factor and τ \tau τ denotes conformal time, related to cosmic time by d τ = d t / a ( t ) d\tau= dt/a(t) d τ = d t / a ( t ) . The scalar perturbations Ψ \Psi Ψ and Φ \Phi Φ correspond to the temporal and spatial metric potentials, respectively. The vector perturbation B i B_i B i is transverse, ∂ i B i = 0 \partial^i B_i = 0 ∂ i B i = 0 , while the tensor perturbation h i j h_{ij} h ij is transverse and traceless, ∂ i h i j = 0 \partial^i h_{ij} = 0 ∂ i h ij = 0 and h i i = 0 h^i_i = 0 h i i = 0 .
The covariant metric equations and the scalar-field equation follow from the variation of the total action and form the starting point for the implementation. When expressed directly in terms of the G i G_i G i functions, these equations involve many different combinations of the functions and their derivatives with respect to ϕ \phi ϕ and X X X . For cosmological applications, however, the linear perturbation dynamics can be organised more efficiently in terms of the effective Planck mass M ∗ 2 M_*^2 M ∗ 2 and the four dimensionless α \alpha α functions α K \alpha_K α K , α B \alpha_B α B , α M \alpha_M α M and α T \alpha_T α T [3 , 8 , 26 ] . These quantities are evaluated on the homogeneous background and can either be derived from a specified covariant Horndeski action or supplied directly through a phenomenological parametrisation.
The effective Planck mass and the four α \alpha α functions characterise different aspects of the scalar–tensor dynamics. In the following, primes denote derivatives with respect to conformal time, H ≡ a ′ / a 2 \mathit{H} \equiv a'/a^2 H ≡ a ′ / a 2 is the physical Hubble rate, H ≡ a ′ / a = a H \mathcal{H} \equiv a'/a = aH H ≡ a ′ / a = a H is the conformal Hubble rate, and the background kinetic term is X ˉ = ϕ ˉ ′ 2 / ( 2 a 2 ) \bar{X} = \bar{\phi}'^2/(2a^2) X ˉ = ϕ ˉ ′2 / ( 2 a 2 ) . All functions G i G_i G i and their derivatives are understood to be evaluated on the homogeneous background. We follow the hi_class convention in which M ∗ 2 M_*^2 M ∗ 2 is dimensionless and denotes the squared ratio of the cosmological effective Planck mass to the locally measured Planck mass M ∗ 2 ≡ M e f f 2 / M P l 2 M_*^2 \equiv M_{\mathrm{eff}}^2/M_{\mathrm{Pl}}^2 M ∗ 2 ≡ M eff 2 / M Pl 2 .
α K \alpha_K α K , kineticity , characterises the kinetic contribution of the scalar degree of freedom and contributes to the kinetic coefficient governing the propagating scalar mode. In the covariant formulation, α K \alpha_K α K can receive contributions from all four Horndeski functions G 2 G_2 G 2 , G 3 G_3 G 3 , G 4 G_4 G 4 and G 5 G_5 G 5 :
H 2 M ∗ 2 α K = 2 X ˉ ( G 2 X + 2 X ˉ G 2 X X − 2 G 3 ϕ − 2 X ˉ G 3 ϕ X ) + 12 ϕ ˉ ′ H X ˉ a ( G 3 X + X ˉ G 3 X X − 2 G 4 ϕ X − 2 X ˉ G 4 ϕ X X ) + 12 H 2 X ˉ [ G 4 X + 8 X ˉ G 4 X X + 4 X ˉ 2 G 4 X X X ] − 12 H 2 X ˉ [ G 5 ϕ + 5 X ˉ G 5 ϕ X + 2 X ˉ 2 G 5 ϕ X X ] + 4 ϕ ˉ ′ H 3 X ˉ a ( 3 G 5 X + 7 X ˉ G 5 X X + 2 X ˉ 2 G 5 X X X ) . (3) \begin{aligned}
H^2 M_*^2 \alpha_K ={}& 2\bar{X}\left(G_{2X} + 2\bar{X}G_{2XX} - 2G_{3\phi} - 2\bar{X}G_{3\phi X}\right) \\
&+ \frac{12\bar{\phi}'H\bar{X}}{a}\left(G_{3X} + \bar{X}G_{3XX} - 2G_{4\phi X} - 2\bar{X}G_{4\phi XX}\right) \\
&+ 12H^2\bar{X}\left[G_{4X} + 8\bar{X}G_{4XX} + 4\bar{X}^2G_{4XXX}\right] \\
&- 12H^2\bar{X}\left[G_{5\phi} + 5\bar{X}G_{5\phi X} + 2\bar{X}^2G_{5\phi XX}\right] \\
&+ \frac{4\bar{\phi}'H^3\bar{X}}{a}\left(3G_{5X} + 7\bar{X}G_{5XX} + 2\bar{X}^2G_{5XXX}\right). \tag*{(3)}
\end{aligned} H 2 M ∗ 2 α K = 2 X ˉ ( G 2 X + 2 X ˉ G 2 X X − 2 G 3 ϕ − 2 X ˉ G 3 ϕX ) + a 12 ϕ ˉ ′ H X ˉ ( G 3 X + X ˉ G 3 X X − 2 G 4 ϕX − 2 X ˉ G 4 ϕX X ) + 12 H 2 X ˉ [ G 4 X + 8 X ˉ G 4 X X + 4 X ˉ 2 G 4 X X X ] − 12 H 2 X ˉ [ G 5 ϕ + 5 X ˉ G 5 ϕX + 2 X ˉ 2 G 5 ϕX X ] + a 4 ϕ ˉ ′ H 3 X ˉ ( 3 G 5 X + 7 X ˉ G 5 X X + 2 X ˉ 2 G 5 X X X ) . (3)
α B \alpha_{\mathrm{B}} α B , braiding , quantifies the kinetic mixing between the scalar and metric perturbations. A non-vanishing α B \alpha_{\mathrm{B}} α B allows the scalar and metric sectors to source one another, modifying the response of the scalar degree of freedom to matter perturbations. In the covariant formulation, it receives contributions from the derivative interaction G 3 G_{3} G 3 and from the non-minimal sectors G 4 G_{4} G 4 and G 5 G_{5} G 5 :
H M ∗ 2 α B = 2 ϕ ˉ ′ a ( X ˉ G 3 X − G 4 ϕ − 2 X ˉ G 4 ϕ X ) + 8 H X ˉ ( G 4 X + 2 X ˉ G 4 X X − G 5 ϕ − X ˉ G 5 ϕ X ) + 2 ϕ ˉ ′ H 2 X ˉ a ( 3 G 5 X + 2 X ˉ G 5 X X ) . (4) H M_{*}^{2}\alpha_{\mathrm{B}} = \frac{2\bar{\phi}'}{a}\left(\bar{X}G_{3X}-G_{4\phi}-2\bar{X}G_{4\phi X}\right) + 8H\bar{X}\left(G_{4X}+2\bar{X}G_{4XX}-G_{5\phi}-\bar{X}G_{5\phi X}\right) + \frac{2\bar{\phi}'H^{2}\bar{X}}{a}\left(3G_{5X}+2\bar{X}G_{5XX}\right). \tag*{(4)} H M ∗ 2 α B = a 2 ϕ ˉ ′ ( X ˉ G 3 X − G 4 ϕ − 2 X ˉ G 4 ϕX ) + 8 H X ˉ ( G 4 X + 2 X ˉ G 4 X X − G 5 ϕ − X ˉ G 5 ϕX ) + a 2 ϕ ˉ ′ H 2 X ˉ ( 3 G 5 X + 2 X ˉ G 5 X X ) . (4)
M ∗ 2 M_{*}^{2} M ∗ 2 , the dimensionless effective Planck mass squared , sets the normalisation of the gravitational sector and may evolve with the cosmological background. In the covariant formulation, it is determined by the non-minimal coupling functions G 4 G_{4} G 4 and G 5 G_{5} G 5 :
M ∗ 2 = 2 [ G 4 − 2 X ˉ G 4 X + X ˉ G 5 ϕ − H ϕ ˉ ′ X ˉ a G 5 X ] . (5) M_{*}^{2}=2\left[G_{4}-2\bar{X}G_{4X}+\bar{X}G_{5\phi}-\frac{H\bar{\phi}'\bar{X}}{a}G_{5X}\right]. \tag*{(5)} M ∗ 2 = 2 [ G 4 − 2 X ˉ G 4 X + X ˉ G 5 ϕ − a H ϕ ˉ ′ X ˉ G 5 X ] . (5)
α M = 1 a H ( M ∗ 2 ) ′ M ∗ 2 . (6) \alpha_{\mathrm{M}}=\frac{1}{aH}\frac{(M_{*}^{2})'}{M_{*}^{2}}. \tag*{(6)} α M = a H 1 M ∗ 2 ( M ∗ 2 ) ′ . (6)
α T \alpha_{\mathrm{T}} α T , the tensor-speed excess , measures the deviation of the propagation speed of tensor perturbations from the speed of light. In the covariant formulation, it is determined by derivative interactions in G 4 G_{4} G 4 and G 5 G_{5} G 5 :
M ∗ 2 α T = 2 X ˉ [ 2 G 4 X − 2 G 5 ϕ − ϕ ˉ ′ ′ − 2 a H ϕ ˉ ′ a 2 G 5 X ] . (7) M_{*}^{2}\alpha_{\mathrm{T}}=2\bar{X}\left[2G_{4X}-2G_{5\phi}-\frac{\bar{\phi}''-2aH\bar{\phi}'}{a^{2}}G_{5X}\right]. \tag*{(7)} M ∗ 2 α T = 2 X ˉ [ 2 G 4 X − 2 G 5 ϕ − a 2 ϕ ˉ ′′ − 2 a H ϕ ˉ ′ G 5 X ] . (7)
The above relations provide the mapping between the covariant Horndeski action and the quantities used in Mercury. The evolution equations can then be expressed in terms of the effective background density and pressure, ρ ˉ ϕ \bar{\rho}_{\phi} ρ ˉ ϕ and P ˉ ϕ \bar{P}_{\phi} P ˉ ϕ , together with M ∗ 2 M_{*}^{2} M ∗ 2 and the α \alpha α functions, without explicitly retaining the individual functions G i G_{i} G i . An important feature of this formulation is that it separates the background expansion history from the independent properties of linear perturbations encoded by the α \alpha α functions [8 ] .
For the scalar perturbation, we follow the notation used in our previous implementations and introduce the variables
π = δ ϕ ϕ ˉ ′ , ζ = π ′ + H π − Ψ . (8) \pi=\frac{\delta\phi}{\bar{\phi}'},\qquad\zeta=\pi'+\mathcal{H}\pi-\Psi. \tag*{(8)} π = ϕ ˉ ′ δ ϕ , ζ = π ′ + H π − Ψ. (8)
Background equations
The homogeneous background evolution used by Mercury is obtained from hi_class. The expansion rate is determined from the energy density of all homogeneous components through the Friedmann equation
H 2 = ∑ i ρ ˉ i . (9) H^{2}=\sum_{i}\bar{\rho}_{i}. \tag*{(9)} H 2 = i ∑ ρ ˉ i . (9)
where the sum runs over all species included in the background evolution. We adopt the hi_class convention, based on the normalisation used in CLASS [27 ] , in which the components of the energy–momentum tensor are rescaled according to
ρ ˉ i h i - c l a s s = 8 π G N 3 ρ ˉ i s t a n d a r d = 1 3 M P l 2 ρ ˉ i s t a n d a r d , (10) \bar{\rho}^{\mathrm{hi\text{-}class}}_i = \frac{8\pi G_N}{3}\bar{\rho}^{\mathrm{standard}}_i = \frac{1}{3M_{\mathrm{Pl}}^2}\bar{\rho}^{\mathrm{standard}}_i, \tag*{(10)} ρ ˉ i hi - class = 3 8 π G N ρ ˉ i standard = 3 M Pl 2 1 ρ ˉ i standard , (10)
with G N G_N G N fixed to Newton’s constant as measured today. In the hi_class convention, the effective Planck mass is normalised to the locally measured Planck mass. Consequently, M ∗ 2 M_*^2 M ∗ 2 is dimensionless and represents their squared ratio, with the general relativistic limit corresponding to M ∗ 2 = 1 M_*^2=1 M ∗ 2 = 1 .
At the background level, the Horndeski scalar is described in terms of an effective dark-energy density ρ ˉ ϕ \bar{\rho}_{\phi} ρ ˉ ϕ and pressure P ˉ ϕ \bar{P}_{\phi} P ˉ ϕ . For a covariant Horndeski model, these quantities are obtained by evaluating the action on the homogeneous background and are given by
ρ ˉ ϕ h i - c l a s s = − 1 3 G 2 + 2 3 X ˉ ( G 2 X − G 3 ϕ ) − 2 H 3 ϕ ˉ ′ X ˉ 3 a ( 7 G 5 X + 4 X ˉ G 5 X X ) + H 2 [ 1 − ( 1 − α B ) M ∗ 2 − 4 X ˉ ( G 4 X − G 5 ϕ ) − 4 X ˉ 2 ( 2 G 4 X X − G 5 ϕ X ) ] , (11) \bar{\rho}^{\mathrm{hi\text{-}class}}_{\phi} = -\frac{1}{3}G_2 + \frac{2}{3}\bar{X}(G_{2X}-G_{3\phi}) - \frac{2H^3\bar{\phi}'\bar{X}}{3a}(7G_{5X}+4\bar{X}G_{5XX}) + H^2\left[1-(1-\alpha_B)M_*^2-4\bar{X}(G_{4X}-G_{5\phi})-4\bar{X}^2(2G_{4XX}-G_{5\phi X})\right], \tag*{(11)} ρ ˉ ϕ hi - class = − 3 1 G 2 + 3 2 X ˉ ( G 2 X − G 3 ϕ ) − 3 a 2 H 3 ϕ ˉ ′ X ˉ ( 7 G 5 X + 4 X ˉ G 5 X X ) + H 2 [ 1 − ( 1 − α B ) M ∗ 2 − 4 X ˉ ( G 4 X − G 5 ϕ ) − 4 X ˉ 2 ( 2 G 4 X X − G 5 ϕX ) ] , (11)
and
P ˉ ϕ h i - c l a s s = 1 3 G 2 − 2 3 X ˉ ( G 3 ϕ − 2 G 4 ϕ ϕ ) + 4 H ϕ ˉ ′ 3 a ( G 4 ϕ − 2 X ˉ G 4 ϕ X + X ˉ G 5 ϕ ϕ ) − ϕ ˉ ′ ′ − a H ϕ ˉ ′ 3 a ϕ ˉ ′ H M ∗ 2 α B − 4 3 H 2 X ˉ 2 G 5 ϕ X − ( H 2 + 2 H H ′ 3 a ) ( 1 − M ∗ 2 ) + 2 H 3 ϕ ˉ ′ X ˉ 3 a G 5 X . (12) \bar{P}^{\mathrm{hi\text{-}class}}_{\phi} = \frac{1}{3}G_2-\frac{2}{3}\bar{X}(G_{3\phi}-2G_{4\phi\phi})+\frac{4H\bar{\phi}'}{3a}(G_{4\phi}-2\bar{X}G_{4\phi X}+\bar{X}G_{5\phi\phi})
-\frac{\bar{\phi}''-aH\bar{\phi}'}{3a\bar{\phi}'}HM_*^2\alpha_B-\frac{4}{3}H^2\bar{X}^2G_{5\phi X}-\left(H^2+\frac{2H H'}{3a}\right)(1-M_*^2)
+\frac{2H^3\bar{\phi}'\bar{X}}{3a}G_{5X}. \tag*{(12)} P ˉ ϕ hi - class = 3 1 G 2 − 3 2 X ˉ ( G 3 ϕ − 2 G 4 ϕϕ ) + 3 a 4 H ϕ ˉ ′ ( G 4 ϕ − 2 X ˉ G 4 ϕX + X ˉ G 5 ϕϕ ) − 3 a ϕ ˉ ′ ϕ ˉ ′′ − a H ϕ ˉ ′ H M ∗ 2 α B − 3 4 H 2 X ˉ 2 G 5 ϕX − ( H 2 + 3 a 2 H H ′ ) ( 1 − M ∗ 2 ) + 3 a 2 H 3 ϕ ˉ ′ X ˉ G 5 X . (12)
Here all functions G i G_i G i and their derivatives are evaluated on the homogeneous background.
With this choice of variables, all homogeneous contributions from the Horndeski sector, including those associated with the time dependence of the effective Planck mass, are absorbed into the effective quantities ρ ˉ ϕ \bar{\rho}_{\phi} ρ ˉ ϕ and P ˉ ϕ \bar{P}_{\phi} P ˉ ϕ . This allows the background scalar sector to be treated as an effective dark-energy fluid. Since matter is minimally coupled to the Jordan-frame metric, the matter sector remains separately conserved, while the effective dark-energy component satisfies
ρ ˉ ϕ ′ + 3 H ρ ˉ ϕ ( 1 + w ϕ ) = 0 , (13) \bar{\rho}'_{\phi}+3\mathcal{H}\bar{\rho}_{\phi}(1+w_{\phi})=0, \tag*{(13)} ρ ˉ ϕ ′ + 3 H ρ ˉ ϕ ( 1 + w ϕ ) = 0 , (13)
where w ϕ ≡ P ˉ ϕ / ρ ˉ ϕ w_{\phi}\equiv\bar{P}_{\phi}/\bar{\rho}_{\phi} w ϕ ≡ P ˉ ϕ / ρ ˉ ϕ is the effective dark-energy equation-of-state parameter.
The quantities ρ ˉ ϕ \bar{\rho}_{\phi} ρ ˉ ϕ and P ˉ ϕ \bar{P}_{\phi} P ˉ ϕ defined in this way are the background inputs used in the perturbation equations below. The practical determination of these quantities for the different hi_class input modes is described in § 4 .
Linear perturbation equations
The linear perturbation equations provide the starting point for the numerical implementation. They are written in Poisson gauge and in conformal time, following the notation introduced in the previous subsections.
Einstein field equations
The Hamiltonian constraint (Einstein 0 0 _{0}^{0} 0 0 component) takes the form
∇ 2 Φ − 3 H 2 Ψ − 3 H Φ ′ = a 2 2 M ∗ 2 ( δ ρ m + δ ρ ϕ ) , (14) \nabla^{2}\Phi- 3\mathcal{H}^{2}\Psi- 3\mathcal{H}\Phi' = \frac{a^{2}}{2M_{*}^{2}}(\delta\rho_{\mathrm{m}}+\delta\rho_{\phi}) \, , \tag*{(14)} ∇ 2 Φ − 3 H 2 Ψ − 3 H Φ ′ = 2 M ∗ 2 a 2 ( δ ρ m + δ ρ ϕ ) , (14)
where the scalar-field contribution to the effective energy density is
δ ρ ϕ = − M ∗ 2 a 2 { α B H ∇ 2 π + 3 α B H 2 Ψ − ( 3 α B + α K ) H 2 ζ + 3 α B H Φ ′ + [ 2 H 2 − α B H 2 + α B H ′ − 2 H ′ − a 2 M ∗ 2 ( ρ ˉ m + P ˉ m ) ] 3 H π } . (15) \delta\rho_{\phi} = -\frac{M_{*}^{2}}{a^{2}}\left\{\alpha_{\mathrm{B}}\mathcal{H}\nabla^{2}\pi+ 3\alpha_{\mathrm{B}}\mathcal{H}^{2}\Psi- (3\alpha_{\mathrm{B}}+\alpha_{\mathrm{K}})\mathcal{H}^{2}\zeta+ 3\alpha_{\mathrm{B}}\mathcal{H}\Phi'
+ \left[2\mathcal{H}^{2}-\alpha_{\mathrm{B}}\mathcal{H}^{2}+\alpha_{\mathrm{B}}\mathcal{H}'-2\mathcal{H}'-\frac{a^{2}}{M_{*}^{2}}(\bar{\rho}_{\mathrm{m}}+\bar{P}_{\mathrm{m}})\right]3\mathcal{H}\pi\right\} \, . \tag*{(15)} δ ρ ϕ = − a 2 M ∗ 2 { α B H ∇ 2 π + 3 α B H 2 Ψ − ( 3 α B + α K ) H 2 ζ + 3 α B H Φ ′ + [ 2 H 2 − α B H 2 + α B H ′ − 2 H ′ − M ∗ 2 a 2 ( ρ ˉ m + P ˉ m ) ] 3 H π } . (15)
Equation (14) is used to determine the spatial curvature potential Φ \Phi Φ . The remaining metric perturbations are obtained from the trace-free spatial part of the Einstein equations, which is given by
D i j χ + B ( i , j ) ′ + ( 2 + α M ) H B ( i , j ) + 1 2 h i j ′ ′ + ( 1 + α M 2 ) H h i j ′ − 1 2 ( 1 + α T ) ∇ 2 h i j = a 2 M ∗ 2 ( Π i j m + Π i j ϕ ) , (16) \mathcal{D}_{ij}\chi+ B'_{(i,j)} + (2+\alpha_{\mathrm{M}})\mathcal{H}B_{(i,j)} + \frac{1}{2}h''_{ij} + \left(1+\frac{\alpha_{\mathrm{M}}}{2}\right)\mathcal{H}h'_{ij} - \frac{1}{2}(1+\alpha_{\mathrm{T}})\nabla^{2}h_{ij}
= \frac{a^{2}}{M_{*}^{2}}\left(\Pi^{\mathrm{m}}_{ij}+\Pi^{\phi}_{ij}\right) \, , \tag*{(16)} D ij χ + B ( i , j ) ′ + ( 2 + α M ) H B ( i , j ) + 2 1 h ij ′′ + ( 1 + 2 α M ) H h ij ′ − 2 1 ( 1 + α T ) ∇ 2 h ij = M ∗ 2 a 2 ( Π ij m + Π ij ϕ ) , (16)
where χ ≡ Φ − Ψ \chi\equiv\Phi-\Psi χ ≡ Φ − Ψ is the gravitational slip, D i j ≡ ∂ i ∂ j − 1 3 δ i j ∇ 2 \mathcal{D}_{ij}\equiv\partial_i\partial_j-\frac{1}{3}\delta_{ij}\nabla^2 D ij ≡ ∂ i ∂ j − 3 1 δ ij ∇ 2 is the traceless second-derivative operator and Π i j ϕ \Pi^\phi_{ij} Π ij ϕ is the scalar-field anisotropic stress given by
Π i j ϕ = M ∗ 2 a 2 D i j [ − α T Φ + ( α M − α T ) H π ] . (17) \Pi^\phi_{ij}=\frac{M_{*}^{2}}{a^{2}}\mathcal{D}_{ij}\left[-\alpha_{\mathrm{T}}\Phi+(\alpha_{\mathrm{M}}-\alpha_{\mathrm{T}})\mathcal{H}\pi\right] \, . \tag*{(17)} Π ij ϕ = a 2 M ∗ 2 D ij [ − α T Φ + ( α M − α T ) H π ] . (17)
Thus the trace-free spatial equation contains five independent components. These determine the scalar slip χ \chi χ , the two vector components of B i B_i B i , and the two tensor components of h i j h_{ij} h ij . In the numerical implementation that we will discuss in the next section, these components are separated and solved by the corresponding spin projections in Fourier space.
The effects of the non-minimal coupling appear in both metric equations, Eqs. (14) and (16) . In the Hamiltonian constraint, M ∗ 2 M_{*}^{2} M ∗ 2 enters both the effective scalar-field energy density perturbation δ ρ ϕ \delta\rho_{\phi} δ ρ ϕ and the prefactor multiplying the total density perturbation δ ρ m + δ ρ ϕ \delta\rho_{\mathrm{m}}+\delta\rho_{\phi} δ ρ m + δ ρ ϕ . In the trace-free spatial equation, M ∗ 2 M_{*}^{2} M ∗ 2 analogously enters both the effective scalar-field anisotropic stress Π i j ϕ \Pi^\phi_{ij} Π ij ϕ and the effective gravitational coupling of the total anisotropic-stress source. The time variation of the effective Planck mass further modifies the damping of the vector and tensor perturbations through α M \alpha_{\mathrm{M}} α M , while the tensor-speed excess α T \alpha_{\mathrm{T}} α T changes the tensor Laplacian term, corresponding to a modified propagation speed for gravitational waves.
Once the Hamiltonian constraint and the trace-free spatial equations are imposed, the remaining Einstein equations are related to them by the contracted Bianchi identities and the covariant conservation of the total stress–energy tensor. They therefore do not provide independent metric equations, but serve as consistency relations. In particular, the time-space component gives the momentum constraint
− 2 M ∗ 2 a 2 ( 1 4 ∇ 2 B i + ∂ i Φ ′ + H ∂ i Ψ ) = δ T i 0 ( m ) + δ T i 0 ( ϕ ) . (18) -\frac{2M_{*}^{2}}{a^{2}}\left(\frac{1}{4}\nabla^{2}B_i+\partial_i\Phi'+\mathcal{H}\partial_i\Psi\right)=\delta T_{i}^{0(\mathrm{m})}+\delta T_{i}^{0(\phi)} \, . \tag*{(18)} − a 2 2 M ∗ 2 ( 4 1 ∇ 2 B i + ∂ i Φ ′ + H ∂ i Ψ ) = δ T i 0 ( m ) + δ T i 0 ( ϕ ) . (18)
where
δ T i ( 0 ) ( ϕ ) = M ∗ 2 a 2 { [ a 2 M ∗ 2 ( ρ ˉ m + P ˉ m ) − 2 H 2 + 2 H ′ ] ∂ i π + α B H ∂ i ζ } (19) \delta T_i^{(0)}(\phi)=\frac{M_*^2}{a^2}\left\{\left[\frac{a^2}{M_*^2}\left(\bar{\rho}_m+\bar{P}_m\right)-2\mathcal{H}^2+2\mathcal{H}'\right]\partial_i\pi+\alpha_{\mathrm{B}}\mathcal{H}\partial_i\zeta\right\} \tag*{(19)} δ T i ( 0 ) ( ϕ ) = a 2 M ∗ 2 { [ M ∗ 2 a 2 ( ρ ˉ m + P ˉ m ) − 2 H 2 + 2 H ′ ] ∂ i π + α B H ∂ i ζ } (19)
Although Eq. (18) is not solved independently in our implementation, its transverse projection provides an optional consistency test of the vector perturbation obtained from the spin-1 projection of Eq. (16) .
Scalar-field equation of motion
The evolution of the additional scalar degree of freedom is determined by its linear equation of motion. Using the variables π \pi π and ζ \zeta ζ introduced above, we can write
A ζ ′ ζ ′ + A ζ ζ + A π π + A ∇ 2 π ∇ 2 π + A ∇ 2 Ψ ∇ 2 Ψ + A ∇ 2 Φ ∇ 2 Φ + A δ P m δ P m + A Φ ′ Φ ′ + A Ψ Ψ = 0 (20) A_{\zeta'}\zeta'+A_{\zeta}\zeta+A_{\pi}\pi+A_{\nabla^2\pi}\nabla^2\pi+A_{\nabla^2\Psi}\nabla^2\Psi+A_{\nabla^2\Phi}\nabla^2\Phi+A_{\delta P_m}\delta P_m+A_{\Phi'}\Phi'+A_{\Psi}\Psi=0 \tag*{(20)} A ζ ′ ζ ′ + A ζ ζ + A π π + A ∇ 2 π ∇ 2 π + A ∇ 2 Ψ ∇ 2 Ψ + A ∇ 2 Φ ∇ 2 Φ + A δ P m δ P m + A Φ ′ Φ ′ + A Ψ Ψ = 0 (20)
where
A ζ ′ = − H 2 ( 3 2 α B 2 + α K ) , A ∇ 2 Ψ = α B H , A ∇ 2 Φ = 2 H ( α M − α T ) , A δ P m = 3 a 2 H 2 M ∗ 2 α B , A_{\zeta'}=-\mathcal{H}^2\left(\frac{3}{2}\alpha_{\mathrm{B}}^2+\alpha_{\mathrm{K}}\right),\qquad A_{\nabla^2\Psi}=\alpha_{\mathrm{B}}\mathcal{H},\qquad A_{\nabla^2\Phi}=2\mathcal{H}\left(\alpha_{\mathrm{M}}-\alpha_{\mathrm{T}}\right),\qquad A_{\delta P_m}=\frac{3a^2\mathcal{H}}{2M_*^2}\alpha_{\mathrm{B}}, A ζ ′ = − H 2 ( 2 3 α B 2 + α K ) , A ∇ 2 Ψ = α B H , A ∇ 2 Φ = 2 H ( α M − α T ) , A δ P m = 2 M ∗ 2 3 a 2 H α B ,
A ζ = H 3 [ 3 α B ( 1 − α B ) − α K − 3 2 α B 2 α M − α K α M ] − H 2 [ 3 2 α B α B ′ + α K ′ ] − H H ′ [ 3 α B + 3 2 α B 2 + 2 α K ] − 3 a 2 H 2 M ∗ 2 α B ( ρ ˉ m + P ˉ m ) , A_{\zeta}=\mathcal{H}^3\left[3\alpha_{\mathrm{B}}(1-\alpha_{\mathrm{B}})-\alpha_{\mathrm{K}}-\frac{3}{2}\alpha_{\mathrm{B}}^2\alpha_{\mathrm{M}}-\alpha_{\mathrm{K}}\alpha_{\mathrm{M}}\right]-\mathcal{H}^2\left[\frac{3}{2}\alpha_{\mathrm{B}}\alpha_{\mathrm{B}}'+\alpha_{\mathrm{K}}'\right]-\mathcal{H}\mathcal{H}'\left[3\alpha_{\mathrm{B}}+\frac{3}{2}\alpha_{\mathrm{B}}^2+2\alpha_{\mathrm{K}}\right]-\frac{3a^2\mathcal{H}}{2M_*^2}\alpha_{\mathrm{B}}\left(\bar{\rho}_m+\bar{P}_m\right), A ζ = H 3 [ 3 α B ( 1 − α B ) − α K − 2 3 α B 2 α M − α K α M ] − H 2 [ 2 3 α B α B ′ + α K ′ ] − H H ′ [ 3 α B + 2 3 α B 2 + 2 α K ] − 2 M ∗ 2 3 a 2 H α B ( ρ ˉ m + P ˉ m ) ,
A π = 3 { H 4 ( α B − 2 ) − H 3 α B ′ + H 2 H ′ ( 4 − 2 α B ) + H H ′ α B ′ + H ′ 2 ( α B − 2 ) + a 2 M ∗ 2 [ ( ρ ˉ m + P ˉ m ) H 2 − ( ρ ˉ m + P ˉ m ) H ′ − 1 2 α B H P ˉ m ′ ] } , A_{\pi}=3\left\{\mathcal{H}^4(\alpha_{\mathrm{B}}-2)-\mathcal{H}^3\alpha_{\mathrm{B}}'+\mathcal{H}^2\mathcal{H}'(4-2\alpha_{\mathrm{B}})+\mathcal{H}\mathcal{H}'\alpha_{\mathrm{B}}'+\mathcal{H}'^2(\alpha_{\mathrm{B}}-2)+\frac{a^2}{M_*^2}\left[(\bar{\rho}_m+\bar{P}_m)\mathcal{H}^2-(\bar{\rho}_m+\bar{P}_m)\mathcal{H}'-\frac{1}{2}\alpha_{\mathrm{B}}\mathcal{H}\bar{P}_m'\right]\right\}, A π = 3 { H 4 ( α B − 2 ) − H 3 α B ′ + H 2 H ′ ( 4 − 2 α B ) + H H ′ α B ′ + H ′2 ( α B − 2 ) + M ∗ 2 a 2 [ ( ρ ˉ m + P ˉ m ) H 2 − ( ρ ˉ m + P ˉ m ) H ′ − 2 1 α B H P ˉ m ′ ] } ,
A Φ ′ = 3 [ H 2 ( 2 − α B ) + H α B ′ + H ′ ( α B − 2 ) − a 2 M ∗ 2 ( ρ ˉ m + P ˉ m ) ] , A_{\Phi'}=3\left[\mathcal{H}^2(2-\alpha_{\mathrm{B}})+\mathcal{H}\alpha_{\mathrm{B}}'+\mathcal{H}'(\alpha_{\mathrm{B}}-2)-\frac{a^2}{M_*^2}\left(\bar{\rho}_m+\bar{P}_m\right)\right], A Φ ′ = 3 [ H 2 ( 2 − α B ) + H α B ′ + H ′ ( α B − 2 ) − M ∗ 2 a 2 ( ρ ˉ m + P ˉ m ) ] ,
A ∇ 2 π = H 2 ( 2 + 2 α M + α B α M − 2 α T ) + H α B ′ + H ′ ( α B − 2 ) − a 2 M ∗ 2 ( ρ ˉ m + P ˉ m ) , A_{\nabla^2\pi}=\mathcal{H}^2(2+2\alpha_{\mathrm{M}}+\alpha_{\mathrm{B}}\alpha_{\mathrm{M}}-2\alpha_{\mathrm{T}})+\mathcal{H}\alpha_{\mathrm{B}}'+\mathcal{H}'(\alpha_{\mathrm{B}}-2)-\frac{a^2}{M_*^2}\left(\bar{\rho}_m+\bar{P}_m\right), A ∇ 2 π = H 2 ( 2 + 2 α M + α B α M − 2 α T ) + H α B ′ + H ′ ( α B − 2 ) − M ∗ 2 a 2 ( ρ ˉ m + P ˉ m ) ,
A Ψ = 3 H [ H 2 ( 2 − α B ) + H α B ′ + H ′ ( α B − 2 ) − a 2 M ∗ 2 ( ρ ˉ m + P ˉ m ) ] . A_{\Psi}=3\mathcal{H}\left[\mathcal{H}^2(2-\alpha_{\mathrm{B}})+\mathcal{H}\alpha_{\mathrm{B}}'+\mathcal{H}'(\alpha_{\mathrm{B}}-2)-\frac{a^2}{M_*^2}\left(\bar{\rho}_m+\bar{P}_m\right)\right]. A Ψ = 3 H [ H 2 ( 2 − α B ) + H α B ′ + H ′ ( α B − 2 ) − M ∗ 2 a 2 ( ρ ˉ m + P ˉ m ) ] .
Implementation
In this section, we describe the numerical implementation of the Horndeski sector in Mercury. The implementation follows the general structure of gevolution, with the scalar-field contributions constructed on the real-space lattice and the metric equations solved using Fourier-space projections.
In the following, all quantities entering the numerical evolution are expressed according to the gevolution unit convention. Background quantities imported from hi_class, including the expansion rate, densities, pressure, and their time derivatives, are converted to this convention before entering the lattice equations. In particular, gevolution normalises the background energy densities such that ρ c , 0 = 1 \rho_{c,0}=1 ρ c , 0 = 1 , while spatial coordinates and conformal time are normalised by the simulation box size. With this convention, the locally measured Planck mass is related to the gravitational coupling through M P l 2 = ( 8 π G N ) − 1 = ( 2 f o u r p i G ) − 1 M_{\mathrm{Pl}}^2=(8\pi G_{\mathrm{N}})^{-1}=(2\,\mathrm{fourpiG})^{-1} M Pl 2 = ( 8 π G N ) − 1 = ( 2 fourpiG ) − 1 , where f o u r p i G ≡ 4 π G N = 2 3 ( H 0 L / c ) 2 \mathrm{fourpiG}\equiv4\pi G_{\mathrm{N}}=\frac{2}{3}(H_0L/c)^2 fourpiG ≡ 4 π G N = 3 2 ( H 0 L / c ) 2 and L L L denotes the simulation box size in h − 1 M p c h^{-1}\,\mathrm{Mpc} h − 1 Mpc . The effective Planck mass entering the equations below is then M e f f 2 ≡ M P l 2 M 2 M_{\mathrm{eff}}^2\equiv M_{\mathrm{Pl}}^2M^2 M eff 2 ≡ M Pl 2 M 2 .
Real-space source construction
We construct the scalar-field contribution as an effective stress–energy tensor on the real-space lattice. For this purpose, we define a new function, projection_Tmunu_smg, in the gevolution.hpp file. In the following expressions, we label lattice sites by the indices i , j , k \mathbf{i},\mathbf{j},\mathbf{k} i , j , k and time cycles by the superscript n \mathbf{n} n . Thus, for a generic field f f f , the value stored at the lattice point ( i , j , k ) (\mathbf{i},\mathbf{j},\mathbf{k}) ( i , j , k ) during the n \mathbf{n} n -th cycle is denoted by f i , j , k n f^{\mathbf{n}}_{\mathbf{i},\mathbf{j},\mathbf{k}} f i , j , k n . The resulting components provide the lattice representation of the scalar-field effective stress–energy tensor, with δ T 0 ( ϕ ) 0 = − δ ρ ϕ \delta T^0_{0(\phi)}=-\delta\rho_\phi δ T 0 ( ϕ ) 0 = − δ ρ ϕ , together with δ T i ( ϕ ) 0 \delta T^0_{i(\phi)} δ T i ( ϕ ) 0 and Π i j ϕ \Pi^\phi_{ij} Π ij ϕ :
δ T 0 0 ( τ n , x i , j , k ) = M e f f 2 a 2 { α B H ( ∇ 2 π ) i , j , k n + 3 α B H 2 Ψ i , j , k n − ( 3 α B + α K ) H 2 ζ i , j , k n − 1 2 + 3 α B H ( Φ ′ ) i , j , k n + 3 H [ 2 H 2 − α B H 2 + α B H ′ − 2 H ′ − a 2 M e f f 2 ( ρ ˉ m + P ˉ m ) ] π i , j , k n } . (21) \delta T^0_0(\tau_n,\mathbf{x}_{i,j,k})=\frac{M_{\mathrm{eff}}^2}{a^2}\left\{\alpha_B\mathcal{H}\left(\nabla^2\pi\right)^{n}_{i,j,k}+3\alpha_B\mathcal{H}^2\Psi^n_{i,j,k}-\left(3\alpha_B+\alpha_K\right)\mathcal{H}^2\zeta^{n-\frac{1}{2}}_{i,j,k}+3\alpha_B\mathcal{H}\left(\Phi'\right)^n_{i,j,k}+3\mathcal{H}\left[2\mathcal{H}^2-\alpha_B\mathcal{H}^2+\alpha_B\mathcal{H}'-2\mathcal{H}'-\frac{a^2}{M_{\mathrm{eff}}^2}\left(\bar{\rho}_m+\bar{P}_m\right)\right]\pi^n_{i,j,k}\right\}. \tag*{(21)} δ T 0 0 ( τ n , x i , j , k ) = a 2 M eff 2 { α B H ( ∇ 2 π ) i , j , k n + 3 α B H 2 Ψ i , j , k n − ( 3 α B + α K ) H 2 ζ i , j , k n − 2 1 + 3 α B H ( Φ ′ ) i , j , k n + 3 H [ 2 H 2 − α B H 2 + α B H ′ − 2 H ′ − M eff 2 a 2 ( ρ ˉ m + P ˉ m ) ] π i , j , k n } . (21)
δ T i 0 ( τ n , x i , j , k ) = M e f f 2 a 2 { [ a 2 M e f f 2 ( ρ ˉ m + P ˉ m ) − 2 H 2 + 2 H ′ ] ( ∂ ℓ π ) i , j , k n + α B H ( ∂ ℓ ζ ) i , j , k n − 1 2 } . (22) \delta T^0_i(\tau_n,\mathbf{x}_{i,j,k})=\frac{M_{\mathrm{eff}}^2}{a^2}\left\{\left[\frac{a^2}{M_{\mathrm{eff}}^2}\left(\bar{\rho}_m+\bar{P}_m\right)-2\mathcal{H}^2+2\mathcal{H}'\right]\left(\partial_\ell\pi\right)^n_{i,j,k}+\alpha_B\mathcal{H}\left(\partial_\ell\zeta\right)^{n-\frac{1}{2}}_{i,j,k}\right\}. \tag*{(22)} δ T i 0 ( τ n , x i , j , k ) = a 2 M eff 2 { [ M eff 2 a 2 ( ρ ˉ m + P ˉ m ) − 2 H 2 + 2 H ′ ] ( ∂ ℓ π ) i , j , k n + α B H ( ∂ ℓ ζ ) i , j , k n − 2 1 } . (22)
Π ℓ m ( τ n , x i , j , k ) = M e f f 2 a 2 [ D ℓ m ( − α T Φ + ( α M − α T ) H π ) ] i , j , k n . (23) \Pi_{\ell m}(\tau_n,\mathbf{x}_{i,j,k})=\frac{M_{\mathrm{eff}}^2}{a^2}\left[D_{\ell m}\left(-\alpha_T\Phi+\left(\alpha_M-\alpha_T\right)\mathcal{H}\pi\right)\right]^n_{i,j,k}. \tag*{(23)} Π ℓ m ( τ n , x i , j , k ) = a 2 M eff 2 [ D ℓ m ( − α T Φ + ( α M − α T ) H π ) ] i , j , k n . (23)
Here ℓ , m = 1 , 2 , 3 \ell,m=1,2,3 ℓ , m = 1 , 2 , 3 denote spatial components and all background quantities are evaluated at the corresponding time cycle.
Real-space scalar-field evolution
The scalar-field variables are advanced in real space using a Newton–Störmer–Verlet leapfrog scheme [28 ] . In this scheme, ζ \zeta ζ is stored at half-integer time cycles, while π \pi π and the metric variables are stored at integer cycles.2 The update for ζ \zeta ζ is written as
ζ i , j , k n + 1 2 = ζ i , j , k n − 1 2 + π i , j , k n Δ τ . (24) \zeta^{n+\frac{1}{2}}_{i,j,k}=\zeta^{n-\frac{1}{2}}_{i,j,k}+\pi^n_{i,j,k}\Delta\tau. \tag*{(24)} ζ i , j , k n + 2 1 = ζ i , j , k n − 2 1 + π i , j , k n Δ τ . (24)
where ζ i , j , k ′ n \zeta_{i,j,k}^{\prime n} ζ i , j , k ′ n is obtained from the scalar-field equation of motion,
ζ i , j , k ′ n = − 1 A ζ ′ [ A ζ ζ i , j , k n + A π π i , j , k n + A Ψ Ψ i , j , k n + A Φ ′ Φ i , j , k ′ n + A δ P m δ P i , j , k n + A ∇ 2 π ( ∇ 2 π ) i , j , k n + A ∇ 2 Φ ( ∇ 2 Φ ) i , j , k n + A ∇ 2 Ψ ( ∇ 2 Ψ ) i , j , k n ] . (25) \zeta_{i,j,k}^{\prime n}=-\frac{1}{A_{\zeta'}}\left[A_{\zeta}\zeta_{i,j,k}^{n}+A_{\pi}\pi_{i,j,k}^{n}+A_{\Psi}\Psi_{i,j,k}^{n}+A_{\Phi'}\Phi_{i,j,k}^{\prime n}+A_{\delta P_m}\delta P_{i,j,k}^{n}
+A_{\nabla^2\pi}\left(\nabla^2\pi\right)_{i,j,k}^{n}+A_{\nabla^2\Phi}\left(\nabla^2\Phi\right)_{i,j,k}^{n}+A_{\nabla^2\Psi}\left(\nabla^2\Psi\right)_{i,j,k}^{n}\right]. \tag*{(25)} ζ i , j , k ′ n = − A ζ ′ 1 [ A ζ ζ i , j , k n + A π π i , j , k n + A Ψ Ψ i , j , k n + A Φ ′ Φ i , j , k ′ n + A δ P m δ P i , j , k n + A ∇ 2 π ( ∇ 2 π ) i , j , k n + A ∇ 2 Φ ( ∇ 2 Φ ) i , j , k n + A ∇ 2 Ψ ( ∇ 2 Ψ ) i , j , k n ] . (25)
All coefficients appearing in Eq. (25) are evaluated at the corresponding integer time cycle τ n \tau^n τ n . The integer-cycle value of ζ \zeta ζ is reconstructed from the two neighbouring half-integer cycle values as
ζ i , j , k n = ζ i , j , k n + 1 2 + ζ i , j , k n − 1 2 2 . (26) \zeta_{i,j,k}^{n}=\frac{\zeta_{i,j,k}^{n+\frac{1}{2}}+\zeta_{i,j,k}^{n-\frac{1}{2}}}{2}. \tag*{(26)} ζ i , j , k n = 2 ζ i , j , k n + 2 1 + ζ i , j , k n − 2 1 . (26)
Substituting Eq. (26) into Eq. (25) , and then inserting the result into Eq. (24) , gives the explicit update
ζ i , j , k n + 1 2 = 1 1 + ( A ζ A ζ ′ ) ( Δ τ 2 ) [ ζ i , j , k n − 1 2 − Δ τ A ζ ′ ( A ζ ζ i , j , k n − 1 2 2 + A π π i , j , k n + A Ψ Ψ i , j , k n + A Φ ′ Φ i , j , k ′ n + A δ P m δ P i , j , k n + A ∇ 2 π ( ∇ 2 π ) i , j , k n + A ∇ 2 Φ ( ∇ 2 Φ ) i , j , k n + A ∇ 2 Ψ ( ∇ 2 Ψ ) i , j , k n ) ] . (27) \zeta_{i,j,k}^{n+\frac{1}{2}}=\frac{1}{1+\left(\frac{A_{\zeta}}{A_{\zeta'}}\right)\left(\frac{\Delta\tau}{2}\right)}
\left[\zeta_{i,j,k}^{n-\frac{1}{2}}-\frac{\Delta\tau}{A_{\zeta'}}\left(\frac{A_{\zeta}\zeta_{i,j,k}^{n-\frac{1}{2}}}{2}+A_{\pi}\pi_{i,j,k}^{n}+A_{\Psi}\Psi_{i,j,k}^{n}+A_{\Phi'}\Phi_{i,j,k}^{\prime n}
+A_{\delta P_m}\delta P_{i,j,k}^{n}+A_{\nabla^2\pi}\left(\nabla^2\pi\right)_{i,j,k}^{n}+A_{\nabla^2\Phi}\left(\nabla^2\Phi\right)_{i,j,k}^{n}+A_{\nabla^2\Psi}\left(\nabla^2\Psi\right)_{i,j,k}^{n}\right)\right]. \tag*{(27)} ζ i , j , k n + 2 1 = 1 + ( A ζ ′ A ζ ) ( 2 Δ τ ) 1 ζ i , j , k n − 2 1 − A ζ ′ Δ τ 2 A ζ ζ i , j , k n − 2 1 + A π π i , j , k n + A Ψ Ψ i , j , k n + A Φ ′ Φ i , j , k ′ n + A δ P m δ P i , j , k n + A ∇ 2 π ( ∇ 2 π ) i , j , k n + A ∇ 2 Φ ( ∇ 2 Φ ) i , j , k n + A ∇ 2 Ψ ( ∇ 2 Ψ ) i , j , k n . (27)
This update is implemented in the function update_zeta in gevolution.hpp. The update for π \pi π follows from the definition of ζ \zeta ζ in Eq. (8) ,
π i , j , k n + 1 = π i , j , k n + π i , j , k ′ n + 1 2 Δ τ = π i , j , k n + [ ζ i , j , k n + 1 2 + Ψ i , j , k n + 1 2 − H n + 1 2 π i , j , k n + 1 + π i , j , k n 2 ] Δ τ = 1 1 + 1 2 H n + 1 2 Δ τ [ π i , j , k n + Δ τ ( ζ i , j , k n + 1 2 + Ψ i , j , k n + 1 2 − 1 2 H n + 1 2 π i , j , k n ) ] . (28) \begin{aligned}
\pi_{i,j,k}^{n+1}=\pi_{i,j,k}^{n}+\pi_{i,j,k}^{\prime n+\frac{1}{2}}\Delta\tau\\
&=\pi_{i,j,k}^{n}+\left[\zeta_{i,j,k}^{n+\frac{1}{2}}+\Psi_{i,j,k}^{n+\frac{1}{2}}-\mathcal{H}^{n+\frac{1}{2}}\frac{\pi_{i,j,k}^{n+1}+\pi_{i,j,k}^{n}}{2}\right]\Delta\tau\\
&=\frac{1}{1+\frac{1}{2}\mathcal{H}^{n+\frac{1}{2}}\Delta\tau}\left[\pi_{i,j,k}^{n}+\Delta\tau\left(\zeta_{i,j,k}^{n+\frac{1}{2}}+\Psi_{i,j,k}^{n+\frac{1}{2}}-\frac{1}{2}\mathcal{H}^{n+\frac{1}{2}}\pi_{i,j,k}^{n}\right)\right]. \tag*{(28)}
\end{aligned} π i , j , k n + 1 = π i , j , k n + π i , j , k ′ n + 2 1 Δ τ = π i , j , k n + [ ζ i , j , k n + 2 1 + Ψ i , j , k n + 2 1 − H n + 2 1 2 π i , j , k n + 1 + π i , j , k n ] Δ τ = 1 + 2 1 H n + 2 1 Δ τ 1 [ π i , j , k n + Δ τ ( ζ i , j , k n + 2 1 + Ψ i , j , k n + 2 1 − 2 1 H n + 2 1 π i , j , k n ) ] . (28)
Here π i , j , k n + 1 2 \pi_{i,j,k}^{n+\frac{1}{2}} π i , j , k n + 2 1 has been replaced using Eq. (8) , with the midpoint value of π \pi π approximated as
π i , j , k n + 1 2 = π i , j , k n + 1 + π i , j , k n 2 . (29) \pi_{i,j,k}^{n+\frac{1}{2}}=\frac{\pi_{i,j,k}^{n+1}+\pi_{i,j,k}^{n}}{2}. \tag*{(29)} π i , j , k n + 2 1 = 2 π i , j , k n + 1 + π i , j , k n . (29)
The midpoint metric potential entering Eq. (28) is evaluated directly in the numerical implementation as
Ψ i , j , k n + 1 2 = Φ i , j , k n − χ i , j , k n + Δ τ 2 ( Ψ ′ ) i , j , k n . (30) \Psi_{i,j,k}^{n+\frac{1}{2}}=\Phi_{i,j,k}^{n}-\chi_{i,j,k}^{n}+\frac{\Delta\tau}{2}\left(\Psi'\right)_{i,j,k}^{n}. \tag*{(30)} Ψ i , j , k n + 2 1 = Φ i , j , k n − χ i , j , k n + 2 Δ τ ( Ψ ′ ) i , j , k n . (30)
Equations (28) and (30) are implemented in the function update_pi in gevolution.hpp.
Metric solver in Fourier space
After the real-space sources have been constructed, the metric equations are solved in Fourier space following the strategy of gevolution. The solver is based on two core equations: the Hamiltonian constraint, which determines the scalar potential Φ \Phi Φ , and the trace-free part of the spatial Einstein equations, which determines the gravitational slip χ = Φ − Ψ \chi= \Phi- \Psi χ = Φ − Ψ , the transverse vector B i B_i B i , and the transverse-traceless tensor h i j h_{ij} h ij .
For clarity, we first summarise the corresponding gevolution metric solver and then introduce the modifications required in Mercury. We follow this structure for both the Hamiltonian constraint and the trace-free spatial equations, which makes the Horndeski contributions transparent relative to the baseline relativistic N N N -body scheme.
Hamiltonian constraint: gevolution scheme
We use the exponential parametrisation of the scalar metric perturbations adopted in the current gevolution formulation. This convention agrees with the original metric parametrisation at linear order but differs from it at higher order. In the weak-field expansion used here, the Hamiltonian constraint is written as
( 1 + 2 Φ ) Δ Φ − 3 H Φ ′ + 3 H 2 ( χ − Φ ) − 1 2 δ i j Φ , i Φ , j = − a 2 2 M P l 2 δ T 0 0 . (31) (1 + 2\Phi)\Delta\Phi- 3\mathcal{H}\Phi' + 3\mathcal{H}^{2}(\chi- \Phi) - \frac{1}{2}\delta^{ij}\Phi_{,i}\Phi_{,j} = -\frac{a^{2}}{2M_{\mathrm{Pl}}^{2}}\delta T^{0}_{0}. \tag*{(31)} ( 1 + 2Φ ) ΔΦ − 3 H Φ ′ + 3 H 2 ( χ − Φ ) − 2 1 δ ij Φ , i Φ , j = − 2 M Pl 2 a 2 δ T 0 0 . (31)
Here δ T 0 0 ≡ T 0 0 − T ‾ 0 0 \delta T^{0}_{0} \equiv T^{0}_{0} - \overline{T}^{0}_{0} δ T 0 0 ≡ T 0 0 − T 0 0 denotes the perturbation of the total energy density component. Equation (31) differs from the purely linear Hamiltonian constraint used in § 2 by the weak-field terms proportional to Φ Δ Φ \Phi\Delta\Phi ΦΔΦ and δ i j Φ , i Φ , j \delta^{ij}\Phi_{,i}\Phi_{,j} δ ij Φ , i Φ , j . These terms are retained in gevolution because the scalar potentials remain small, while their spatial derivatives can become large in the nonlinear regime.
In the numerical implementation, Eq. (31) is not solved directly as a nonlinear parabolic equation. Instead, following the Fourier-space solver of gevolution, it is rearranged into a linear finite-difference equation for the updated potential Φ i , j , k n + 1 \Phi^{n+1}_{i,j,k} Φ i , j , k n + 1 . This is done by dividing by the factor 1 + 2 Φ 1 + 2\Phi 1 + 2Φ and expanding ( 1 + 2 Φ ) − 1 ≃ 1 − 2 Φ (1 + 2\Phi)^{-1} \simeq1 - 2\Phi ( 1 + 2Φ ) − 1 ≃ 1 − 2Φ to the order retained in the weak-field scheme. The Laplacian and time-derivative terms contain the updated potential Φ n + 1 \Phi^{n+1} Φ n + 1 , while the nonlinear geometric corrections and the gravitational slip are evaluated using the known fields at cycle n n n .3 The lattice version of the Hamiltonian constraint can therefore be written as
Φ i − 1 , j , k n + 1 + Φ i + 1 , j , k n + 1 + Φ i , j − 1 , k n + 1 + Φ i , j + 1 , k n + 1 + Φ i , j , k − 1 n + 1 + Φ i , j , k + 1 n + 1 − 6 Φ i , j , k n + 1 d x 2 − 3 H Φ i , j , k n + 1 − Φ i , j , k n d τ \frac{\Phi^{n+1}_{i-1,j,k} + \Phi^{n+1}_{i+1,j,k} + \Phi^{n+1}_{i,j-1,k} + \Phi^{n+1}_{i,j+1,k} + \Phi^{n+1}_{i,j,k-1} + \Phi^{n+1}_{i,j,k+1} - 6\Phi^{n+1}_{i,j,k}}{\mathrm{d}x^{2}} - 3\mathcal{H}\frac{\Phi^{n+1}_{i,j,k} - \Phi^{n}_{i,j,k}}{\mathrm{d}\tau} d x 2 Φ i − 1 , j , k n + 1 + Φ i + 1 , j , k n + 1 + Φ i , j − 1 , k n + 1 + Φ i , j + 1 , k n + 1 + Φ i , j , k − 1 n + 1 + Φ i , j , k + 1 n + 1 − 6 Φ i , j , k n + 1 − 3 H d τ Φ i , j , k n + 1 − Φ i , j , k n
− 3 H 2 ( Φ i , j , k n − χ i , j , k n ) − 1 2 ( Φ i + 1 , j , k n − Φ i − 1 , j , k n ) 2 + ( Φ i , j + 1 , k n − Φ i , j − 1 , k n ) 2 + ( Φ i , j , k + 1 n − Φ i , j , k − 1 n ) 2 4 d x 2 = − a 2 2 M P l 2 ( 1 − 2 Φ i , j , k n ) δ T 0 0 ( τ n + 1 , x i , j , k ) . (32) \begin{aligned}
- 3\mathcal{H}^{2}(\Phi^{n}_{i,j,k} - \chi^{n}_{i,j,k}) - \frac{1}{2}\frac{\left(\Phi^{n}_{i+1,j,k} - \Phi^{n}_{i-1,j,k}\right)^{2} + \left(\Phi^{n}_{i,j+1,k} - \Phi^{n}_{i,j-1,k}\right)^{2} + \left(\Phi^{n}_{i,j,k+1} - \Phi^{n}_{i,j,k-1}\right)^{2}}{4\mathrm{d}x^{2}} \\
&= -\frac{a^{2}}{2M_{\mathrm{Pl}}^{2}}\left(1 - 2\Phi^{n}_{i,j,k}\right)\delta T^{0}_{0}(\tau_{n+1},x_{i,j,k}). \tag*{(32)}
\end{aligned} − 3 H 2 ( Φ i , j , k n − χ i , j , k n ) − 2 1 4 d x 2 ( Φ i + 1 , j , k n − Φ i − 1 , j , k n ) 2 + ( Φ i , j + 1 , k n − Φ i , j − 1 , k n ) 2 + ( Φ i , j , k + 1 n − Φ i , j , k − 1 n ) 2 = − 2 M Pl 2 a 2 ( 1 − 2 Φ i , j , k n ) δ T 0 0 ( τ n + 1 , x i , j , k ) . (32)
To solve Eq. (32) numerically, gevolution rewrites the constraint as an equation for the new grid field Φ n + 1 \Phi^{n+1} Φ n + 1 . The terms involving Φ n + 1 \Phi^{n+1} Φ n + 1 are kept as the left-hand side of the update equation. The remaining metric terms are evaluated explicitly using the fields at cycle n n n , while the total stress–energy perturbation is constructed at τ n + 1 \tau_{n+1} τ n + 1 . Moving these known terms to the right-hand side, the source is defined as
s i , j , k ≡ 3 H 2 ( Φ i , j , k n − χ i , j , k n ) + 1 8 d x 2 ( Φ i + 1 , j , k n − Φ i − 1 , j , k n ) 2 + 1 8 d x 2 ( Φ i , j + 1 , k n − Φ i , j − 1 , k n ) 2 + 1 8 d x 2 ( Φ i , j , k + 1 n − Φ i , j , k − 1 n ) 2 − 3 H d τ Φ i , j , k n − a 2 2 M P l 2 ( 1 − 2 Φ i , j , k n ) δ T 0 0 ( τ n + 1 , x i , j , k ) . (33) s_{i,j,k} \equiv3\mathcal{H}^{2}\left(\Phi^{n}_{i,j,k}-\chi^{n}_{i,j,k}\right)+\frac{1}{8\mathrm{d}x^{2}}\left(\Phi^{n}_{i+1,j,k}-\Phi^{n}_{i-1,j,k}\right)^{2}+\frac{1}{8\mathrm{d}x^{2}}\left(\Phi^{n}_{i,j+1,k}-\Phi^{n}_{i,j-1,k}\right)^{2}
+\frac{1}{8\mathrm{d}x^{2}}\left(\Phi^{n}_{i,j,k+1}-\Phi^{n}_{i,j,k-1}\right)^{2}-\frac{3\mathcal{H}}{\mathrm{d}\tau}\Phi^{n}_{i,j,k}-\frac{a^{2}}{2M_{\mathrm{Pl}}^{2}}\left(1-2\Phi^{n}_{i,j,k}\right)\delta T^{0}_{0}(\tau_{n+1},\mathbf{x}_{i,j,k}) . \tag*{(33)} s i , j , k ≡ 3 H 2 ( Φ i , j , k n − χ i , j , k n ) + 8 d x 2 1 ( Φ i + 1 , j , k n − Φ i − 1 , j , k n ) 2 + 8 d x 2 1 ( Φ i , j + 1 , k n − Φ i , j − 1 , k n ) 2 + 8 d x 2 1 ( Φ i , j , k + 1 n − Φ i , j , k − 1 n ) 2 − d τ 3 H Φ i , j , k n − 2 M Pl 2 a 2 ( 1 − 2 Φ i , j , k n ) δ T 0 0 ( τ n + 1 , x i , j , k ) . (33)
The Hamiltonian constraint is therefore reduced to the linear implicit equation for Φ n + 1 \Phi^{n+1} Φ n + 1
Φ i − 1 , j , k n + 1 + Φ i + 1 , j , k n + 1 + Φ i , j − 1 , k n + 1 + Φ i , j + 1 , k n + 1 + Φ i , j , k − 1 n + 1 + Φ i , j , k + 1 n + 1 − 6 Φ i , j , k n + 1 d x 2 − 3 H d τ Φ i , j , k n + 1 = s i , j , k . (34) \frac{\Phi^{n+1}_{i-1,j,k}+\Phi^{n+1}_{i+1,j,k}+\Phi^{n+1}_{i,j-1,k}+\Phi^{n+1}_{i,j+1,k}+\Phi^{n+1}_{i,j,k-1}+\Phi^{n+1}_{i,j,k+1}-6\Phi^{n+1}_{i,j,k}}{\mathrm{d}x^{2}}-\frac{3\mathcal{H}}{\mathrm{d}\tau}\Phi^{n+1}_{i,j,k}=s_{i,j,k}. \tag*{(34)} d x 2 Φ i − 1 , j , k n + 1 + Φ i + 1 , j , k n + 1 + Φ i , j − 1 , k n + 1 + Φ i , j + 1 , k n + 1 + Φ i , j , k − 1 n + 1 + Φ i , j , k + 1 n + 1 − 6 Φ i , j , k n + 1 − d τ 3 H Φ i , j , k n + 1 = s i , j , k . (34)
Because the grid is periodic, the Fourier transform is the natural way to solve this equation. It rewrites the grid field as a sum of Fourier modes, and each mode can then be solved separately for Φ n + 1 \Phi^{n+1} Φ n + 1 . The source field s i , j , k s_{i,j,k} s i , j , k is therefore first transformed to Fourier space. For a grid with N N N points in each spatial direction, the transform is defined as
s ~ u , v , w ≡ ∑ i , j , k s i , j , k e − 2 π i ( i u + j v + k w ) / N . (35) \widetilde{s}_{u,v,w}\equiv\sum_{i,j,k}s_{i,j,k}e^{-2\pi\mathrm{i}(iu+jv+kw)/N}. \tag*{(35)} s u , v , w ≡ i , j , k ∑ s i , j , k e − 2 π i ( i u + j v + k w ) / N . (35)
Here i , j , k i,j,k i , j , k label the real-space lattice point, while u , v , w u,v,w u , v , w label the Fourier mode. The full lattice contains N 3 N^{3} N 3 grid points.
Applying the same Fourier transform to Eq. (34) , the finite-difference equation becomes an algebraic equation for each Fourier mode,
− [ 4 d x 2 sin 2 ( π u N ) + 4 d x 2 sin 2 ( π v N ) + 4 d x 2 sin 2 ( π w N ) + 3 H d τ ] Φ ~ u , v , w n + 1 = s ~ u , v , w . (36) -\left[\frac{4}{\mathrm{d}x^{2}}\sin^{2}\left(\frac{\pi u}{N}\right)+\frac{4}{\mathrm{d}x^{2}}\sin^{2}\left(\frac{\pi v}{N}\right)+\frac{4}{\mathrm{d}x^{2}}\sin^{2}\left(\frac{\pi w}{N}\right)+\frac{3\mathcal{H}}{\mathrm{d}\tau}\right]\widetilde{\Phi}^{n+1}_{u,v,w}=\widetilde{s}_{u,v,w}. \tag*{(36)} − [ d x 2 4 sin 2 ( N π u ) + d x 2 4 sin 2 ( N π v ) + d x 2 4 sin 2 ( N π w ) + d τ 3 H ] Φ u , v , w n + 1 = s u , v , w . (36)
This equation contains only one unknown quantity for each mode, namely Φ ~ u , v , w n + 1 \widetilde{\Phi}^{n+1}_{u,v,w} Φ u , v , w n + 1 . The updated potential is therefore obtained by dividing the transformed source s ~ u , v , w \widetilde{s}_{u,v,w} s u , v , w by the factor multiplying Φ ~ u , v , w n + 1 \widetilde{\Phi}^{n+1}_{u,v,w} Φ u , v , w n + 1 .
Hamiltonian constraint: Mercury modifications
In Mercury, the numerical rearrangement of the Hamiltonian constraint and the Fourier-space inversion remain unchanged. The modification enters through the source term. In addition to the matter contribution already present in gevolution, the scalar-field contribution constructed on the real-space lattice, Eq. (21) , is added to the source. At the same time, the constant Planck mass M P l 2 M_{\mathrm{Pl}}^{2} M Pl 2 appearing in the gevolution source is replaced by the time-dependent cosmological Planck mass M e f f 2 M_{\mathrm{eff}}^{2} M eff 2 . This gives
− a 2 2 M P l 2 ( 1 − 2 Φ i , j , k n ) δ T 0 0 ⟶ − a 2 2 M e f f 2 ( 1 − 2 Φ i , j , k n ) [ δ T 0 0 ( m ) + δ T 0 0 ( φ ) ] . (37) -\frac{a^{2}}{2M_{\mathrm{Pl}}^{2}}\left(1-2\Phi^{n}_{i,j,k}\right)\delta T^{0}_{0}\longrightarrow-\frac{a^{2}}{2M_{\mathrm{eff}}^{2}}\left(1-2\Phi^{n}_{i,j,k}\right)\left[\delta T^{0(\mathrm{m})}_{0}+\delta T^{0(\varphi)}_{0}\right]. \tag*{(37)} − 2 M Pl 2 a 2 ( 1 − 2 Φ i , j , k n ) δ T 0 0 ⟶ − 2 M eff 2 a 2 ( 1 − 2 Φ i , j , k n ) [ δ T 0 0 ( m ) + δ T 0 0 ( φ ) ] . (37)
Trace-free equation: gevolution scheme
After updating Φ \Phi Φ , the remaining metric perturbations are obtained from the trace-free part of the spatial Einstein equations. In the gevolution implementation used here, these equations take the form
( δ k i δ l j − 1 3 δ i j δ k l ) [ 1 2 h i j ′ ′ + H h i j ′ − 1 2 ∇ 2 h i j + B ( i , j ) ′ + 2 H B ( i , j ) + χ , i j − 2 Φ , i Φ , j ] = a 2 M P l 2 ( δ k i δ l j − 1 3 δ i j δ k l ) δ m i T j m = a 2 M P l 2 Π k l . (38) \left(\delta^{i}_{k}\delta^{j}_{l}-\frac{1}{3}\delta^{ij}\delta_{kl}\right)\left[\frac{1}{2}h^{\prime\prime}_{ij}+\mathcal{H}h^{\prime}_{ij}-\frac{1}{2}\nabla^{2}h_{ij}+B^{\prime}_{(i,j)}+2\mathcal{H}B_{(i,j)}+\chi_{,ij}-2\Phi_{,i}\Phi_{,j}\right]
=\frac{a^{2}}{M_{\mathrm{Pl}}^{2}}\left(\delta^{i}_{k}\delta^{j}_{l}-\frac{1}{3}\delta^{ij}\delta_{kl}\right)\delta_{mi}T^{m}_{j}=\frac{a^{2}}{M_{\mathrm{Pl}}^{2}}\Pi_{kl}. \tag*{(38)} ( δ k i δ l j − 3 1 δ ij δ k l ) [ 2 1 h ij ′′ + H h ij ′ − 2 1 ∇ 2 h ij + B ( i , j ) ′ + 2 H B ( i , j ) + χ , ij − 2 Φ , i Φ , j ] = M Pl 2 a 2 ( δ k i δ l j − 3 1 δ ij δ k l ) δ mi T j m = M Pl 2 a 2 Π k l . (38)
Equation (38) already incorporates the approximation adopted in the solver. A more complete weak-field expression, retaining all second-order terms in the scalar metric potentials, is given in [14 ] . When written in terms of χ = Φ − Ψ \chi= \Phi- \Psi χ = Φ − Ψ , this expression contains additional nonlinear terms involving χ \chi χ , which are neglected here, while the linear contribution χ , i j \chi_{,ij} χ , ij and the quadratic term in Φ \Phi Φ are retained. These omitted terms are second order in the metric perturbations and are subdominant when the anisotropic stress provides the leading source of the trace-free metric perturbations [14 ] .
Following the same strategy as for the Hamiltonian constraint, the nonlinear term built from the already known scalar potential is moved to the source. Equation (38) can therefore be rearranged as
( δ k i δ l j − 1 3 δ i j δ k l ) [ 1 2 h i j ′ ′ + H h i j ′ − 1 2 ∇ 2 h i j + B ( i , j ) ′ + 2 H B ( i , j ) + χ , i j ] = ( δ k i δ l j − 1 3 δ i j δ k l ) [ a 2 M P l 2 δ m i T j m + 2 Φ , i Φ , j ] . (39) \left(\delta^i_k\delta^j_l-\frac{1}{3}\delta^{ij}\delta_{kl}\right)\left[\frac{1}{2}h''_{ij}+\mathcal{H}h'_{ij}-\frac{1}{2}\nabla^2h_{ij}+B'_{(i,j)}+2\mathcal{H}B_{(i,j)}+\chi_{,ij}\right]
=
\left(\delta^i_k\delta^j_l-\frac{1}{3}\delta^{ij}\delta_{kl}\right)\left[\frac{a^2}{M_{\mathrm{Pl}}^2}\delta^i_m T^m_j+2\Phi_{,i}\Phi_{,j}\right]. \tag*{(39)} ( δ k i δ l j − 3 1 δ ij δ k l ) [ 2 1 h ij ′′ + H h ij ′ − 2 1 ∇ 2 h ij + B ( i , j ) ′ + 2 H B ( i , j ) + χ , ij ] = ( δ k i δ l j − 3 1 δ ij δ k l ) [ M Pl 2 a 2 δ m i T j m + 2 Φ , i Φ , j ] . (39)
The quantity inside the second set of brackets is then identified as the source tensor,
S i j ≡ a 2 M P l 2 δ m i T j m + 2 Φ , i Φ , j . (40) S_{ij}\equiv\frac{a^2}{M_{\mathrm{Pl}}^2}\delta^i_m T^m_j+2\Phi_{,i}\Phi_{,j}. \tag*{(40)} S ij ≡ M Pl 2 a 2 δ m i T j m + 2 Φ , i Φ , j . (40)
The source tensor S i j S_{ij} S ij must be constructed at the correct positions on the lattice. Scalar quantities such as Φ \Phi Φ are stored at the vertices of the grid, and the diagonal components of a spatial tensor are also evaluated at the vertices. The components of vector fields are associated with the edges, while the off-diagonal components of a spatial tensor are evaluated on the faces of the lattice cells. The finite-difference operators used in S i j S_{ij} S ij are therefore chosen so that all terms contributing to a given component are evaluated at the same lattice position.
For a diagonal component, all terms are evaluated at the vertex x i , j , k \mathbf{x}_{i,j,k} x i , j , k . For example,
S 11 ( x i , j , k ) ≡ a 2 M P l 2 T 1 1 ( τ n + 1 , x i , j , k ) + ( Φ i + 1 , j , k n + 1 − Φ i − 1 , j , k n + 1 ) 2 2 d x 2 . (41) S_{11}\left(\mathbf{x}_{i,j,k}\right)\equiv\frac{a^2}{M_{\mathrm{Pl}}^2}T^1_1\left(\tau_{n+1},\mathbf{x}_{i,j,k}\right)+\frac{\left(\Phi^{n+1}_{i+1,j,k}-\Phi^{n+1}_{i-1,j,k}\right)^2}{2\mathrm{d}x^2}. \tag*{(41)} S 11 ( x i , j , k ) ≡ M Pl 2 a 2 T 1 1 ( τ n + 1 , x i , j , k ) + 2 d x 2 ( Φ i + 1 , j , k n + 1 − Φ i − 1 , j , k n + 1 ) 2 . (41)
The second term is the lattice representation of 2 Φ , 1 Φ , 1 2\Phi_{,1}\Phi_{,1} 2 Φ , 1 Φ , 1 at the same vertex.
For an off-diagonal component, the source is evaluated at the corresponding face of the lattice cell. For example, S 12 S_{12} S 12 is evaluated at x i + 1 2 , j + 1 2 , k \mathbf{x}_{i+\frac{1}{2},j+\frac{1}{2},k} x i + 2 1 , j + 2 1 , k , and is written as
S 12 ( x i + 1 2 , j + 1 2 , k ) ≡ a 2 M P l 2 T 2 1 ( τ n + 1 , x i + 1 2 , j + 1 2 , k ) + 1 2 Φ i + 1 , j + 1 , k n + 1 − Φ i , j + 1 , k n + 1 + Φ i + 1 , j , k n + 1 − Φ i , j , k n + 1 d x × Φ i + 1 , j + 1 , k n + 1 − Φ i + 1 , j , k n + 1 + Φ i , j + 1 , k n + 1 − Φ i , j , k n + 1 d x . (42) \begin{aligned}
S_{12}\left(\mathbf{x}_{i+\frac{1}{2},j+\frac{1}{2},k}\right)\equiv{}&\frac{a^2}{M_{\mathrm{Pl}}^2}T^1_2\left(\tau_{n+1},\mathbf{x}_{i+\frac{1}{2},j+\frac{1}{2},k}\right)\\
&+\frac{1}{2}\frac{\Phi^{n+1}_{i+1,j+1,k}-\Phi^{n+1}_{i,j+1,k}+\Phi^{n+1}_{i+1,j,k}-\Phi^{n+1}_{i,j,k}}{\mathrm{d}x}\\
&\qquad\times\frac{\Phi^{n+1}_{i+1,j+1,k}-\Phi^{n+1}_{i+1,j,k}+\Phi^{n+1}_{i,j+1,k}-\Phi^{n+1}_{i,j,k}}{\mathrm{d}x}. \tag*{(42)}
\end{aligned} S 12 ( x i + 2 1 , j + 2 1 , k ) ≡ M Pl 2 a 2 T 2 1 ( τ n + 1 , x i + 2 1 , j + 2 1 , k ) + 2 1 d x Φ i + 1 , j + 1 , k n + 1 − Φ i , j + 1 , k n + 1 + Φ i + 1 , j , k n + 1 − Φ i , j , k n + 1 × d x Φ i + 1 , j + 1 , k n + 1 − Φ i + 1 , j , k n + 1 + Φ i , j + 1 , k n + 1 − Φ i , j , k n + 1 . (42)
The second term in Eq. (42) represents 2 Φ , 1 Φ , 2 2\Phi_{,1}\Phi_{,2} 2 Φ , 1 Φ , 2 , with both gradients evaluated at the same face. The other components of S i j S_{ij} S ij are constructed in the same way.
With this definition, the trace-free equation becomes
1 2 h i j ′ ′ + H h i j ′ − 1 2 ∇ 2 h i j + B ( i , j ) ′ + 2 H B ( i , j ) + χ , i j − 1 3 δ i j ∇ 2 χ = S i j − 1 3 δ i j δ k l S k l . (43) \frac{1}{2}h''_{ij}+\mathcal{H}h'_{ij}-\frac{1}{2}\nabla^2h_{ij}+B'_{(i,j)}+2\mathcal{H}B_{(i,j)}+\chi_{,ij}-\frac{1}{3}\delta_{ij}\nabla^2\chi=S_{ij}-\frac{1}{3}\delta_{ij}\delta^{kl}S_{kl}. \tag*{(43)} 2 1 h ij ′′ + H h ij ′ − 2 1 ∇ 2 h ij + B ( i , j ) ′ + 2 H B ( i , j ) + χ , ij − 3 1 δ ij ∇ 2 χ = S ij − 3 1 δ ij δ k l S k l . (43)
The trace-free spatial equation is solved in Fourier space by decomposing the source tensor into its scalar, vector and tensor parts. We first write the projection formulae in continuum Fourier notation. Defining the transverse projector
P j i = δ j i − k i k j k 2 , (44) P^{i}_{j} = \delta^{i}_{j} - \frac{k^{i}k_{j}}{k^{2}}, \tag*{(44)} P j i = δ j i − k 2 k i k j , (44)
the scalar projection gives the gravitational slip,
χ ~ ( k ) = 1 2 k 2 ( δ i j − 3 k i k j k 2 ) S ~ i j ( k ) . (45) \tilde{\chi}(\mathbf{k}) = \frac{1}{2k^{2}}\left(\delta^{ij} - 3\frac{k^{i}k^{j}}{k^{2}}\right)\tilde{S}_{ij}(\mathbf{k}). \tag*{(45)} χ ~ ( k ) = 2 k 2 1 ( δ ij − 3 k 2 k i k j ) S ~ ij ( k ) . (45)
The vector projection gives the transverse frame-dragging equation,
B ~ i ′ ( k ) + 2 H B ~ i ( k ) = 1 a 2 ( a 2 B ~ i ( k ) ) ′ = − 2 i k 2 P i p k j k l S ~ j l ( k ) . (46) \tilde{B}'_{i}(\mathbf{k}) + 2\mathcal{H}\tilde{B}_{i}(\mathbf{k}) = \frac{1}{a^{2}}\left(a^{2}\tilde{B}_{i}(\mathbf{k})\right)' = -\frac{2\mathrm{i}}{k^{2}}P^{p}_{i}k^{j}k^{l}\tilde{S}_{jl}(\mathbf{k}). \tag*{(46)} B ~ i ′ ( k ) + 2 H B ~ i ( k ) = a 2 1 ( a 2 B ~ i ( k ) ) ′ = − k 2 2 i P i p k j k l S ~ j l ( k ) . (46)
Finally, the tensor projection gives the transverse-traceless tensor equation,
h ~ i j ′ ′ ( k ) + 2 H h ~ i j ′ ( k ) + k 2 h ~ i j ( k ) = 2 ( P i l P j m − 1 2 P i j P l m ) S ~ l m ( k ) . (47) \tilde{h}''_{ij}(\mathbf{k}) + 2\mathcal{H}\tilde{h}'_{ij}(\mathbf{k}) + k^{2}\tilde{h}_{ij}(\mathbf{k}) = 2\left(P^{l}_{i}P^{m}_{j} - \frac{1}{2}P_{ij}P^{lm}\right)\tilde{S}_{lm}(\mathbf{k}). \tag*{(47)} h ~ ij ′′ ( k ) + 2 H h ~ ij ′ ( k ) + k 2 h ~ ij ( k ) = 2 ( P i l P j m − 2 1 P ij P l m ) S ~ l m ( k ) . (47)
On the lattice these equations are implemented using discrete Fourier modes. For diagonal components, which are evaluated at the vertices, the Fourier transform is
S ~ 11 ( u , v , w ) ≡ ∑ i , j , k S 11 ( x i , j , k ) e − 2 π i ( i u + j v + k w ) / N . (48) \tilde{S}_{11}(\mathbf{u},\mathbf{v},\mathbf{w}) \equiv\sum_{i,j,k} S_{11}(x_{i,j,k})e^{-2\pi\mathrm{i}(iu+jv+kw)/N}. \tag*{(48)} S ~ 11 ( u , v , w ) ≡ i , j , k ∑ S 11 ( x i , j , k ) e − 2 π i ( i u + j v + k w ) / N . (48)
For off-diagonal components, which are evaluated on the faces of the lattice cells, an additional phase factor accounts for the half-cell displacement. For example,
S ~ 12 ( u , v , w ) ≡ e − π i u / N e − π i v / N ∑ i , j , k S 12 ( x i + 1 2 , j + 1 2 , k ) e − 2 π i ( i u + j v + k w ) / N . (49) \tilde{S}_{12}(\mathbf{u},\mathbf{v},\mathbf{w}) \equiv e^{-\pi\mathrm{i}u/N}e^{-\pi\mathrm{i}v/N}\sum_{i,j,k}S_{12}\left(x_{i+\frac{1}{2},j+\frac{1}{2},k}\right)e^{-2\pi\mathrm{i}(iu+jv+kw)/N}. \tag*{(49)} S ~ 12 ( u , v , w ) ≡ e − π i u / N e − π i v / N i , j , k ∑ S 12 ( x i + 2 1 , j + 2 1 , k ) e − 2 π i ( i u + j v + k w ) / N . (49)
The remaining components are transformed analogously. Following gevolution, the lattice momentum associated with the mode ( u , v , w ) (u,v,w) ( u , v , w ) is defined as
( k u , v , w 1 , k u , v , w 2 , k u , v , w 3 ) ≡ ( 2 d x sin π u N , 2 d x sin π v N , 2 d x sin π w N ) . (50) \left(k^{1}_{u,v,w},k^{2}_{u,v,w},k^{3}_{u,v,w}\right) \equiv\left(\frac{2}{\mathrm{d}x}\sin\frac{\pi u}{N},\frac{2}{\mathrm{d}x}\sin\frac{\pi v}{N},\frac{2}{\mathrm{d}x}\sin\frac{\pi w}{N}\right). \tag*{(50)} ( k u , v , w 1 , k u , v , w 2 , k u , v , w 3 ) ≡ ( d x 2 sin N π u , d x 2 sin N π v , d x 2 sin N π w ) . (50)
The discrete version of Eqs. (45) –(47) is then obtained by making the replacements
S ~ i j ( k ) ⟶ S ~ i j ( u , v , w ) , k i ⟶ k u , v , w i , k 2 ⟶ δ i j k u , v , w i k u , v , w j . (51) \tilde{S}_{ij}(\mathbf{k}) \longrightarrow\tilde{S}_{ij}(\mathbf{u},\mathbf{v},\mathbf{w}), \qquad k^{i} \longrightarrow k^{i}_{u,v,w}, \qquad k^{2} \longrightarrow\delta_{ij}k^{i}_{u,v,w}k^{j}_{u,v,w}. \tag*{(51)} S ~ ij ( k ) ⟶ S ~ ij ( u , v , w ) , k i ⟶ k u , v , w i , k 2 ⟶ δ ij k u , v , w i k u , v , w j . (51)
Thus the same Fourier-space source tensor S ~ i j ( u , v , w ) \tilde{S}_{ij}(\mathbf{u},\mathbf{v},\mathbf{w}) S ~ ij ( u , v , w ) is used to obtain χ \chi χ , B i B_i B i and h i j h_{ij} h ij through the scalar, vector and tensor projections.
Trace-free equation: Mercury modifications
In Mercury, the scalar, vector and tensor projectors retain the same form as in gevolution. The modifications enter through the source tensor and through the time-dependent coefficients governing the vector and tensor evolution. The source tensor becomes
S i j ⟶ S i j M e r c u r y ≡ a 2 M e f f 2 [ δ m i T j m ( m ) + Π i j ( ϕ ) ] + 2 Φ , i Φ , j . (52) S_{ij} \longrightarrow S^{\mathrm{Mercury}}_{ij} \equiv\frac{a^{2}}{M_{\mathrm{eff}}^{2}}\left[\delta_{mi}T^{m(\mathrm{m})}_{j}+\Pi^{(\phi)}_{ij}\right]+2\Phi_{,i}\Phi_{,j}. \tag*{(52)} S ij ⟶ S ij Mercury ≡ M eff 2 a 2 [ δ mi T j m ( m ) + Π ij ( ϕ ) ] + 2 Φ , i Φ , j . (52)
The Horndeski anisotropic stress Π i j ( ϕ ) \Pi_{ij}^{(\phi)} Π ij ( ϕ ) is trace-free and has purely scalar form, being proportional to D i j ≡ ∂ i ∂ j − 1 3 δ i j ∇ 2 D_{ij} \equiv\partial_i\partial_j - \frac{1}{3}\delta_{ij}\nabla^2 D ij ≡ ∂ i ∂ j − 3 1 δ ij ∇ 2 acting on a scalar quantity. It therefore contributes directly to the scalar projection determining the gravitational slip, while its vector and tensor projections vanish at linear order. The scalar projection consequently keeps the same algebraic form as in gevolution,
χ ~ ( k ) = 1 2 k 2 ( δ i j − 3 k i k j k 2 ) S ~ i j M e r c u r y ( k ) . (53) \tilde{\chi}(\mathbf{k}) = \frac{1}{2k^2}\left(\delta^{ij} - 3\frac{k^i k^j}{k^2}\right)\tilde{S}^{\mathrm{Mercury}}_{ij}(\mathbf{k}). \tag*{(53)} χ ~ ( k ) = 2 k 2 1 ( δ ij − 3 k 2 k i k j ) S ~ ij Mercury ( k ) . (53)
For the vector mode, the running of the effective Planck mass modifies the damping term. Using α M = ( M ∗ 2 ) ′ / ( H M ∗ 2 ) \alpha_{\mathrm{M}} = (M_*^2)'/(\mathcal{H}M_*^2) α M = ( M ∗ 2 ) ′ / ( H M ∗ 2 ) , the vector equation becomes
1 a 2 M ∗ 2 ( a 2 M ∗ 2 B ~ i ( k ) ) ′ = B ~ i ′ ( k ) + ( 2 + α M ) H B ~ i ( k ) = − 2 i k 2 P i j k l S ~ j l M e r c u r y ( k ) . (54) \frac{1}{a^2M_*^2}\left(a^2M_*^2\tilde{B}_i(\mathbf{k})\right)' = \tilde{B}'_i(\mathbf{k}) + (2+\alpha_{\mathrm{M}})\mathcal{H}\tilde{B}_i(\mathbf{k}) = -\frac{2\mathrm{i}}{k^2}P_i{}^j k^l\tilde{S}^{\mathrm{Mercury}}_{jl}(\mathbf{k}). \tag*{(54)} a 2 M ∗ 2 1 ( a 2 M ∗ 2 B ~ i ( k ) ) ′ = B ~ i ′ ( k ) + ( 2 + α M ) H B ~ i ( k ) = − k 2 2 i P i j k l S ~ j l Mercury ( k ) . (54)
Similarly, the tensor equation is modified by both the running of the effective Planck mass and the tensor-speed excess,
1 a 2 M ∗ 2 ( a 2 M ∗ 2 h ~ i j ′ ′ ( k ) ) ′ + ( 1 + α T ) k 2 h ~ i j ( k ) = 2 ( P l i P m j − 1 2 P i j P l m ) S ~ l m M e r c u r y ( k ) . (55) \frac{1}{a^2M_*^2}\left(a^2M_*^2\tilde{h}_{ij}''(\mathbf{k})\right)' + (1+\alpha_{\mathrm{T}})k^2\tilde{h}_{ij}(\mathbf{k}) = 2\left(P_l{}^iP_m{}^j-\frac{1}{2}P_{ij}P^{lm}\right)\tilde{S}^{\mathrm{Mercury}}_{lm}(\mathbf{k}). \tag*{(55)} a 2 M ∗ 2 1 ( a 2 M ∗ 2 h ~ ij ′′ ( k ) ) ′ + ( 1 + α T ) k 2 h ~ ij ( k ) = 2 ( P l i P m j − 2 1 P ij P l m ) S ~ l m Mercury ( k ) . (55)
Equivalently, its left-hand side is
h ~ i j ′ ′ ( k ) + ( 2 + α M ) H h ~ i j ′ ( k ) + ( 1 + α T ) k 2 h ~ i j ( k ) . (56) \tilde{h}_{ij}''(\mathbf{k}) + (2+\alpha_{\mathrm{M}})\mathcal{H}\tilde{h}_{ij}'(\mathbf{k}) + (1+\alpha_{\mathrm{T}})k^2\tilde{h}_{ij}(\mathbf{k}). \tag*{(56)} h ~ ij ′′ ( k ) + ( 2 + α M ) H h ~ ij ′ ( k ) + ( 1 + α T ) k 2 h ~ ij ( k ) . (56)
The discrete implementation follows the same Fourier transforms, lattice momenta and projection operators as in gevolution, with S ~ i j \tilde{S}_{ij} S ~ ij replaced by S ~ i j M e r c u r y \tilde{S}^{\mathrm{Mercury}}_{ij} S ~ ij Mercury .
Numerical workflow of Mercury
This section describes the numerical workflow of Mercury, from the specification of the Horndeski model and the construction of the initial conditions to the main simulation loop. We organise the procedure into three stages, summarised schematically in Figure 1 and discussed in the following subsections.
Figure 1. Schematic overview of the Mercury workflow.
Stage I: Model specification and background calculation
The implementation in Mercury separates the relativistic N N N -body evolution from the specification of the underlying Horndeski model. The metric and scalar-field equations evolved by Mercury are written in terms of the α \alpha α functions α K \alpha_{\mathrm{K}} α K , α B \alpha_{\mathrm{B}} α B , α M \alpha_{\mathrm{M}} α M and α T \alpha_{\mathrm{T}} α T , together with the effective Planck mass M ∗ 2 M_*^2 M ∗ 2 and the corresponding background quantities. These are computed by hi_class, which provides the interface between the model specified by the user and the background and perturbation quantities required by the simulation. As a consequence, any model implemented in hi_class can be run natively in Mercury, and the implementation of new models requires modifications only to hi_class.4
Two input workflows are supported. In the effective-theory approach , the background expansion and the time dependence of the α \alpha α functions are specified phenomenologically. In the covariant-theory approach , the model is instead defined through a Horndeski action, from which hi_class derives the background evolution and the corresponding α \alpha α functions. Once these quantities have been computed and passed to Mercury, the subsequent simulation evolution is independent of how the model was specified. The two input workflows are described separately below.
A common part of both workflows is the treatment of the present-day fractional density of the scalar sector, controlled in hi_class by the parameter Omega_smg. Three cases are possible:
0 < 0 < 0 < Omega_smg< 1 < 1 < 1 : the scalar sector is active and its present-day fractional density is specified directly. Either Ω Λ , 0 \Omega_{\Lambda,0} Ω Λ , 0 or Ω f l d , 0 \Omega_{\mathrm{fld},0} Ω fld , 0 must be left unspecified, and the remaining component is determined from the closure relation5
∑ i Ω i , 0 = 1. (57) \sum_i \Omega_{i,0} = 1 . \tag*{(57)} i ∑ Ω i , 0 = 1. (57)
Omega_smg< 0 < 0 < 0 : the scalar sector remains active, but its present-day fractional density is determined internally from the closure relation. In this case, both Ω Λ , 0 \Omega_{\Lambda,0} Ω Λ , 0 and Ω f l d , 0 \Omega_{\mathrm{fld},0} Ω fld , 0 must be specified.
For the simulations presented in this work, we set Omega_smg = − 1 = -1 = − 1 together with Ω Λ , 0 = Ω f l d , 0 = 0 \Omega_{\Lambda,0} = \Omega_{\mathrm{fld},0} = 0 Ω Λ , 0 = Ω fld , 0 = 0 . The present-day scalar-sector density is therefore determined by hi_class from Eq. (57) .
Effective theory approach
In this mode, the background expansion and the linear Horndeski perturbation sector are specified independently. The background history is selected through expansion_model, while the time dependence of the Horndeski α \alpha α functions is selected separately through gravity_model. Consequently, different choices of α i ( a ) \alpha_i(a) α i ( a ) may be combined with the same expansion history, and conversely the same α \alpha α -function parametrisation may be evaluated for different background histories. For the examples considered in this paper, the relevant hi_class input parameters are summarised in Table 1 . The input Omega_smg fixes the target present-day scalar-sector density, either explicitly or through the closure relation. To reproduce this target, hi_class adjusts the entry of expansion_smg selected by tuning_index_smg. If Ω s m g , 0 \Omega_{\mathrm{smg},0} Ω smg , 0 is selected for tuning, its supplied value is overwritten.
Table 1. Relevant hi_class input options for the parametrised Horndeski models used here.
Background workflow: Once the present-day abundance has been fixed, the background evolution is constructed according to the selected expansion_model. For the simulations shown in this work, we use the wowa option, adopting the Chevallier–Polarski–Linder (CPL) parametrisation of the scalar-sector equation of state [29 , 30 ] ,
w ϕ ( a ) = w 0 + w a ( 1 − a ) . (58) w_{\phi}(a) = w_0 + w_a(1-a). \tag*{(58)} w ϕ ( a ) = w 0 + w a ( 1 − a ) . (58)
The parameters Ω s m g , 0 \Omega_{\mathrm{smg},0} Ω smg , 0 , w 0 w_0 w 0 , and w a w_a w a are specified through expansion_smg. The present-day abundance fixes the normalisation of the scalar-sector density, while w 0 w_0 w 0 and w a w_a w a determine its evolution. Integrating the corresponding conservation equation gives
ρ ˉ ϕ ( a ) = ρ ˉ ϕ , 0 a − 3 ( 1 + w 0 + w a ) exp [ 3 w a ( a − 1 ) ] . (59) \bar{\rho}_{\phi}(a) = \bar{\rho}_{\phi,0} a^{-3(1+w_0+w_a)} \exp[3w_a(a-1)]. \tag*{(59)} ρ ˉ ϕ ( a ) = ρ ˉ ϕ , 0 a − 3 ( 1 + w 0 + w a ) exp [ 3 w a ( a − 1 )] . (59)
The corresponding pressure is P ˉ ϕ = w ϕ ρ ˉ ϕ \bar{P}_{\phi}=w_{\phi}\bar{\rho}_{\phi} P ˉ ϕ = w ϕ ρ ˉ ϕ , while ρ ˉ ϕ ′ \bar{\rho}'_{\phi} ρ ˉ ϕ ′ follows the conservation equation. No explicit evolution of the homogeneous scalar field ϕ ˉ \bar{\phi} ϕ ˉ is required in this mode, since the background scalar sector is specified directly through its effective density, pressure, and equation of state.
The α \alpha α functions are specified independently through gravity_model. For the propto_omega parametrisation used in this work, they follow the fractional dark-energy density,
α i ( a ) = α ^ i Ω s m g ( a ) , i ∈ { K , B , M , T } . (60) \alpha_i(a) = \hat{\alpha}_i \Omega_{\mathrm{smg}}(a), \qquad i \in\{K, B, M, T\}. \tag*{(60)} α i ( a ) = α ^ i Ω smg ( a ) , i ∈ { K , B , M , T } . (60)
The coefficients α ^ K \hat{\alpha}_{K} α ^ K , α ^ B \hat{\alpha}_{B} α ^ B , α ^ M \hat{\alpha}_{M} α ^ M , and α ^ T \hat{\alpha}_{T} α ^ T , together with the initial value M ∗ , i n i 2 M^{2}_{*,\mathrm{ini}} M ∗ , ini 2 , are specified through parameters_smg. The alternatives listed in Table 1 include propto_scale, for which the α \alpha α functions are proportional to the scale factor, and constant_alphas, for which they remain constant in time.
In this mode, the covariant relations connecting the Horndeski functions G i G_i G i to M ∗ 2 M^{2}_{*} M ∗ 2 , the α \alpha α functions, and the effective scalar background quantities are not evaluated. Instead, the background evolution is fixed directly through expansion_model, while M ∗ 2 M^{2}_{*} M ∗ 2 and the α \alpha α functions are constructed from the chosen phenomenological parametrisation. The resulting quantities are then supplied to Mercury in the same form as in the covariant workflow.
Covariant-theory approach
In the covariant mode, the background expansion and the Horndeski perturbation sector are determined self-consistently from the underlying action. The user selects a theory through gravity_model and specifies the corresponding model parameters and scalar-field initial conditions through parameters_smg. In contrast to the effective-theory approach, no independent expansion_model is required. Instead, hi_class evolves the homogeneous scalar field together with the background expansion and evaluates ρ ˉ ϕ \bar{\rho}_{\phi} ρ ˉ ϕ , P ˉ ϕ \bar{P}_{\phi} P ˉ ϕ , M ∗ 2 M^{2}_{*} M ∗ 2 , and the α \alpha α functions from the resulting background solution [4 ] . The covariant models considered in this work are summarised in Table 2 and briefly introduced below.
Table 2. Relevant hi_class \texttt{hi\_class} hi_class input options for the covariant Horndeski models.
For the covariant models considered below, we follow the normalisation of Eq. (1) , with M P l 2 M_{\mathrm{Pl}}^{2} M Pl 2 factored out of the Horndeski Lagrangian. The scalar fields are expressed as dimensionless variables, so that X X X has dimensions of inverse length squared.
Cubic covariant Galileon. The Cubic covariant Galileon is the lowest-order member of the covariant Galileon family and contains a derivative self-interaction of the scalar field. It is defined by
G 2 = − X , G 3 = − 2 c 3 X H 0 2 , G 4 = 1 2 , G 5 = 0. (61) G_{2}=-X,\qquad G_{3}=-\frac{2c_{3}X}{H_{0}^{2}},\qquad G_{4}=\frac{1}{2},\qquad G_{5}=0. \tag*{(61)} G 2 = − X , G 3 = − H 0 2 2 c 3 X , G 4 = 2 1 , G 5 = 0. (61)
In the hi_class implementation used here, the model is selected through gravity_model = galileon and gravity_submodel = cubic. While in principle this model has three free parameters, i.e. ( ϕ i n i , ϕ i n i ′ , c 3 ) (\phi_{\mathrm{ini}},\phi'_{\mathrm{ini}},c_{3}) ( ϕ ini , ϕ ini ′ , c 3 ) , ϕ i n i \phi_{\mathrm{ini}} ϕ ini is irrelevant since the theory is shift-symmetric, c 3 c_{3} c 3 is fixed to satisfy the closure relation and ϕ i n i ′ \phi'_{\mathrm{ini}} ϕ ini ′ is chosen such that the solution sits on the attractor (in hi_class, the system can also be evolved away from the attractor). Thus, no additional parameters_smg vector is required. Since G 4 G_{4} G 4 is constant and G 5 = 0 G_{5}=0 G 5 = 0 , the effective Planck mass is constant, M ∗ 2 = 1 M_{*}^{2}=1 M ∗ 2 = 1 , and the tensor propagation speed is unmodified, giving α M = α T = 0 \alpha_{M}=\alpha_{T}=0 α M = α T = 0 , while the cubic interaction produces a non-vanishing braiding function α B \alpha_{B} α B .
n n n KGB. The n n n KGB model is a shift-symmetric kinetic gravity braiding theory that generalises the Cubic Galileon through a power-law dependence on the kinetic term. It is defined by
G 2 = − X , G 3 = g n − 1 2 n ( X H 0 2 ) n , G 4 = 1 2 , G 5 = 0 , (62) G_{2}=-X,\qquad G_{3}=\frac{g^{n-\frac{1}{2}}}{n}\left(\frac{X}{H_{0}^{2}}\right)^{n},\qquad G_{4}=\frac{1}{2},\qquad G_{5}=0, \tag*{(62)} G 2 = − X , G 3 = n g n − 2 1 ( H 0 2 X ) n , G 4 = 2 1 , G 5 = 0 , (62)
The model is specified by the dimensionless coupling g g g , which controls the strength of the kinetic braiding interaction, the power-law index n n n , which determines its dependence on the kinetic term X X X , and the quantity R s h i f t , 0 R_{\mathrm{shift},0} R shift , 0 , which measures the present-day departure from the shift-current attractor J = 0 J=0 J = 0 , where J J J denotes the scalar shift current. The latter quantity is defined as
R s h i f t , 0 = 2 X J 2 X J + X ∣ a = 1 , 0 ≤ R s h i f t , 0 < 1. (63) R_{\mathrm{shift},0}=\left.\frac{\sqrt{2X}\,J}{\sqrt{2X}\,J+X}\right|_{a=1}, \qquad0\le R_{\mathrm{shift},0}<1. \tag*{(63)} R shift , 0 = 2 X J + X 2 X J a = 1 , 0 ≤ R shift , 0 < 1. (63)
The attractor solution corresponds to R s h i f t , 0 = 0 R_{\mathrm{shift},0}=0 R shift , 0 = 0 . Since G 4 G_4 G 4 is constant and G 5 = 0 G_5=0 G 5 = 0 , the effective Planck mass is constant, M ∗ 2 = 1 M_*^2=1 M ∗ 2 = 1 , and the tensor propagation speed is unmodified, giving α M = α T = 0 \alpha_M=\alpha_T=0 α M = α T = 0 . The n n n KGB input file therefore uses parameters_smg = ( g , n , R s h i f t , 0 ) \texttt{parameters\_smg}=(g,n,R_{\mathrm{shift},0}) parameters_smg = ( g , n , R shift , 0 ) .
Brans–Dicke gravity. Brans–Dicke gravity introduces a non-minimal coupling between the scalar field and the Ricci scalar. In the implementation considered here, the covariant functions are
G 2 = ω B D ϕ X − 3 H 0 2 V 0 , G 3 = 0 , G 4 = ϕ 2 , G 5 = 0. (64) G_2=\frac{\omega_{\mathrm{BD}}}{\phi}X-3H_0^2V_0,\qquad G_3=0,\qquad G_4=\frac{\phi}{2},\qquad G_5=0. \tag*{(64)} G 2 = ϕ ω BD X − 3 H 0 2 V 0 , G 3 = 0 , G 4 = 2 ϕ , G 5 = 0. (64)
Here, V 0 V_0 V 0 is the dimensionless constant-potential parameter, while ω B D \omega_{\mathrm{BD}} ω BD controls the scalar kinetic term and the coupling strength relative to the general-relativistic limit. The GR limit is approached as ω B D → ∞ \omega_{\mathrm{BD}}\to\infty ω BD → ∞ , for which the scalar becomes increasingly difficult to excite. In this convention, the dimensionless effective Planck mass squared is M ∗ 2 = 2 G 4 = ϕ M_*^2=2G_4=\phi M ∗ 2 = 2 G 4 = ϕ . The parameters ϕ i n i \phi_{\mathrm{ini}} ϕ ini and ϕ i n i ′ \phi'_{\mathrm{ini}} ϕ ini ′ specify the initial conditions for the homogeneous scalar field. The corresponding input vector is parameters_smg = ( V 0 , ω B D , ϕ i n i , ϕ i n i ′ ) (V_0, \omega_{\rm BD}, \phi_{\rm ini}, \phi'_{\rm ini}) ( V 0 , ω BD , ϕ ini , ϕ ini ′ ) . The optional parameter M_pl_today_smg can be used to fix the present-day effective Planck mass by adjusting the scalar-field initial value. When normalize_G_NR is also activated, hi_class instead normalises the effective gravitational coupling felt by nonrelativistic matter.
Background workflow:
Once the present-day fractional scalar-sector density has been fixed through Omega_smg, hi_class treats Ω s m g , 0 \Omega_{\rm smg,0} Ω smg , 0 as the target abundance that the covariant background solution must reproduce. When Omega_smg< 0 <0 < 0 , this target is first inferred from the cosmological closure relation discussed above. In the normalisation used by hi_class,
ϕ ˉ 0 t a r g e t = H 0 2 Ω s m g , 0 t a r g e t . (65) \bar{\phi}_{0}^{\rm target}=H_0^2\Omega_{\rm smg,0}^{\rm target}. \tag*{(65)} ϕ ˉ 0 target = H 0 2 Ω smg , 0 target . (65)
The selected gravity model, together with the corresponding entries of parameters_smg, determines the covariant functions G i ( ϕ , X ) G_i(\phi,X) G i ( ϕ , X ) and the scalar-field initial conditions. Starting from a trial set of model parameters, hi_class constructs an initial configuration satisfying the Friedmann constraint and evolves the homogeneous scalar field together with the cosmological background using its constraint-preserving integration scheme [4 ] . The effective scalar density and pressure are evaluated along this trajectory from the covariant expressions introduced in Section 2.1.
For models in which a parameter must be adjusted to reproduce the desired present-day abundance, tuning_index_smg selects the corresponding shooting parameter, which we denote by θ s h o o t \theta_{\rm shoot} θ shoot . After each trial background evolution, the resulting value Ω s m g , 0 t r i a l \Omega_{\rm smg,0}^{\rm trial} Ω smg , 0 trial is compared with the target through
R ( θ s h o o t ) = Ω s m g , 0 t r i a l − Ω s m g , 0 t a r g e t . (66) \mathcal{R}(\theta_{\rm shoot})=\Omega_{\rm smg,0}^{\rm trial}-\Omega_{\rm smg,0}^{\rm target}. \tag*{(66)} R ( θ shoot ) = Ω smg , 0 trial − Ω smg , 0 target . (66)
If ∣ R ∣ |\mathcal{R}| ∣ R ∣ exceeds the required tolerance ϵ s h o o t \epsilon_{\rm shoot} ϵ shoot , the shooting parameter is updated and the background evolution is repeated. Once the target abundance is reproduced, the converged solution is retained and the quantities required by Mercury, including H ( a ) H(a) H ( a ) , ρ ˉ ϕ ( a ) \bar{\rho}_{\phi}(a) ρ ˉ ϕ ( a ) , P ˉ ϕ ( a ) \bar{P}_{\phi}(a) P ˉ ϕ ( a ) , M ∗ 2 ( a ) M_*^2(a) M ∗ 2 ( a ) , and the α \alpha α functions, are stored along the background trajectory. The procedure is summarised in Figure 2 .
Figure 2. Schematic representation of the shooting procedure used to construct the covariant Horndeski background.
Stage II: Construction of the initial conditions
Once the background evolution and linear transfer functions have been computed by hi_class, they are used to construct the initial conditions at a redshift z i n i z_{\rm ini} z ini chosen by the user. In the simulations presented in this work, we set z i n i = 100 z_{\mathrm{ini}} = 100 z ini = 100 .
The perturbations evolved by hi_class are expressed in synchronous gauge, whereas Mercury evolves the metric and scalar-field perturbations in Poisson gauge. The transfer functions required for the initialisation are therefore transformed consistently to Poisson gauge. The corresponding gauge-transformation relations are given in Appendix C of [22 ] .
The initial perturbations are generated as correlated Gaussian realisations by combining the linear transfer functions with the primordial curvature spectrum. The same random seed and Fourier-mode ordering are used for the different perturbation variables, ensuring that the matter, metric, and Horndeski scalar fields correspond to the same primordial realisation.
Realisation of the perturbation fields
To initialise the scalar-field perturbation π \pi π and its evolution variable ζ \zeta ζ on the real-space lattice, we first transform their Fourier-space perturbations from hi_class into Poisson gauge and then apply an inverse fast Fourier transform (FFT). These fields provide the initial conditions for the subsequent scalar-field evolution and for the construction of the Horndeski stress–energy tensor.
The initial spatial metric potential Φ \Phi Φ is constructed from the total density and velocity-divergence transfer functions using the linearised Hamiltonian and momentum constraints, Eqs. (14) and (18) . The gravitational slip χ \chi χ is obtained from the trace-free spatial metric equation, with the linear hi_class slip used at early times when the optional linear-χ \chi χ treatment is active. The temporal potential is then reconstructed as
Ψ = Φ − χ (67) \Psi= \Phi- \chi \tag*{(67)} Ψ = Φ − χ (67)
and is therefore not stored as an independent lattice field. The initial vector potential B i B_i B i is obtained from the corresponding vector projection of the matter momentum source.
Initialisation of the particle phase space
The particle phase space is initialised following the procedure implemented in gevolution and described in Appendix § 9 of [13 ] . A homogeneous particle template is displaced using the linear matter transfer functions, while the corresponding velocity transfer functions determine the initial particle momenta. The required relativistic gauge corrections are included consistently in the construction of these fields.
In the blended treatment adopted in this work, CDM and baryons are represented by a single particle ensemble. Their density and velocity transfer functions are combined using the corresponding background-density weights before the displacement and momentum fields are generated. The vector potential B i B_i B i is computed from the initial particle momentum density, whereas h i j h_{ij} h ij is obtained from the tensor source at the first evolution cycle and is therefore not included among the fields initialised at this stage. At the end of this stage, the initialised lattice fields are
{ Φ , χ , B i , π , ζ } (68) \{\Phi, \chi, B_i, \pi, \zeta\} \tag*{(68)} { Φ , χ , B i , π , ζ } (68)
while the particle sector is specified by
{ x p , q p } (69) \{\mathbf{x}_p, \mathbf{q}_p\} \tag*{(69)} { x p , q p } (69)
where x p \mathbf{x}_p x p and q p \mathbf{q}_p q p denote the position and canonical momentum of particle p p p , respectively. Together with the background and Horndeski quantities obtained in Stage I, these variables define the initial state passed to the main evolution loop in Stage III.
Stage III: Main evolution loop
After the initial conditions have been constructed, the simulation enters the main evolution loop. At each cycle, the matter and Horndeski sources are projected onto the lattice, the metric fields are updated, the Horndeski scalar perturbations π \pi π and ζ \zeta ζ are advanced, and finally the particle phase-space coordinates and background scale factor are evolved.
The first step is the construction of the matter stress–energy tensor on the simulation lattice. The particle positions and canonical momenta are used to evaluate the components T 0 0 ( m ) T^{0(m)}_{0} T 0 0 ( m ) , T i 0 ( m ) T^{0(m)}_{i} T i 0 ( m ) , and T i j ( m ) T^{j(m)}_{i} T i j ( m ) , which are deposited onto the lattice using the particle-to-mesh projection scheme of gevolution. The explicit expressions for the particle stress–energy tensor and the corresponding projection procedure are given in [13 ] .
The deposited matter energy-density component is separated into its homogeneous and perturbed parts, with δ T 0 0 ( m ) \delta T^{0(m)}_{0} δ T 0 0 ( m ) contributing to the scalar source s i , j , k s_{i,j,k} s i , j , k defined in Eq. (33) , while the momentum density and spatial stress contribute to the vector and trace-free spatial sources.
The Horndeski contribution to the stress–energy tensor is then evaluated from the current scalar and metric fields. The relevant components are δ T 0 0 ( ϕ ) \delta T^{0(\phi)}_{0} δ T 0 0 ( ϕ ) , δ T ℓ 0 ( ϕ ) \delta T^{0(\phi)}_{\ell} δ T ℓ 0 ( ϕ ) , and Π ℓ m ( ϕ ) \Pi^{(\phi)}_{\ell m} Π ℓ m ( ϕ ) , whose lattice expressions are given in Eqs. (21) –(23) . These contributions are added to the corresponding gravitational sources before the metric equations are solved.
The Hamiltonian constraint is solved first to update the spatial metric potential Φ \Phi Φ . The scalar source is transformed to Fourier space, where the discretised constraint in Eq. (36) is solved mode by mode, and the resulting Φ \Phi Φ field is transformed back to the real-space lattice.
The trace-free spatial equations are treated next. The source S i j S_{ij} S ij is transformed to Fourier space and decomposed into its scalar, vector, and tensor parts. The scalar projection determines the gravitational slip χ \chi χ through Eq. (53) . At early times, when the linear-χ \chi χ treatment is active, the full linear slip supplied by hi_class is used instead. The vector sector determines the frame-dragging potential B i B_i B i through either the transverse projection of the momentum constraint in Eq. (18) or the evolution equation in Eq. (54) , depending on the selected treatment. The tensor perturbation h i j h_{ij} h ij can either be evolved dynamically through Eq. (55) or obtained from its elliptic, quasistatic limit by neglecting the time-derivative terms. The tensor results presented in this work use the latter treatment.
Once Φ \Phi Φ and χ \chi χ have been updated, their conformal-time derivatives are reconstructed from the current and previous time levels. Since Ψ = Φ − χ \Psi= \Phi- \chi Ψ = Φ − χ , this provides both Φ ′ \Phi' Φ ′ and Ψ ′ \Psi' Ψ ′ , which enter the subsequent evolution of the Horndeski scalar perturbations. Snapshots, power spectra, and lightcones are written whenever the corresponding output redshifts are reached.
The scalar variables ζ \zeta ζ and π \pi π are advanced using the staggered leapfrog scheme described in § 3 . The variable ζ \zeta ζ is evaluated at half-integer time levels and π \pi π at integer time levels. When required by the scalar stability condition, the main simulation step is subdivided into smaller scalar steps, with the background evaluated consistently throughout the subcycling.
Finally, the particle phase-space coordinates are advanced using the updated metric fields. The canonical momenta are updated first, the background scale factor is advanced by half a time step, and the particle positions are then evolved using the updated momenta. The remaining half-step of the background evolution is subsequently completed. This preserves the time staggering of the particle leapfrog scheme. The conformal time and time step are then updated, and the procedure is repeated for the next simulation cycle.
Numerical results and validation
In this section, we present the numerical results obtained with Mercury and assess the implementation against the corresponding linear predictions from hi_class.
Simulation setup
We consider six representative Horndeski models, divided into two groups according to the input approach used in hi_class. The first group consists of three phenomenological models specified directly in the effective-theory basis. We refer to these simulations as EFT-k k k ess, EFT-KGB, and EFT-LH, corresponding respectively to the k k k -essence subclass, the kinetic gravity braiding subclass, and the luminal Horndeski subclass. For EFT-LH, we adopt the best-fit values obtained from the CMB+DESI+ISWL+PantheonPlus data combination in [31 ] . We further choose a large kineticity, α ^ K = 3 × 10 3 \hat{\alpha}_{K} = 3 \times10^{3} α ^ K = 3 × 1 0 3 , which leads to a small speed of sound. The EFT-KGB and EFT-k k k ess models are then obtained as successive limits of EFT-LH by setting α ^ M = 0 \hat{\alpha}_{M} = 0 α ^ M = 0 and subsequently α ^ B = 0 \hat{\alpha}_{B} = 0 α ^ B = 0 , respectively, while keeping α ^ T = 0 \hat{\alpha}_{T} = 0 α ^ T = 0 in all three cases. For EFT-LH and EFT-KGB, the phantom divide can be crossed without generating a singularity in the perturbation evolution. We therefore retain the best-fit background values ( w 0 , w a ) = ( − 0.88 , − 0.40 ) (w_{0}, w_{a}) = (-0.88, -0.40) ( w 0 , w a ) = ( − 0.88 , − 0.40 ) obtained from [31 ] . By contrast, the minimally coupled k k k -essence model considered here does not allow a regular crossing of w = − 1 w = -1 w = − 1 . For EFT-k k k ess, we therefore set w a = 0 w_{a} = 0 w a = 0 while keeping w 0 = − 0.88 w_{0} = -0.88 w 0 = − 0.88 . Moreover, the time dependence of the effective theory functions follows the propto_omega parametrisation,
α i ( a ) = α ^ i Ω s m g ( a ) . (70) \alpha_{i}(a) = \hat{\alpha}_{i} \Omega_{\rm smg}(a). \tag*{(70)} α i ( a ) = α ^ i Ω smg ( a ) . (70)
The second group consists of three theories specified through a covariant Horndeski action: the nKGB model, the Cubic Galileon, and the Brans–Dicke model. For these simulations, the background evolution and the effective functions M ∗ 2 M_{*}^{2} M ∗ 2 and α i \alpha_{i} α i are computed self-consistently from the covariant model by hi_class.
All simulations are initialised at z i n i = 100 z_{\rm ini} = 100 z ini = 100 using the same baseline cosmological parameters, summarised in Table 3 , and adopt a common numerical setup with N g r i d = N p c l = 3072 3 N_{\rm grid} = N_{\rm pcl} = 3072^{3} N grid = N pcl = 307 2 3 and L b o x = 4000 h − 1 M p c L_{\rm box} = 4000 h^{-1}\mathrm{Mpc} L box = 4000 h − 1 Mpc . In all cases, the present-day dark-energy density is determined from the spatial-flatness closure relation,
Table 3. Baseline cosmological parameters used in all simulations.
Ω s m g , 0 = 1 − Ω m , 0 − Ω r , 0 . (71) \Omega_{\rm smg,0} = 1 - \Omega_{\rm m,0} - \Omega_{\rm r,0}. \tag*{(71)} Ω smg , 0 = 1 − Ω m , 0 − Ω r , 0 . (71)
The model-dependent parameters are summarised in Table 4 .
Table 4. Table 4: Model parameters used in the simulations. All simulations use 3072 3 3072^{3} 307 2 3 grid cells and particles, and a box size of L b o x = 4000 h − 1 M p c L_{\mathrm{box}} = 4000\,h^{-1}\mathrm{Mpc} L box = 4000 h − 1 Mpc . For the EFT models, α i ( a ) = α ^ i Ω s m g ( a ) \alpha_i(a) = \hat{\alpha}_i\Omega_{\mathrm{smg}}(a) α i ( a ) = α ^ i Ω smg ( a ) and M ∗ , i n i 2 = 1 M^{2}_{*,\mathrm{ini}} = 1 M ∗ , ini 2 = 1 .
Background evolution
Before turning to the perturbation spectra, we first compare the background evolution of the six models introduced above. Figure 3 presents the redshift evolution of the relevant background quantities for the six models. The upper row shows the expansion history and the effective dark-energy evolution, while the lower row presents the time-dependent α \alpha α functions entering the perturbation equations.
Figure 3. Background evolution of the six models considered in this work. The upper panels show the fractional deviation of the Hubble parameter from the reference Λ \Lambda Λ CDM cosmology, the effective dark-energy equation of state w D E w_{\rm DE} w DE , and the fractional difference in the physical dark-energy density, Δ ρ D E / ρ Λ \Delta\rho_{\rm DE}/\rho_{\Lambda} Δ ρ DE / ρ Λ . The lower panels show the evolution of α M \alpha_{\rm M} α M , α K \alpha_{\rm K} α K , and α B \alpha_{\rm B} α B . The function α M \alpha_{\rm M} α M vanishes for all models except EFT-LH and Brans–Dicke. For Brans–Dicke, α B = − α M \alpha_{\rm B}=-\alpha_{\rm M} α B = − α M ; its negative values are therefore not displayed on the logarithmic scale used in the α B \alpha_{\rm B} α B panel.
The differences in the expansion rate shown in panel (a) can be interpreted in terms of the evolution of w D E w_{\mathrm{DE}} w DE and ρ D E \rho_{\mathrm{DE}} ρ DE in panels (b) and (c). In panel (c), we plot the fractional deviation of the dark-energy density from its Λ \Lambda Λ CDM value,
Δ ρ D E ρ Λ ≡ ρ D E ( z ) − ρ Λ ρ Λ , (72) \frac{\Delta\rho_{\mathrm{DE}}}{\rho_{\Lambda}} \equiv\frac{\rho_{\mathrm{DE}}(z)-\rho_{\Lambda}}{\rho_{\Lambda}}, \tag*{(72)} ρ Λ Δ ρ DE ≡ ρ Λ ρ DE ( z ) − ρ Λ , (72)
where ρ Λ \rho_{\Lambda} ρ Λ denotes the dark-energy density of the reference Λ \Lambda Λ CDM cosmology and is constant. Since all models share the same present-day Hubble parameter and dark-energy density, the deviations in panels (a) and (c) vanish at z = 0 z = 0 z = 0 . Quintessence-like behaviour, w D E > − 1 w_{\mathrm{DE}} > -1 w DE > − 1 , generally implies a larger dark-energy density in the past than for a cosmological constant, whereas phantom behaviour, w D E < − 1 w_{\mathrm{DE}} < -1 w DE < − 1 , implies a smaller one. These differences modify the total background energy density and, through the Friedmann equation, the evolution of H ( z ) H(z) H ( z ) .
The EFT-kess model provides the clearest example of quintessence-like behaviour. Its equation of state is constant, with w D E = − 0.88 w_{\mathrm{DE}} = -0.88 w DE = − 0.88 , so its physical dark-energy density increases towards the past relative to the constant ρ Λ \rho_{\Lambda} ρ Λ . This is reflected by the positive deviation in panel (c) and leads to an enhanced Hubble rate at low and intermediate redshifts, reaching a few per cent around z ∼ 1 z \sim1 z ∼ 1 . EFT-KGB and EFT-LH share the same prescribed background evolution and therefore overlap throughout the upper row. Their equation of state is quintessence-like at late times but crosses into the phantom regime at higher redshift. Accordingly, their dark-energy density is initially larger than ρ Λ \rho_{\Lambda} ρ Λ when moving away from z = 0 z = 0 z = 0 , but later falls below it. The Hubble-rate deviation follows the same transition, becoming positive at low redshift, reaching a maximum below z ∼ 1 z \sim1 z ∼ 1 , and turning slightly negative at higher redshift.
The covariant KGB models exhibit phantom behaviour over the redshift interval in which their dark-energy sector contributes appreciably to the expansion. Their physical dark-energy density is therefore lower than ρ Λ \rho_{\Lambda} ρ Λ over this range, producing the negative deviations in panel (c) and a corresponding suppression of the Hubble rate. This effect is relatively mild for nKGB, whose equation of state remains closer to − 1 -1 − 1 , but is considerably stronger for the Cubic Galileon, for which w D E w_{\rm DE} w DE approaches − 2 -2 − 2 . The Cubic Galileon consequently shows the largest departure in panel (a), with Δ H / H Λ C D M \Delta H/H_{\Lambda\mathrm{CDM}} Δ H / H Λ CDM reaching about − 8 % -8\% − 8% around z ∼ 1 z\sim1 z ∼ 1 .
Brans–Dicke remains close to the Λ \Lambda Λ CDM expansion history at low redshift despite the pronounced evolution of its effective equation of state. The effective equation of state remains close to − 1 -1 − 1 at low redshift, with only small variations around the phantom divide. At higher redshift, the effective dark-energy density grows rapidly relative to ρ Λ \rho_{\Lambda} ρ Λ , producing the pronounced rise in panel (c). Although this fractional difference becomes large, its impact on H ( z ) H(z) H ( z ) remains modest because the background is increasingly dominated by matter at these redshifts. Consequently, the Brans–Dicke expansion history stays close to that of Λ \Lambda Λ CDM.
The lower panels of Figure 3 show the evolution of the α \alpha α functions. For the EFT models, their time dependence follows the parametrisation introduced in Eq. (70) , such that each non-vanishing α i \alpha_i α i scales with Ω s m g ( a ) \Omega_{\rm smg}(a) Ω smg ( a ) . As the dark-energy contribution becomes increasingly important towards low redshift, the corresponding α \alpha α functions grow and approach their largest values at the present epoch. An instructive example is α K \alpha_{\mathrm{K}} α K in panel (e). Although the same value of α ^ K \hat{\alpha}_{\mathrm{K}} α ^ K is adopted for all three EFT models, EFT-KGB and EFT-LH follow the same evolution, whereas EFT-kess departs from them at higher redshift. This difference originates entirely from the background evolution entering the parametrisation: EFT-KGB and EFT-LH share the same dynamical dark-energy equation of state and therefore the same Ω s m g ( a ) \Omega_{\mathrm{smg}}(a) Ω smg ( a ) , while EFT-kess has w a = 0 w_a = 0 w a = 0 and consequently a different evolution of Ω s m g \Omega_{\mathrm{smg}} Ω smg . The three models nevertheless approach the same value of α K \alpha_{\mathrm{K}} α K at z = 0 z = 0 z = 0 , where their present-day dark-energy density fractions coincide.
For the covariant models, by contrast, the evolution of the α \alpha α functions is determined by the underlying scalar–tensor theory rather than by the phenomenological parametrisation adopted for the EFT models. This results in different redshift dependences. In Brans–Dicke, both α M \alpha_{\mathrm{M}} α M and α K \alpha_{\mathrm{K}} α K vary only mildly over the redshift range shown and remain approximately constant compared with the stronger evolution found in the other models. Although G 3 = 0 G_3 = 0 G 3 = 0 , the non-minimal coupling through G 4 ( ϕ ) G_4(\phi) G 4 ( ϕ ) generates a non-vanishing braiding function, which for this model satisfies α B = − α M \alpha_{\mathrm{B}} = -\alpha_{\mathrm{M}} α B = − α M . The nKGB and Cubic Galileon models, by contrast, show a strong increase in both α K \alpha_{\mathrm{K}} α K and α B \alpha_{\mathrm{B}} α B towards low redshift. Although their evolution differs, both functions decrease rapidly at higher redshifts, with the Cubic Galileon showing a steeper decline.
Power-spectrum analysis
We next examine the power spectra of the perturbations at z = 0 z = 0 z = 0 and compare the results from Mercury with the corresponding linear predictions from hi_class. On large scales, the two closely match, as expected when the evolution remains in the linear regime. Towards smaller scales, the Mercury spectra depart from the linear predictions as nonlinear structure formation becomes important. These nonlinear effects propagate through the coupled matter, scalar-field, and metric sectors, modifying the Horndeski perturbations and subsequently feeding back onto the metric perturbations.
The convergence tests presented in Appendix § 9 indicate that, for the simulations with N g r i d = N p c l = 3072 3 N_{\mathrm{grid}} = N_{\mathrm{pcl}} = 3072^3 N grid = N pcl = 307 2 3 discussed in this section, resolution effects at the per cent level become relevant in the individual power spectra at k ≳ 0.3 k \gtrsim0.3 k ≳ 0.3 –0.4 h M p c − 1 0.4\,h\,\mathrm{Mpc}^{-1} 0.4 h Mpc − 1 . These effects largely cancel in power-spectrum ratios, with the tested ratios showing a resolution dependence within approximately 2% over the full plotted range. This supports a reliable interpretation of the relative model signatures down to the smallest scales shown.
Figure 4 shows the matter power spectra at z = 0 z = 0 z = 0 for the EFT and covariant models. On large scales, the Mercury results match the corresponding linear predictions from hi_class, as can also be seen in the lower panels showing the relative differences with respect to EFT-kess. The differences between the models in this regime reflect their different growth histories, which accumulate from the initial conditions to the present epoch. Towards smaller scales, nonlinear evolution increases the power relative to the linear prediction while preserving the ordering of the models compared to the linear case.
Figure 4. Matter power spectra at z = 0 z = 0 z = 0 for the EFT models (left) and the covariant models (right). Solid lines show the results from Mercury, while dashed lines show the corresponding linear predictions from hi_class. The lower panels show the relative differences with respect to EFT-kess, expressed as percentages.
Within the EFT family, EFT-KGB and EFT-LH are particularly useful to compare, since they share the same prescribed background evolution as well as the same α K \alpha_{\mathrm{K}} α K and α B \alpha_{\mathrm{B}} α B , but differ through the non-vanishing α M \alpha_{\mathrm{M}} α M and the associated evolution of M ∗ 2 M_*^2 M ∗ 2 in EFT-LH. The resulting difference in the matter power spectrum therefore isolates the effect of the additional non-minimal coupling within this EFT parametrisation. This difference is already present in the linear evolution and persists into the nonlinear regime, where the overall separation between the spectra becomes more pronounced. EFT-kess, which also differs in its background evolution and has vanishing braiding, shows the lowest matter power among the three models at small scales.
For the covariant models, the Cubic Galileon exhibits the largest matter power, followed by nKGB and Brans–Dicke. The same ordering is already apparent in the linear spectra and is maintained after nonlinear evolution. Unlike the EFT-KGB and EFT-LH comparison, however, the covariant models differ simultaneously in their background expansion, effective Planck mass, and the evolution of the α \alpha α functions. Their relative amplitudes therefore reflect the combined effect of these differences on the growth of matter perturbations and cannot be associated with a single Horndeski function. The matter spectra thus provide a useful reference for the following discussion, since the scale-dependent departure from the linear predictions marks the regime in which nonlinear matter evolution can begin to source corresponding scalar-field and metric perturbations.
Figure 5 shows the power spectrum of the scalar-field perturbation π \pi π . A characteristic feature of the braided models is the pronounced minimum associated with a zero crossing and sign change of π \pi π , previously discussed in detail for KGB models in [22 ] . This behaviour is clearly visible for EFT-KGB and EFT-LH, both of which have a non-vanishing α B \alpha_{\mathrm{B}} α B , while it is absent in the EFT-kess limit. Similar zero crossings are also present in the covariant nKGB and Cubic Galileon models at lower wavenumbers, around k ∼ 10 − 3 h M p c − 1 k \sim10^{-3}\,h\,\mathrm{Mpc}^{-1} k ∼ 1 0 − 3 h Mpc − 1 . Their different scalar dynamics, including the evolution of the sound speed, shift the characteristic sign change of π \pi π towards larger scales.
Figure 5. Dimensionless power spectra of the scalar-field perturbation H 0 π \mathcal{H}_0\pi H 0 π at z = 0 z = 0 z = 0 for the EFT models (left) and the covariant models (right). Solid lines show the results from Mercury, while dashed lines show the corresponding linear predictions from hi_class.
Figure 6 shows the dimensionless power spectrum of the effective dark-energy density contrast, δ D E = δ ρ ϕ / ρ ˉ ϕ \delta_{\mathrm{DE}} = \delta\rho_{\phi}/\bar{\rho}_{\phi} δ DE = δ ρ ϕ / ρ ˉ ϕ . Its behaviour can be understood directly from the structure of the effective density perturbation in Eq. (15) . In particular, δ ρ φ \delta\rho_{\varphi} δ ρ φ receives contributions from π \pi π , ζ \zeta ζ , and the scalar metric perturbations, with their relative importance controlled by the α \alpha α functions. Of particular relevance is the braiding contribution α B H ∇ 2 π \alpha_{\mathrm{B}}\mathcal{H}\nabla^2\pi α B H ∇ 2 π , which in Fourier space is proportional to α B k 2 π \alpha_{\mathrm{B}}k^2\pi α B k 2 π . This gradient enhancement explains why the dark-energy density perturbations can continue to grow towards small scales even though the scalar-field spectrum shown in Figure 5 decreases in this regime.
Figure 6. Dimensionless power spectra of the effective dark-energy density contrast δ D E \delta_{\mathrm{DE}} δ DE at z = 0 z = 0 z = 0 for the EFT models (left) and the covariant models (right). Solid lines show the results from Mercury, while dashed lines show the corresponding linear predictions from hi_class.
The distinction is particularly clear among the EFT models. In the EFT-kess limit, α B = 0 \alpha_{\mathrm{B}} = 0 α B = 0 , and all terms in Eq. (15) proportional to the braiding function vanish. The density perturbation is then mainly determined by the terms involving α K ζ \alpha_{\mathrm{K}}\zeta α K ζ and π \pi π , resulting in the turnover and subsequent decrease of Δ D E \Delta_{\mathrm{DE}} Δ DE towards small scales. Once braiding is introduced in EFT-KGB, the k 2 π k^2\pi k 2 π contribution becomes increasingly important and produces a strong enhancement of the dark-energy clustering at high wavenumbers, consistent with the behaviour previously found in [22 ] . EFT-LH has the same background evolution and the same α K \alpha_{\mathrm{K}} α K and α B \alpha_{\mathrm{B}} α B as EFT-KGB, but additionally includes a non-vanishing α M \alpha_{\mathrm{M}} α M and an evolving effective Planck mass. Note that although α M \alpha_{\mathrm{M}} α M does not appear explicitly in Eq. (15) , it affects δ ρ ϕ \delta\rho_{\phi} δ ρ ϕ both through the evolution of M ∗ 2 M_*^2 M ∗ 2 and indirectly through the modified evolution of the scalar and metric perturbations. The effective Planck mass changes the normalisation of the effective density perturbation through the overall prefactor and also enters the coefficient of the term proportional to π \pi π . Its evolution can therefore modify not only the amplitude of δ D E \delta_{\mathrm{DE}} δ DE but also its scale dependence, as shown in Figure 6 .
The covariant nKGB and Cubic Galileon models show an even stronger growth of the dark-energy density perturbations towards small scales. Both models possess a non-vanishing braiding interaction, while their α K \alpha_{\mathrm{K}} α K and α B \alpha_{\mathrm{B}} α B functions grow strongly towards low redshift, as shown in Figure 3 . In particular, at z = 0 z = 0 z = 0 their braiding functions are of order unity, substantially larger than the value α B ≃ 0.34 \alpha_{\mathrm{B}} \simeq0.34 α B ≃ 0.34 reached by EFT-KGB and EFT-LH. The larger braiding amplitude enhances the gradient term proportional to α B k 2 π \alpha_{\mathrm{B}} k^2\pi α B k 2 π in Eq. (15) , which helps to produce the stronger dark-energy clustering seen in the covariant KGB models. This contribution therefore becomes increasingly important at late times and on small scales. The similar amplitudes of the nKGB and Cubic Galileon dark-energy power spectra at z = 0 z = 0 z = 0 are consistent with their comparable values of α K \alpha_{\mathrm{K}} α K and α B \alpha_{\mathrm{B}} α B , although the resulting density perturbations also depend on the evolution of other background quantities and the scalar-field perturbations.
Brans–Dicke behaves very differently. As discussed above, its Horndeski functions remain small and evolve only mildly over the relevant redshift range. In particular, α K \alpha_{\mathrm{K}} α K stays at the level of ∼ 10 − 3 \sim10^{-3} ∼ 1 0 − 3 , several orders of magnitude below the values reached by the EFT models and substantially smaller than in nKGB and the Cubic Galileon, while α B \alpha_{\mathrm{B}} α B and α M \alpha_{\mathrm{M}} α M likewise remain small and vary only mildly over the same redshift range. Together with the large w B D = 1000 w_{\mathrm{BD}} = 1000 w BD = 1000 , this keeps the model relatively close to its GR limit and leads to much weaker scalar perturbations, resulting in a dark-energy density power spectrum several orders of magnitude below those of nKGB and the Cubic Galileon.
Figure 7 shows the dimensionless power spectrum of the gravitational potential Φ \Phi Φ . Its behaviour can be understood from the Hamiltonian constraint in Eq. (14) , where Φ \Phi Φ is sourced by the combined matter and scalar-field density perturbations, with the gravitational response normalised by M ∗ 2 M_*^2 M ∗ 2 . On sub-horizon scales, this approximately gives k 2 Φ ∝ ( δ ρ m + δ ρ ϕ ) / M ∗ 2 k^2\Phi\propto(\delta\rho_{\mathrm{m}} + \delta\rho_{\phi})/M_*^2 k 2 Φ ∝ ( δ ρ m + δ ρ ϕ ) / M ∗ 2 , so that the decrease of the gravitational potential spectra towards large wavenumbers reflects the increasing k 2 k^2 k 2 suppression, modulated by the scale dependence of the matter and dark-energy sources.
Figure 7. Dimensionless power spectra of the gravitational potential Φ \Phi Φ at z = 0 z = 0 z = 0 for the EFT models (left) and the covariant models (right). Solid lines show the results from Mercury, while dashed lines show the corresponding linear predictions from hi_class.
Within the EFT models, EFT-KGB retains slightly more potential power towards smaller scales than EFT-kess, consistent with the enhanced scalar clustering produced by braiding. EFT-LH instead shows an earlier and steeper decrease. This behaviour can be understood from the running of the effective Planck mass, characterised by α M > 0 \alpha_{\mathrm{M}} > 0 α M > 0 . Since M ∗ , i n i 2 = 1 M_{*,\mathrm{ini}}^2 = 1 M ∗ , ini 2 = 1 , the effective Planck mass increases towards the present epoch, suppressing the gravitational response to matter density perturbations through the factor 1 / M ∗ 2 1/M_*^2 1/ M ∗ 2 in the Hamiltonian constraint. Furthermore, the effective dark-energy density perturbation in Eq. (15) contains an overall prefactor M ∗ 2 M_*^2 M ∗ 2 , which cancels against the factor 1 / M ∗ 2 1/M_*^2 1/ M ∗ 2 in the Hamiltonian constraint, although additional dependence on M ∗ 2 M_*^2 M ∗ 2 remains within the expression. Consequently, its enhanced power does not necessarily translate into a larger contribution to the gravitational potential. In addition, the non-vanishing α M \alpha_{\mathrm{M}} α M generates gravitational slip, allowing the temporal potential Ψ \Psi Ψ , which governs matter dynamics, to evolve differently from the spatial potential Φ \Phi Φ . These effects provide a qualitative explanation for why EFT-LH exhibits less potential power despite having enhanced matter and effective dark-energy density power spectra compared to EFT-KGB and EFT-kess. For the covariant models, nKGB and the Cubic Galileon exhibit the largest potential power and a mild enhancement before the subsequent decline, consistent with their strongly clustered scalar sectors seen in Figure 6 . In both models M ∗ 2 M_*^2 M ∗ 2 is constant, so this behaviour is consistent with their strong braiding and the resulting enhanced scalar contribution to the total density source. Brans–Dicke remains lower in amplitude, in agreement with the much weaker scalar clustering found in the preceding spectra.
Figure 8 shows the dimensionless power spectrum of the gravitational slip, χ = Φ − Ψ \chi= \Phi- \Psi χ = Φ − Ψ . For EFT-kess, EFT-KGB, nKGB, and the Cubic Galileon, both α M \alpha_{\mathrm{M}} α M and α T \alpha_{\mathrm{T}} α T vanish, so the scalar-field anisotropic stress is zero at linear order. The corresponding hi_class prediction for χ \chi χ is not strictly zero, owing to the anisotropic stress of relativistic species, including photons and free-streaming massless neutrinos. In the Mercury simulations, the nonlinear evolution of dark matter generates an additional contribution to the gravitational slip through its anisotropic stress. Deep inside the horizon, this second-order effect is larger than the linear contribution of relativistic species. Consequently, the power spectrum of χ \chi χ in these models exceeds the linear hi_class prediction, particularly on smaller scales.
Figure 8. Dimensionless power spectra of the gravitational slip χ = Φ − Ψ \chi= \Phi- \Psi χ = Φ − Ψ at z = 0 z = 0 z = 0 for the EFT models (left) and the covariant models (right). Solid lines show the results from Mercury, while dashed lines show the corresponding linear predictions from hi_class.
The situation is different for EFT-LH and Brans–Dicke, where α M ≠ 0 \alpha_{\mathrm{M}} \ne0 α M = 0 while α T = 0 \alpha_{\mathrm{T}} = 0 α T = 0 . In this case, the Horndeski scalar generates a non-zero anisotropic stress already at linear order through the term proportional to α M H π \alpha_{\mathrm{M}}\mathcal{H}\pi α M H π in Eq. (17) , which is much larger than the slip generated by nonlinear matter evolution in the models with α M = 0 \alpha_{\mathrm{M}} = 0 α M = 0 . The Mercury and hi_class spectra consequently agree closely on large scales, while towards smaller scales the
Figure 9. Dimensionless power spectra of the vector metric perturbation B i B_i B i at z = 0 z = 0 z = 0 for the EFT models (left) and the covariant models (right). Solid lines show the results from Mercury.
Mercury results develop additional power as nonlinear matter and metric sources become increasingly important.
Figures 9 and 10 show the vector and tensor metric perturbations generated during the nonlinear evolution. Both quantities are obtained from the spin-1 and spin-2 projections of the same trace-free spatial source. The linear Horndeski anisotropic stress is purely scalar and therefore does not contribute directly to either projection; instead, B i B_i B i and h i j h_{ij} h ij are sourced by the nonlinear matter anisotropic stress and by the quadratic metric contribution proportional to Φ , i Φ , j \Phi_{,i}\Phi_{,j} Φ , i Φ , j . Consequently, differences between the models partly reflect the different nonlinear matter and metric evolution already seen in the preceding spectra.
Figure 10. Dimensionless power spectra of the tensor metric perturbation h i j h_{ij} h ij at z = 0 z = 0 z = 0 for the EFT models (left) and the covariant models (right). Solid lines show the results from Mercury.
In addition, a running effective Planck mass affects both sectors through α M \alpha_{\mathrm{M}} α M . For the vector mode, which is evolved here using the parabolic spin-1 equation, the damping term becomes ( 2 + α M ) H B i (2 + \alpha_{\mathrm{M}})\mathcal{H}B_i ( 2 + α M ) H B i . The effect is particularly clear when comparing EFT-LH with EFT-KGB: the two models share the same background evolution and the same α K \alpha_{\mathrm{K}} α K and α B \alpha_{\mathrm{B}} α B , while only EFT-LH has α M ≠ 0 \alpha_{\mathrm{M}} \ne0 α M = 0 . The lower vector power in EFT-LH is therefore consistent with the additional α M \alpha_{\mathrm{M}} α M -dependent damping, together with the modifications that the evolving effective Planck mass induces in the nonlinear source terms. Similar behaviour occurs in the dynamical tensor equation, where α M \alpha_{\mathrm{M}} α M modifies the friction term to ( 2 + α M ) H h i j ′ (2 + \alpha_{\mathrm{M}})\mathcal{H}h'_{ij} ( 2 + α M ) H h ij ′ . The tensor results shown here use the elliptic treatment, which neglects time derivatives; their differences therefore arise through the source. Since α T = 0 \alpha_{\mathrm{T}} = 0 α T = 0 for all models considered here, the tensor propagation speed remains unchanged. The lower vector and tensor amplitudes of Brans–Dicke are likewise consistent with its non-vanishing Planck-mass running together with its weaker nonlinear source, whereas nKGB and the Cubic Galileon, for which α M = 0 \alpha_{\mathrm{M}} = 0 α M = 0 , retain the largest amplitudes among the covariant models.
Snapshot analysis
In this section, we study the evolution of the dark-energy perturbations directly in real space. For this purpose, we perform additional simulations with 512 3 512^3 51 2 3 grid points in a box of side length L b o x = 100 h − 1 M p c L_{\mathrm{box}} = 100\,h^{-1}\mathrm{Mpc} L box = 100 h − 1 Mpc . We focus on two cases, the EFT-kess and EFT-LH models, using the same model parameters as listed in Table 4 . The smaller volume provides a higher spatial resolution and allows the development of nonlinear structure to be followed more clearly. The snapshots are used to illustrate how an effectively nonlinear dark-energy distribution emerges in Mercury even though the scalar-field perturbation equations themselves are implemented only at linear order. In Mercury, the scalar perturbations evolve in the presence of the nonlinear matter and metric sources generated by structure formation, allowing matter inhomogeneities to imprint nonlinear features on δ D E \delta_{\mathrm{DE}} δ DE . By contrast, hi_class evolves the same model entirely within linear perturbation theory.
Figure 11 shows this evolution for the EFT-LH model at four different redshifts. At the initial redshift, z ≃ 100 z \simeq100 z ≃ 100 , the hi_class and Mercury dark-energy fields are nearly indistinguishable, as expected from the common linear initial conditions. As structure formation proceeds, differences between the two gradually develop. By z ≃ 20 z \simeq20 z ≃ 20 and more clearly by z ≃ 8 z \simeq8 z ≃ 8 , the dark-energy field evolved in Mercury begins to acquire spatial features correlated with the emerging matter distribution, while the hi_class realisation retains the morphology predicted by linear evolution. At z ≃ 0.1 z \simeq0.1 z ≃ 0.1 , the difference becomes particularly pronounced. The non-vanishing braiding parameter α B \alpha_{\mathrm{B}} α B contributes to a strong response of the dark-energy perturbations to the nonlinear matter distribution, causing the Mercury field to develop a filamentary structure that closely traces the cosmic web. In contrast, the corresponding hi_class field remains comparatively smooth. This behaviour is consistent with our previous KGB analysis, where kinetic braiding was likewise found to drive enhanced dark-energy clustering [22 ] . The non-vanishing α M \alpha_{\mathrm{M}} α M and the associated evolution of the effective Planck mass M ∗ 2 M_*^2 M ∗ 2 also affect the dark-energy distribution. As discussed above, this occurs both through the explicit dependence of δ ρ φ \delta\rho_\varphi δ ρ φ on M ∗ 2 M_*^2 M ∗ 2 in Eq. (15) and indirectly through the modified evolution of the scalar and metric perturbations. For the EFT-LH model considered here, its time evolution therefore modifies the overall amplitude of δ D E \delta_{\mathrm{DE}} δ DE , while also affecting the gradient-dependent contributions to δ ρ φ \delta\rho_\varphi δ ρ φ . This effect is subdominant to the characteristic clustering induced by braiding, but further modifies the dark-energy field at late times.
Figure 12 shows the corresponding evolution for the EFT-kess model. As in the EFT-LH case, the hi_class and Mercury dark-energy fields agree closely at high redshift, when the evolution remains in the linear regime. At later times, differences between the two also begin to develop as the nonlinear matter and metric fields in Mercury feed into the scalar perturbations. However, the departure from the purely linear hi_class evolution is considerably weaker than in the EFT-LH model. In particular, the pronounced filamentary dark-energy structure seen in Figure 11 at late times is much less prominent in the EFT-kess case. This is consistent with the absence of kinetic braiding, α B = 0 \alpha_{\mathrm{B}} = 0 α B = 0 , for which the scalar sector responds less strongly to the nonlinear matter distribution.
Figure 11. Real-space evolution of the density contrasts in the EFT-LH model with the parameters given in Table 4 . The left and middle columns show the dark-energy density contrast obtained from hi_class and Mercury, respectively, while the right column shows the nonlinear matter density contrast in the simulation. For visualisation, the colour limits are restricted to the 1st–99th percentile range.
The comparison between the two models is also informative at the linear level. The hi_class snapshots in Figure 11 and Figure 12 show that the EFT-LH and EFT-kess models develop different dark-energy distributions even before the nonlinear response present in Mercury is taken into account, reflecting their different linear dynamics. The additional separation between hi_class and Mercury at late times is nevertheless much stronger for the EFT-LH model. This comparison makes it possible to distinguish differences inherited from the linear dynamics of the two models from the additional structure generated through the coupling of the scalar perturbations to the nonlinear matter and metric fields in Mercury.
Figure 12. Same as Figure 11 , but for the EFT-kess model with the parameters given in Table 4 .
For the models and parameters considered here, the dark-energy density perturbations remain small in both examples, even as the matter distribution becomes nonlinear. This supports the linear treatment of the scalar sector adopted in Mercury, while allowing the dark-energy perturbations to respond to nonlinear matter clustering.
Discussion and conclusions
In this work, we have developed Mercury as a relativistic N N N -body framework for Horndeski gravity within gevolution. The main step beyond our previous implementations is the transition from specific subclasses of scalar–tensor theories to a common formulation based on
the general linear Horndeski α \alpha α -basis. Together with the interface to hi_class, this provides a common numerical pipeline in which the cosmological model can be specified either phenomenologically through the α \alpha α functions or through an underlying covariant action, while the subsequent N N N -body evolution is performed within the same relativistic framework. The recovery of the previously implemented limits and the agreement with hi_class in the linear regime provide the primary validation of this construction.
The present implementation should be viewed as an intermediate step between linear Horndeski calculations and a nonlinear scalar–tensor simulation. Matter and the weak-field metric are evolved nonlinearly, and these nonlinear quantities enter the scalar-field evolution and its effective stress–energy tensor. The scalar sector can therefore respond dynamically to nonlinear structure formation and feed back on the gravitational field, rather than being imposed as an external linear realisation. At the same time, the intrinsic scalar dynamics are still described by the linear Horndeski perturbation equations. The nonlinear features that develop in the dark-energy distribution consequently arise from its coupling to the nonlinear matter and metric environment, rather than from nonlinear self-interactions of the Horndeski degree of freedom itself.
This distinction is also relevant for the interpretation of the α \alpha α -basis used by Mercury. The functions α K \alpha_{\mathrm{K}} α K , α B \alpha_{\mathrm{B}} α B , α M \alpha_{\mathrm{M}} α M and α T \alpha_{\mathrm{T}} α T provide an efficient and largely model-independent characterisation of Horndeski gravity at the level of linear cosmological perturbations. Beyond linear order, however, the nonlinear scalar dynamics depend on higher-order operators and interactions that are not fixed by these four functions alone [26 , 32 ] . Extending Mercury beyond its present approximation will therefore require a corresponding nonlinear description of the theory, either by retaining the relevant higher-order operators in an extended effective formulation or by deriving the nonlinear equations directly from a specified covariant Horndeski action. The latter route is especially direct for the covariant models already supported by the code.
A major motivation for this extension is the possibility of studying screening within the same relativistic N N N -body framework. In scalar–tensor theories with sufficiently strong derivative interactions, nonlinearities in the scalar equation can suppress the response of the additional degree of freedom in regions where scalar gradients and derivative self-interactions become large, typically in and around nonlinear overdensities. Such behaviour cannot be reproduced by the present linear scalar equations, irrespective of how nonlinear the matter distribution becomes. Incorporating the nonlinear scalar terms would therefore allow Mercury to follow the transition from the cosmological regime, where modifications to gravity may remain appreciable, to environments in which the scalar-mediated modification is dynamically suppressed. This would provide a framework for investigating screening mechanisms in relativistic cosmological simulations, including their dependence on the local environment and their impact on nonlinear structure formation.
Implementing this regime is not only a theoretical extension but also a substantially different numerical problem. The nonlinear scalar equation must be evolved together with the nonlinear contributions of the scalar field to the gravitational sources, while remaining consistent with the weak-field expansion used by gevolution. In regions where nonlinear scalar interactions become dominant, the equations may develop strong spatial gradients and increasingly complex dynamics, requiring numerical methods capable of accurately resolving the transition between screened and unscreened regimes. Nonlinear scalar dynamics can also develop instabilities, as observed in k k k -evolution simulations at small sound speed and investigated analytically in [33 , 34 , 35 ] . A nonlinear extension of Mercury would also allow us to investigate whether similar behaviour occurs in broader classes of Horndeski models. A nonlinear implementation will therefore require both an extension of the scalar solver and dedicated tests of its stability and convergence. The ability to recover the unscreened linear regime from the nonlinear solver will provide an important consistency test against the present version of Mercury.
The framework is also naturally suited to extending the relativistic observables previously studied for KGB to a substantially broader class of scalar–tensor theories. Since Mercury evolves the metric perturbations directly, its output can be combined with the light-cone infrastructure of gevolution to construct observables sensitive to the gravitational field along the line of sight. Our previous KGB analysis showed that such observables can retain nonlinear signatures that are not captured by linear perturbation theory alone. Applying the same methodology to general Horndeski models will make it possible to connect modifications of the scalar and metric sectors to weak lensing, the ISW–RS effect, gravitational redshift, and other relativistic probes without relying on the matter power spectrum alone.
The present version of Mercury therefore establishes the numerical link between the general linear Horndeski α \alpha α -basis implemented in hi_class and relativistic nonlinear structure formation in gevolution. The next step is to extend this framework to the nonlinear scalar sector, allowing scalar self-interactions, gravitational backreaction, and possible screening dynamics to be treated self-consistently alongside nonlinear matter within a single relativistic N N N -body framework.
Acknowledgements
Ahmad Nouri-Zonoz, Julian Adamek and Martin Kunz acknowledge funding from the Swiss National Science Foundation. Julian Adamek acknowledges additional support from the Dr. Tomalla Foundation for Gravity Research. Farbod Hassani acknowledges funding from the Research Council of Norway (Young Talent Grant, Project No. 345334). All simulations presented in this work were performed using resources provided by Sigma2—the National Infrastructure for High-Performance Computing and Data Storage in Norway (project No. NN12015K). Disclaimer: Co-funded by the European Union. Views and opinions expressed are, however, those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Executive Agency. Neither the European Union nor the granting authority can be held responsible for them.
The numerical results presented in this work were obtained using the CPU and GPU implementations of the same Mercury code, which yield consistent numerical results but differ in computational performance. The power-spectrum analysis was carried out using the CPU version of Mercury, whereas the simulation snapshots were obtained with the GPU version. Both versions of the code are publicly available at: https://github.com/anourizo . The GPU implementation of Mercury is based on the GPU-accelerated framework of gevolution 2.0, for which a reduction in computational cost by a factor of approximately 4.5, measured in node-hours, was reported relative to the earlier CPU implementation [14 ] . A detailed performance and scaling comparison of the CPU and GPU implementations of Mercury, including the computational overhead of the additional scalar-field evolution, is left for future work.
Convergence tests
In this appendix, we assess numerical convergence at the level of both the individual power spectra and their ratios, using the EFT-LH model as a representative case. We first compare the matter and dark-energy density power spectra and their ratio, and then examine the EFT-LH to EFT-kess power-spectrum ratios used in the main analysis. We repeat the simulations with N g r i d = N p c l = 1536 3 N_{\rm grid}=N_{\rm pcl}=1536^3 N grid = N pcl = 153 6 3 , 2048 3 2048^3 204 8 3 , and 3072 3 3072^3 307 2 3 , keeping the box size fixed at L b o x = 4000 h − 1 M p c L_{\rm box}=4000\,h^{-1}\mathrm{Mpc} L box = 4000 h − 1 Mpc . The corresponding Nyquist wavenumbers are k N y ≃ 1.21 k_{\rm Ny}\simeq1.21 k Ny ≃ 1.21 , 1.61 1.61 1.61 , and 2.41 h M p c − 1 2.41\,h\,\mathrm{Mpc}^{-1} 2.41 h Mpc − 1 , respectively. All simulations use the same cosmological and model parameters as in the main analysis.
Figure 13 shows the individual power spectra at z = 0 z=0 z = 0 and z = 1 z=1 z = 1 , together with the relative differences between successive resolutions, P 1536 / P 2048 − 1 P_{1536}/P_{2048}-1 P 1536 / P 2048 − 1 and P 2048 / P 3072 − 1 P_{2048}/P_{3072}-1 P 2048 / P 3072 − 1 . Here and below, the resolution subscript denotes the number of grid points along each direction. The spectra agree well on large scales, while finite-resolution effects become more important towards larger wavenumbers. The departure shifts to smaller physical scales as the resolution is increased, with P 2048 / P 3072 − 1 P_{2048}/P_{3072}-1 P 2048 / P 3072 − 1 remaining closer to zero than P 1536 / P 2048 − 1 P_{1536}/P_{2048}-1 P 1536 / P 2048 − 1 over the resolved range.
Figure 13. Resolution convergence for the EFT-LH model in a L b o x = 4000 h − 1 M p c L_{\rm box}=4000\,h^{-1}\mathrm{Mpc} L box = 4000 h − 1 Mpc box. The upper panels show the matter (left) and dark-energy density (right) power spectra for N g r i d = N p c l = 1536 3 N_{\rm grid}=N_{\rm pcl}=1536^3 N grid = N pcl = 153 6 3 , 2048 3 2048^3 204 8 3 , and 3072 3 3072^3 307 2 3 at z = 0 z=0 z = 0 and z = 1 z=1 z = 1 . The lower panels show the relative differences between successive resolutions. The shaded regions indicate 1% and 2% deviations.
To test whether this departure follows the grid scale, we rescale the wavenumber by the Nyquist wavenumber of the lower-resolution simulation in each pair, q = k / k N y , l o w q=k/k_{\rm Ny,low} q = k / k Ny , low . Figure 14 shows the resulting relative differences at z = 0 z = 0 z = 0 for the matter and dark-energy density power spectra, together with those of their ratio R ( k ) ≡ P m ( k ) / P D E ( k ) R(k) \equiv P_{\mathrm{m}}(k)/P_{\mathrm{DE}}(k) R ( k ) ≡ P m ( k ) / P DE ( k ) . The two resolution pairs show a similar scale dependence in q q q for both power spectra, suggesting that the discrepancy begins at approximately the same fraction of the Nyquist wavenumber.
Figure 14. Relative differences between successive resolutions at z = 0 z = 0 z = 0 , shown as a function of k / k N y , l o w k/k_{\mathrm{Ny,low}} k / k Ny , low for the matter power spectrum (left), dark-energy density power spectrum (middle), and their ratio R ( k ) = P m ( k ) / P D E ( k ) R(k) = P_{\mathrm{m}}(k)/P_{\mathrm{DE}}(k) R ( k ) = P m ( k ) / P DE ( k ) (right). Here, k N y , l o w k_{\mathrm{Ny,low}} k Ny , low denotes the Nyquist wavenumber of the lower-resolution simulation in each pair.
As a quantitative reference, the 2% deviation occurs at q ≃ 0.12 q \simeq0.12 q ≃ 0.12 –0.13 0.13 0.13 for the matter power spectrum and at q ≃ 0.15 q \simeq0.15 q ≃ 0.15 –0.16 0.16 0.16 for the dark-energy density power spectrum. If this scaling continues to the production resolution, N g r i d = 3072 3 N_{\mathrm{grid}} = 3072^3 N grid = 307 2 3 , its Nyquist wavenumber gives the estimated 2% resolution scales
k 2 % m ≃ 0.29 h M p c − 1 , k 2 % D E ≃ 0.36 h M p c − 1 . (73) k_{2\%}^{\mathrm{m}} \simeq0.29\,h\,\mathrm{Mpc}^{-1}, \qquad k_{2\%}^{\mathrm{DE}} \simeq0.36\,h\,\mathrm{Mpc}^{-1}. \tag*{(73)} k 2% m ≃ 0.29 h Mpc − 1 , k 2% DE ≃ 0.36 h Mpc − 1 . (73)
These extrapolated scales provide an indication of resolution sensitivity rather than a direct measurement of the absolute numerical error of the production runs. In contrast to the individual spectra, the ratio R ( k ) R(k) R ( k ) shows much smaller differences between resolutions, with Δ R / R \Delta R/R Δ R / R remaining within approximately 1% over most of the plotted range. This indicates a substantial cancellation of resolution effects in this ratio.
We next test whether a similar cancellation occurs in the model comparisons presented in the main text. Figure 15 shows Q X , N = P X , N E F T − L H / P X , N E F T − k e s s Q_{X,N} = P^{\mathrm{EFT-LH}}_{X,N}/P^{\mathrm{EFT-kess}}_{X,N} Q X , N = P X , N EFT − LH / P X , N EFT − kess , with X ∈ { m , Φ } X \in\{\mathrm{m}, \Phi\} X ∈ { m , Φ } , at all three resolutions. Taking N g r i d = 3072 3 N_{\mathrm{grid}} = 3072^3 N grid = 307 2 3 as the reference, we define Δ Q X / Q X = Q X , N / Q X , 3072 − 1 \Delta Q_X/Q_X = Q_{X,N}/Q_{X,3072} - 1 Δ Q X / Q X = Q X , N / Q X , 3072 − 1 , with N ∈ { 1536 , 2048 } N \in\{1536, 2048\} N ∈ { 1536 , 2048 } . For N g r i d = 2048 3 N_{\mathrm{grid}} = 2048^3 N grid = 204 8 3 , these differences remain within approximately 2% over the plotted range at z = 0 z = 0 z = 0 and z = 1 z = 1 z = 1 . The N g r i d = 1536 3 N_{\mathrm{grid}} = 1536^3 N grid = 153 6 3 simulation shows larger differences on small scales, exceeding 2% at z = 1 z = 1 z = 1 . The reduced resolution sensitivity of these model ratios supports a more robust interpretation of the relative model signatures on smaller scales than is possible from the individual spectra alone.
Figure 15. Ratios of the EFT-LH to EFT-k e s s k_{\rm ess} k ess power spectra for matter (left) and the spatial metric potential Φ \Phi Φ (right), shown at z = 0 z = 0 z = 0 and z = 1 z = 1 z = 1 for simulations with N g r i d = N p c l = 1536 3 N_{\rm grid} = N_{\rm pcl} = 1536^3 N grid = N pcl = 153 6 3 , 2048 3 2048^3 204 8 3 , and 3072 3 3072^3 307 2 3 . The lower panels show the relative differences with respect to the N g r i d = 3072 3 N_{\rm grid} = 3072^3 N grid = 307 2 3 simulation, with shaded bands indicating 1% and 2% deviations.