WorksPhysics and Astronomy
Simple multi-interacting fluids in SymBoltz
Abstract
We implement a simple and general way of specifying arbitrary interactions between baryons, dark matter and dark energy in the Einstein–Boltzmann code SymBoltz. Due to the symbolic-numeric interface and approximation-free structure of SymBoltz, the model definition is remarkably compact and convenient to modify by specifying only the covariant coupling. The full equations are stiff, but stable and fast to integrate with an efficient implicit solver, particularly with the sparse and analytical ODE Jacobian generated from the symbolic equations. We first validate it using single-interaction models, comparing their background evolution and matter and CMB power spectra with those from modified versions of CLASS, finding – agreement at most scales. Finally, we show how our framework makes it trivial to implement models with any interactions of any complexity among all three species simultaneously, which requires a more involved implementation in other Einstein–Boltzmann codes like CLASS or CAMB. Our full model is specified in only around 300 lines of code and is easy to modify for any other interaction by just specifying it in three lines.
Introduction
SymBoltz1 is a recently introduced Einstein–Boltzmann solver written in the Julia programming language. It is completely free of approximation schemes that complicate other codes such as CAMB [2, 3] and CLASS [4, 5], and it has a symbolic-numeric interface that makes it convenient to specify and modify equations. These features are useful for implementing models with interactions between multiple species.
First, approximation-freeness means that only the full and stiff Einstein–Boltzmann equations have to be specified, and it is not necessary to derive and implement approximations to the equations in different regimes. In CLASS, for example, the tight-coupling approximation (TCA) [5] is mandatory to circumvent stiffness of the equations in the early universe. Interacting models generally introduce additional stiffness and modify the equations underlying the TCA, requiring new or modified approximation schemes. Other approximations such as the radiation streaming approximation (RSA), ultra-relativistic fluid approximation (UFA) and non-cold dark matter fluid approximation (NCDMFA) [5, 6] are in principle optional and can be disabled, but are often necessary in practice because the code relies on them for the speed of solving the perturbation equations. SymBoltz instead uses the efficient implicit Rodas5P ODE solver [7] to handle stiffness, and provides it with fast numerical code for the ODE and its sparse and analytical Jacobian generated by the symbolic-numeric interface. This makes it possible to directly implement the full modified equations once, without spending effort on re-deriving, re-implementing and re-validating approximation schemes in different regimes.
Second, the symbolic-numeric interface allows for a convenient, compact and general way of specifying our modified equations. Our full CDM model, with the option to add interactions, is encoded in only around 300 lines of code.2 All variables, parameters and equations for the background and perturbations and for all components are specified in a single place using Unicode characters with one-to-one correspondence with the mathematical notation. The symbolic-numeric engine automatically separates the background and perturbations, splines the background when solving the perturbations, generates optimal numerical code for the ODE and its Jacobian and makes it trivial to obtain any variables from the solution. Moreover, SymBoltz has been updated to version 2 alongside this paper, which makes it possible to integrate the background equations using a mixture of forwards and backwards integration in time. This is particularly useful for interacting models, where the background continuity equations generally lose their analytical solutions, and it is useful to integrate them backwards from present values of the density parameters. Thus, once an interaction has been defined covariantly, its implementation in SymBoltz reduces to three symbolic lines of code. This same prescription applies to any arbitrary interaction, to any number of coupled species and/or simultaneous interactions, making even complicated interacting cosmologies a compact modification.
This paper is organised as follows. § 2 describes the new background integration framework introduced in SymBoltz version 2. Section III establishes the covariant formulation of interactions used. Section IV explains their implementation. § 5 presents the validation against CLASS. Section VI presents a realistic application as a prototype use case. Finally, Section VII summarises our conclusions.
SymBoltz version 2
SymBoltz version 2 is released alongside this paper. In particular, it updates the symbolic-numeric framework to let users easily specify models where some background3 equations are integrated forwards in time, while others are integrated backwards. For example, the background ODEs (including thermodynamics and RECFAST recombination) we consider here have the following structure (in this section and is the time variable used in the code, but we will later formulate our equations with conformal time):
Baryon density:
integrated from and backwards,
Dark matter density:
integrated from and backwards,
Dark energy density:
integrated from and backwards,
Lookback time:
integrated from and backwards,
Conformal time:
integrated from and forwards,
Hydrogen ionization:
integrated from and forwards,
Helium ionization:
integrated from and forwards,
Baryon temperature:
integrated from and forwards,
Optical depth:
integrated from and backwards.
The continuity equations for 4 are numerically integrated backwards because we parameterise them by their present density parameters , and . Conversely, thermodynamics equations are integrated forwards because their fully ionised initial conditions are in the early universe. This is a generalisation of the equations for the standard CDM model, where the non-interacting continuity equations have analytical solutions with constant equations of state in the background. As illustrated in Figure 1, the background system (2.1) admits five stages, and the best way to integrate them is to join stages 1 + 2 and 3 + 4:

Figure 1. SymBoltz version 2 automatically creates a dependency graph between all variables in the user-specified background equations. An arrow means that (and hence ) depends on . SymBoltz identifies cycles in this graph (here with the same color), which must be integrated as one coupled ODE. Different cycles are disconnected or connected by one-way arrows, which constitute stages of the equations that can be integrated sequentially, each using splined input of earlier stages. Variables without outgoing arrows correspond to integrals. Each variable is marked with a preferred integration direction (forwards or backwards ), and all variables in the same coupled stage must have the same direction. Here the background system (2.1) admits 5 stages (going clockwise from 12 o’clock), and stages 1 + 2 and 3 + 4 can be merged because they share direction.
With the latest SymBoltz update, the user only needs to write down the full background (and perturbation) equations together, and the symbolic-numeric framework automatically inspects them and finds the dependency graph between all variables. If the user requests some variables to be integrated backwards and others forwards, the code will check if the inter-dependencies allow the system to be split in this way, and if so split the background ODEs into appropriate stages. This can be understood as a generalisation of the background.c → thermodynamics.c → ... structure in CLASS [4], such that the number of background stages is not hardcoded to 2. We emphasise that this machinery is not custom-tailored to one particular model, but made to be general with the ambition of supporting equations with arbitrary mixtures of forward-backward integration.
For example, CLASS supports non-interacting continuity equations with by first evaluating backwards, and then integrating the continuity equation forwards as an ODE. This falls naturally into the general backwards-forwards integration framework in SymBoltz by first doing backwards integration on the integral.
The alternative to integrating backwards is to only integrate forwards, but use the shooting method to find the initial conditions at that give the desired densities at . This is also supported in SymBoltz. It amounts to solving the following root-finding problem for , and , where , and are computed by integrating an ODE forwards:
Here the differentiability of SymBoltz is used to compute the Jacobian of to help Newton methods converge to the right root. Whether backwards integration or shooting is better is model-dependent and comes down to where the initial conditions are known, the stability of the integration direction of the equations and the stability of the parameter space of the model. For the interacting models here we find backward and forward integration of the continuity equations to be equally stable, but with the shooting method we find it challenging to find initial guesses for that avoid running into physically unstable regions in parameter space (e.g. with negative energy densities) for general interactions. Shooting must also solve the background several times, while backwards integration solves it only once. Our preferred approach is therefore backwards integration to avoid shooting.
The ambition with SymBoltz version 2 is that mixed backwards-forward integration in conjunction with the shooting method constitutes a framework for treating the boundary-value nature of the background equations for many cosmological models in a general way.
Theory
We consider scalar perturbations in the Newtonian gauge, following [8]:
Here is the scale factor, and are the Bardeen potentials, is conformal time and we use comoving spatial coordinates . Primes will denote derivatives with respect to conformal time , and the conformal Hubble rate is . The energy-momentum tensor for a generic matter component is:
The background has energy density and pressure , while and are first order density and pressure perturbations. We consider perfect fluids with vanishing anisotropic stress tensor , although the formalism can be extended to include anisotropic stresses. The quantity is the fluid velocity perturbation, which is commonly defined in terms of a velocity potential:
For each component , we define an equation of state , density contrast , velocity potential , and the physical sound speed in the fluid rest frame (rf):
In an arbitrary (non rest) frame we have the relation
where the adiabatic sound speed is defined as
Having specified the metric, fluid variables and sound speed conventions, we can now write the evolution equations in the absence of interactions. In this case, each component conserves its energy-momentum tensor independently with . In the background, this leads to the continuity equation
At the perturbative level, it leads to the density contrast and Euler equations for each perfect fluid component5 [8]
However, these equations change when we add interactions through a covariantly defined transfer four-vector .
Covariant formulation of interactions
Coupling terms introduced at the level of the background continuity equation are a useful phenomenological starting point. However, this description is not enough once perturbations are included, since a covariant formulation is needed. We therefore introduce the interaction for each component through a four-vector source:
The second condition guarantees total energy-momentum conservation. For later convenience we decompose the four-vector source as [9, 10, 11]
with . Here is the background energy-transfer rate, is its perturbation, and is the scalar momentum transfer potential. The vector defines the reference frame in which the energy transfer is measured, and need not coincide with the four-velocity of any fluid. Following the velocity conventions (17), we write it as
At the level of each matter component , the above decomposition of the interaction translates into
The condition implies
For the special case of two interacting fluids, this reduces to , and . We have now decomposed into , and . This sets all the rules for computing the relevant quantities and equations that describe the evolution of both the background and perturbations with any number of interacting components.
In the background, the continuity equation for each interacting component becomes
For the squared physical sound speed and adiabatic sound speed (20), we get the relations
With the conventions established above and the additional four-velocity source components (29), the perturbed continuity and Euler equations for each component become6 [10, 13]
The reference frame velocity is , as explained around equation (28). With our chosen decomposition (3.11), and enter the continuity and Euler equations separately, while is a background quantity and enters both.
Hubble rate, local expansion and the choice of reference frame
Consider an interaction whose background coupling can be written as , where is any scalar and is the Hubble rate. A frequently adopted phenomenological prescription is to treat as unperturbed, which leads to . At the homogeneous level, the Hubble rate is unambiguous. In the perturbations, however, alone does not define a unique local covariant quantity, so a covariant completion is required. Thus, we must specify a timelike congruence , which at the linear level is nothing more than specifying a velocity reference frame, and replace the Hubble function by the expansion scalar . Therefore, the phenomenological choice of not perturbing leads to an incomplete covariant specification of the interaction. Although often sufficient in the past, neglecting the perturbation of the local expansion may affect current and future precision observations.
Following the ambition of SymBoltz to solve the complete Einstein–Boltzmann system with no approximation schemes, we include the fully covariant formulation here. In the background is simply , while up to first order it is [9, 11]
In the decomposition (3.11) of , we introduced the four-vector of the reference frame in which the energy transfer is measured without defining exactly what that frame would be. In this work we adopt the total energy frame as the reference frame. It is constructed from the velocities of all cosmological components weighted by their respective inertial densities, which provides a natural and general prescription for the frame in which the energy transfer is measured. In our notation that means:
We put a hat on variables related to the total weighted velocity from now on. Other choices for the reference frame are possible, in fact any other choice of the congruence is perfectly acceptable if used consistently. Given any choice, we end up with
where and are respectively the background expansion and its linear perturbation associated with the chosen congruence. In this work, we use the total energy frame defined above.
Implementation in SymBoltz
In this section we show how interacting cosmological models can be implemented in SymBoltz. We want to show that the code for implementing a new interaction in SymBoltz is considerably more direct than in previous works or Einstein–Boltzmann codes, no matter how elaborate it may be or even if the interaction modifies several fluids or depends non-linearly on the densities. Only three functions have to be implemented, following the decomposition explained in Section III.a.
Once the user has expressions , and for the interaction between one or more fluid pairs , they are ready to be implemented in SymBoltz. We adopt the following sign convention for (and for , and ) to satisfy condition (30):
We modify the minimal CDM example in the code documentation, where every variable, parameter and equation of the entire standard model is specified in around 300 lines of code. This example is straightforward to modify with arbitrary interaction equations. To not duplicate the entire model for every interaction, we wrap this in a function interacting_model(Qbc, δQbc, fQbc, QbΛ, ...)7 that takes arbitrary interaction expressions as input. This function can now be used to create models with arbitrary pairwise interactions by passing symbolic expressions. We first create a non-interacting model M to get a handle to all its symbolic expressions, and then create several interacting_model() instances with arbitrary interaction expressions. For example, to conveniently construct the interacting model (43):
# Build non-interacting base model to access its symbolic variables
M = interacting_model()
@unpack a, ℋ, ρc, ρΛ, δc, δΛ, θ, θc, θΛ, Ψ, Φ, k, αcΛ = M
# Create interacting model instances
M1 = interacting_model(
name = :ζCDM,
QcΛ = αcΛ * ℋ * ρΛ / a,
δQcΛ = αcΛ * ℋ * (ℋ * ρΛ + (ρΛ*δΛ - ρΛ*Ψ) + ρΛ * (Θ/3 - Dτ(Φ))),
fQcΛ = αcΛ * ℋ * ρΛ / (a*k^2) * (θc - θ),
)
Other interacting models are constructed similarly. This makes it easy to create many different interacting models.
Validation
We now compare some simple examples of interacting models in SymBoltz with modified versions of the well-established CLASS code from earlier works. Our goal is to demonstrate that SymBoltz reproduces the evolution of the background and perturbations with a similar level of precision as CLASS. First we consider standard cosmological models without interactions, then pure momentum transfer models, and finally models with both energy and momentum exchange (see [14] for a recent review on interactions). This allows us to separately check the standard non-interacting evolution, modifications affecting only the perturbations, and cases in which the interaction also changes the background evolution.
We compare background densities, the Hubble function, matter power spectra, and angular CMB TT and EE power spectra. We fix the reduced Hubble constant to , the dark matter density today to , the baryon density today to , the helium fraction to , the amplitude of scalar perturbations to , the scalar spectral index to , and use two massless neutrinos and one massive neutrino with total mass eV. Other parameters are fixed to default values. The results of the comparison are similar for other parameter values.
Reference cases: no interactions
As a reference case, we first compare SymBoltz with CLASS for the non-interacting CDM, CDM and CDM models, the latter of which includes the Chevallier–Polarski–Linder (CPL) dark energy parametrization [15, 16]. The first and most important result is that SymBoltz reproduces accurate results for these standard models in the absence of interactions. Figure 2 and Figure 3 compare one CDM model, two representative CDM models and two representative CDM models. In the background, the cold dark matter density , baryon density , dark energy/cosmological constant density and Hubble rate from SymBoltz follow the corresponding CLASS curves closely in all five cases. The curves lie on top of each other and the relative difference with respect to CLASS remains well below 0.001%. The matter power spectrum agrees below the 1% level for all h/Mpc. Finally, the CMB power spectra also agree well within 1% except at very low multipoles in the EE spectrum, where the spectrum approaches zero. The resulting spike in the relative difference is therefore caused by the normalization to a vanishingly small CLASS value, rather than by a significant absolute discrepancy between the two codes. This is also the domain where cosmic variance dominates the uncertainty anyway.

Figure 2. Background comparison between CLASS and SymBoltz for CDM (black), CDM with (red) and (blue), and CDM with (green) and (gold). The upper panels show the background evolution, while the lower panels show the relative difference, calculated as .

Figure 3. Comparison of matter, CMB TT and CMB EE power spectra (left to right) between CLASS and SymBoltz for CDM (black), CDM with (red) and (blue), and CDM with (green) and (gold). The lower panels show the logarithm of the relative difference .
Pure momentum transfer
Now we consider interacting models implemented in SymBoltz. We begin with the simplest case one can imagine: the trilogy of momentum transfer models. Here a coupling between the velocities of two species appears in their Euler equations (hence the name), while the perturbed continuity equation is unchanged in form (but not solution) and the entire background evolution is unchanged. One of the first appearances of these models dates back to Ref. [17], but a plethora of models around the original one have emerged [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32].
Here we consider three example models that we implement in SymBoltz: the CDM model [33], the CDM model [34] and the CDM model [35]. For these models we have access to corresponding modified versions of CLASS, which we can then compare with SymBoltz.
Dark energy – dark matter
A pure momentum interaction between dark matter and dark energy was first studied in Ref. [33] and more recently extended in Ref. [25]. The interaction is defined by , and the decomposition of Section III.a gives:8
This is implemented in SymBoltz as described in Section IV, and a corresponding modified version of CLASS9 is available. Figure 4 and Figure 5 again show the comparison between SymBoltz and CLASS. The background is not modified by this interaction, but we compare it again because the modified version of CLASS is different from the base version of CLASS used in the first non-interacting comparison. Both the background and the matter and CMB power spectra remain in similar agreement as in the non-interacting case, with similar 0.1%–1% differences in the power spectra. This holds over a large range of coupling parameters . Consequently, the SymBoltz implementation demonstrates a very good match with previous implementations.

Figure 4. Background comparison between CLASS and SymBoltz as in Figure 2, but for the αCDM model (40).

Figure 5. Power spectrum comparison between CLASS and SymBoltz as in Figure 3, but for the αCDM model (40).
Dark energy – baryons
A pure momentum interaction between baryons and dark energy was first studied in [34] inspired by Ref. [36]. The interaction is defined by , and the decomposition gives:
In Figure 6 we again compare the matter and CMB power spectra, while we omit the comparison of the background because it is not altered and we showed above that SymBoltz and CLASS are indistinguishable here. The matter and CMB power spectra again agree with less than 1% difference.

Figure 6. Power spectrum comparison between CLASS and SymBoltz as in Figure 3, but for the CDM model (41).
Dark matter – baryons
Finally, a pure momentum interaction between dark matter and baryons was first studied in Ref. [35]. The interaction is defined by
and the decomposition gives:
We again omit the comparison of the unchanged background. The matter power spectrum in Figure 7 agrees well below the 1% level for linear scales, but some percent-level differences appear at smaller scales for very high . Here a non-linear prescription or -body analysis is needed for accurate results anyway. On the other hand, the CMB spectra continue to agree well within 1% for different coupling values, similarly as before.

Figure 7. Power spectrum comparison between CLASS and SymBoltz as in Figure 3, but for the CDM model (42).
Dark energy – dark matter: energy and momentum transfer
Previous interactions involved only a pure momentum exchange and did not change the background evolution from the standard non-interacting CDM, CDM and CDM models. Now we extend the testing of the capabilities of SymBoltz to scenarios in which energy is also transferred and the background evolution is changed. This will also serve as a test of the backwards integration capabilities of SymBoltz version 2 explained in § 2, since the interacting continuity equation has no analytical solution for general and must be solved using either the shooting method or backwards integration. As our example model, we consider a dark energy – dark matter interaction with both energy and momentum transfer, first using a linear interaction term and then a non-linear one. Both cases have well-known analytical solutions for the background densities and Hubble function which we have implemented in the CLASS versions. However, in SymBoltz we have not used them. For the background in SymBoltz we followed the general prescription for interactions, so a triad is introduced in each case, and then solved the background equations with the new backwards integration of SymBoltz version 2. The comparison will show the capabilities of SymBoltz to correctly solve the background dynamics with this new backwards integration possibility.
Linear coupling
We consider a linear coupling between dark energy and dark matter (several examples can be found in Refs. [11, 37, 38, 39, 40, 41, 42]) defined by , which translates to the following decomposition.10
Figures 8 and 9 again display the background evolution of the different energy densities of the interacting and non-interacting components, the matter power spectrum and the CMB power spectra for several values of the coupling parameter from SymBoltz and compare them to CLASS. For the background evolution, we see that both codes agree very well up to a difference well below 0.001% in the densities of the interacting components, and . Moreover, the differences for the interacting and non-interacting components are comparable. The resulting Hubble function depends on all the densities and agrees to a similar level as before. Consequently, even when the interaction affects the background evolution, the codes are in very good agreement. For the perturbations, the matter and CMB power spectra from both codes agree within a similar 0.1%–1% level as before (the spikes in the matter power spectrum errors are due to zero crossings since we are representing the absolute relative difference). Even for unrealistic values of the coupling, like , which have an extremely suppressed matter power spectrum and a CMB spectrum incompatible with Planck, the codes differ below or around 1%. Consequently, we have demonstrated that SymBoltz can handle interacting models as precisely as other Boltzmann codes, and with a user-friendly way of implementing them by just writing three lines of code with the details of the interaction and with no approximation-switching schemes.
Figure 8. Background comparison between CLASS and SymBoltz as in Figure 2, but for the linear DE–DM interaction (43).

Figure 9. Power spectrum comparison between CLASS and SymBoltz as in Figure 3, but for the linear DE–DM interaction (43).
Non-linear coupling
We now consider a non-linear coupling between dark energy and dark matter. Some examples of such models are found in Refs. [43, 44, 45]. The interaction is defined by the four-vector
and the decomposition gives:
Figures 10 and 11 again compare the background and matter and CMB power spectra from SymBoltz and CLASS for several values of the coupling . Although the modifications produced by this interaction are phenomenologically similar to those obtained in the linear case, studying this model provides a non-trivial additional test. The energy-transfer rate now depends non-linearly on the background densities, and both codes must consistently evaluate this non-linear dependence and its corresponding first-order perturbation throughout the cosmological evolution. In the background, we again see that the densities and Hubble function agree well below 0.001%. The power spectra also agree very well within 0.1%–1% for almost all scales and multipoles in a similar way as before. This demonstrates that SymBoltz handles non-linear interacting models as precisely as other Boltzmann codes.

Figure 10. Background comparison between CLASS and SymBoltz as in Figure 2, but for the non-linear DE–DM interaction (5.6).

Figure 11. Power spectrum comparison between CLASS and SymBoltz as in Figure 3, but for the non-linear DE–DM interaction (5.6).
This validation of several interacting models establishes SymBoltz as a precise and powerful framework for studying interacting cosmologies, while also making it simple to modify and extend. Any new interaction can be implemented by specifying only the three quantities , and , each of which can be decomposed from an interaction four-vector . In practice, incorporating a new interaction amounts to adding only a single line for each of these three quantities. The agreement of SymBoltz with CLASS for standard non-interacting cosmologies, pure momentum transfer models, and both linear and non-linear energy-momentum transfer models demonstrates that the code accurately reproduces the background and perturbation evolution across a broad range of physically distinct scenarios.
SymBoltz achieves this accuracy while solving the full stiff Einstein-Boltzmann system using implicit ODE solvers without relying on approximation switching schemes. The absence of approximation switching schemes is particularly helpful when an interaction modifies a component that takes part in such schemes, such as the baryons. In conventional Boltzmann codes, the interaction must also be consistently propagated through the corresponding approximation regimes and switching conditions. Most importantly, this capability not only works for the standard model, but is preserved when the cosmological model is modified. A new interaction is introduced directly through the three quantities , and , which are incorporated into the same general system of equations. Thus, SymBoltz combines the precision required for cosmological predictions with a flexible and easy-to-modify structure that makes the exploration of general interacting models direct, systematic, and considerably simpler than modifying a conventional Boltzmann code.
Multiple interactions at the same time
Finally, to really highlight the simplicity of SymBoltz when dealing with modifications, we consider a model with multiple pairwise interactions between dark energy, dark matter and baryons at the same time:11
Following the general decomposition in Section III.a for each of the interactions now gives:
Table 6.2.
We continue to use the sign convention (39) to guarantee the conservation of the total energy-momentum (30). This gives the total , and “influxes” to each component:
This guarantees cancellation of the energy and momentum transfers when all components are added together, so the total stress-energy tensor is covariantly conserved for the interacting components both in the background and perturbations. That is, .
This complicated system is implemented in SymBoltz in the very same simple way as all the previous test cases. By just writing the expressions (6.2) for the , and into the “factory function” interacting_model() as explained in Section IV, SymBoltz automatically creates the correct background and perturbation equations with no other necessary modifications from the user. Then the user only needs to specify the desired values of the coupling parameters and solve the resulting background and perturbation equations. Taking the interactions (6.2) as an example model and a proof of concept for the utility of SymBoltz, the user only has to write the following code:
M = interacting_model()
@unpack a, ℋ, ρb, ρc, ρΛ, δb, δc, δΛ, θ, θb, θc, θΛ, Ψ, Φ, k, αbc, αbΛ, αcΛ = M
# Background energy transfers
Qbc = αbc * ℋ / a * (ρb + ρc)
QbΛ = αbΛ * ℋ / a * (ρb + ρΛ)
QcΛ = αcΛ * ℋ / a * (ρc + ρΛ)
# Perturbations of the energy transfers
δQbc = αbc * ℋ / a * (ρb * δb + ρc * δc - (ρb + ρc) * Ψ) + αbc * (ρb + ρc) / a * (θ / 3 - Dτ(Φ))
δQbΛ = αbΛ * ℋ / a * (ρb * δb + ρΛ * δΛ - (ρb + ρΛ) * Ψ) + αbΛ * (ρb + ρΛ) / a * (θ / 3 - Dτ(Φ))
δQcΛ = αcΛ * ℋ / a * (ρc * δc + ρΛ * δΛ - (ρc + ρΛ) * Ψ) + αcΛ * (ρc + ρΛ) / a * (θ / 3 - Dτ(Φ))
# Scalar momentum-transfer potentials
fQbc = αbc * ℋ / (a * k^2) * (ρb + ρc) * (θc - θ)
fQbΛ = αbΛ * ℋ / (a * k^2) * (ρb + ρΛ) * (θb - θ)
fQcΛ = αcΛ * ℋ / (a * k^2) * (ρc + ρΛ) * (θc - θ)
M1 = interacting_model(; Qbc, QbΛ, QcΛ, δQbc, δQbΛ, δQcΛ, fQbc, fQbΛ, fQcΛ)
Once the three pairwise interactions have been easily implemented in SymBoltz, we now consider three increasingly complex cases with one, two and three interactions active at a time. For that we only need to set the values of the coupling parameters , and in the code. Figure 12 displays the background evolution with densities and the Hubble rate for each case. Figure 13 and Figure 14 display the matter and CMB power spectra, respectively. Here we have no corresponding implementation in CLASS to compare with, which would take us more effort and care to build, particularly for the case of the interactions involving baryons where we would need to propagate the new coupling terms into the TCA schemes. All that complexity is absent here. This example shows how SymBoltz makes it relatively simple to implement such complex models.

Figure 12. Background evolution for the multi-interacting baryon–dark matter–dark energy model (6.2). From top to bottom: one individual interaction, two simultaneous interactions, and the three interactions active at the same time.

Figure 13. Matter power spectrum for the multi-interacting baryon–dark matter–dark energy model (6.2). From left to right: one individual interaction, two simultaneous interactions, and all three interactions active at the same time.

Figure 14. CMB TT and EE angular power spectra for the multi-interacting baryon–dark matter–dark energy model (6.2). From top to bottom: one individual interaction, two simultaneous interactions, and all three interactions active at the same time.
Conclusion
The main goal of this work is to show how the Einstein–Boltzmann code SymBoltz makes it particularly easy to implement interactions between baryons, dark matter and dark energy in a general, direct and simple way. Starting from SymBoltz’ compact symbolic definition of the full standard CDM model, we created a simple interacting_model(, , ) wrapper function around it that allows specifying arbitrary expressions for the flow of energy and momentum between any pair(s) of fluids . This makes it trivial to prototype arbitrary interactions between any fluids, and in a way where multiple interactions are not much more complex than only one. Our full model definition is available in the code documentation and is easy to modify.12
Of course, the interaction should be physically well-defined and stable. Here we showed how to derive interactions consistently from a covariant formulation and in a way that conserves total energy-momentum by construction. Once this is done, the implementation in SymBoltz is straightforward and only involves typing the symbolic expressions into the code, with no additional boilerplate code.
The symbolic-numeric interface and approximation-free nature of SymBoltz make it possible to write all variables, parameters and equations of the cosmological model in a convenient, uniform and compact modeling language. Support for Unicode characters makes the code equations readable and correspond one-to-one with the mathematical notation. All equations can be specified in a single place as if they are part of one system, but SymBoltz internally splits them into sequential background/perturbation stages with a mixture of forwards-backwards integration to solve them in the optimal way. The Rodas5P implicit solver coupled with efficient generated numerical code for the ODE and its sparse and analytical Jacobian is completely invisible to users, but this internal infrastructure makes the stiff equations stable and fast to solve without complicating the model with approximation schemes.
Concretely, here we first validated a few models with only two interacting species by comparing them to corresponding modified versions of CLASS from earlier works, finding 0.1%–1% difference for matter and CMB power spectra at most scales. We then constructed a proof-of-concept model with interactions between all three species at the same time. This was completely straightforward with our general interacting symbolic model constructor, but would take more effort and care to implement in a conventional code like CLASS due to approximation schemes and more verbose boilerplate code for every operation in the code.
Given the flexibility of SymBoltz, this multi-interacting model can be extended in two possible ways. First, we can consider an interaction that not only modifies the energy-momentum conservation rule but also the thermodynamical evolution of the interacting species. Having an effective modification on the temperature evolution equations of an interacting species can be added with a new variable, say , to the triad (, , ) for each interaction. With the goal of having a general and univocally defined approach, one could consider a framework in which SymBoltz takes the usual interaction triad (, , ) together with the additional micro-physical information needed to specify the exchange of internal energy, and automatically incorporates the corresponding modifications into the temperature evolution equations through its symbolic-numeric framework. Second, we can easily incorporate new species by adding new variables and equations in our model definition, and adding their contributions to the total energy-momentum variables that source gravity. However, our objective here is to test the ease of modifying the code, and we leave these generalisations for future work.
To summarize, SymBoltz provides a direct route from any arbitrarily chosen covariantly specified interaction to full, approximation-free cosmological predictions. This makes the exploration of multi-component interacting cosmologies of any kind straightforward to code with quantitatively reliable calculations that agree very well with established state-of-the-art Boltzmann solvers.
Acknowledgments
The authors thank Hans Winther for useful comments and insightful discussions that helped improve this work. DF acknowledges support from ”Convocatoria de contratación de personal investigador doctor de la UPV/EHU (2024)” and from Project PID2025-174372NB-I00 funded by MICIU/AEI/10.13039/501100011033. HS acknowledges support from the Research Council of Norway under project number 325113.
References
References
- [2]A. Lewis, A. Challinor, and A. Lasenby, Astrophys. J. 538, 473 (2000), arXiv:astro-ph/9911177 [astro-ph].DOI
- [3]A. Lewis, JCAP 10, 013 (2026), arXiv:2607.14854 [astro-ph.CO].DOI
- [4]J. Lesgourgues, arXiv e-prints, arXiv:1104.2932 (2011), arXiv:1104.2932 [astro-ph.IM].arxiv.org/abs/1104.2932
- [5]D. Blas, J. Lesgourgues, and T. Tram, JCAP 2011, 034 (2011), arXiv:1104.2933 [astro-ph.CO].DOI
- [6]J. Lesgourgues and T. Tram, JCAP 2011, 032 (2011), arXiv:1104.2935 [astro-ph.CO].DOI
- [7]G. Steinbach, BIT Numerical Mathematics 63, 27 (2023).
- [8]C.-P. Ma and E. Bertschinger, Astrophys. J. 455, 7 (1995), arXiv:astro-ph/9506072.DOI
- [9]M. B. Gavela, L. Lopez Honorez, O. Mena, and S. Rigolin, JCAP 11, 044 (2010), arXiv:1005.0295 [astro-ph.CO].
- [10]J. Valiviita, E. Majerotto, and R. Maartens, JCAP 07, 020 (2008), arXiv:0804.0232 [astro-ph].
- [11]R. von Martens, L. Casarini, D. F. Mota, and W. Zimdahl, Phys. Dark Univ. 23, 100248 (2019), arXiv:1807.11380 [astro-ph.CO].
- [12]M. C. Pookkillath, A. De Felice, and S. Mukohyama, Universe 6, 6 (2020), arXiv:1906.06831 [astro-ph.CO].DOI
- [13]B. Wang, E. Abdalla, F. Atrio-Barandela, and D. Pavón, Rept. Prog. Phys. 79, 096901 (2016), arXiv:1603.08299 [astro-ph.CO].DOI
- [14]B. Wang, E. Abdalla, F. Atrio-Barandela, and D. Pavón, Rept. Prog. Phys. 87, 036901 (2024), arXiv:2402.00819 [astro-ph.CO].arxiv.org/abs/2402.00819
- [15]M. Chevallier and D. Polarski, Int. J. Mod. Phys. D 10, 213 (2001), arXiv:gr-qc/0009008 [gr-qc].DOI
- [16]E. V. Linder, Phys. Rev. Lett. 90, 091301 (2003), arXiv:astro-ph/0208518 [astro-ph].
- [17]F. Simpson, Phys. Rev. D 82, 083505 (2010), arXiv:1007.1034 [astro-ph.CO].DOI
- [18]A. Pourtsidou, C. Skordis, and E. J. Copeland, Phys. Rev. D 88, 083505 (2013), arXiv:1307.0458 [astro-ph.CO].DOI
- [19]C. G. Boehmer, N. Tamanini, and M. Wright, Phys. Rev. D 91, 123003 (2015), arXiv:1502.04030 [gr-qc].DOI
- [20]A. Pourtsidou and T. Tram, Phys. Rev. D 94, 043518 (2016), arXiv:1604.04222 [astro-ph.CO].
- [21]M. S. Linton, A. Pourtsidou, R. Crittenden, and R. Maartens, JCAP 04, 043 (2018), arXiv:1711.05196 [astro-ph.CO].DOI
- [22]F. N. Chammings, A. Avgoustidis, E. J. Copeland, A. M. Green, and A. Pourtsidou, Phys. Rev. D 101, 043531 (2020), arXiv:1912.09858 [astro-ph.CO].DOI
- [23]L. Amendola and S. Tsujikawa, JCAP 06, 020 (2020), arXiv:2003.02686 [gr-qc].DOI
- [24]J. Beltrán Jiménez, D. Bettoni, D. Figueruelo, F. A. Teppa Pannia, and S. Tsujikawa, JCAP 03, 085 (2021), arXiv:2012.12204 [astro-ph.CO].DOI
- [25]D. Figueruelo et al., JCAP 07, 022 (2021), arXiv:2103.01571 [astro-ph.CO].DOI
- [26]M. S. Linton, R. Crittenden, and A. Pourtsidou, JCAP 08, 075 (2022), arXiv:2107.03235 [astro-ph.CO].DOI
- [27]J. Beltrán Jiménez, D. Bettoni, D. Figueruelo, F. A. Teppa Pannia, and S. Tsujikawa, Phys. Rev. D 104, 103503 (2021), arXiv:2106.11222 [astro-ph.CO].DOI
- [28]X. Liu, S. Tsujikawa, and K. Ichiki, Phys. Rev. D 109, 043533 (2024), arXiv:2309.13946 [astro-ph.CO].DOI
- [29]N. Cruickshank, R. Crittenden, K. Koyama, and M. Bruni, (2025), arXiv:2512.11639 [astro-ph.CO].DOI
- [30]K. Aoki, J. Beltrán Jiménez, M. C. Pookkillath, and S. Tsujikawa, Phys. Rev. D 113, 044053 (2026), arXiv:2504.17293 [astro-ph.CO].DOI
- [31]E. Jensko, E. M. Teixeira, and V. Poulin, (2026), arXiv:2603.10622 [astro-ph.CO].DOI
- [32]J. Beltrán Jiménez, K. Ichiki, X. Liu, F. A. Teppa Pannia, and S. Tsujikawa, (2026), arXiv:2603.15805 [astro-ph.CO].DOI
- [33]M. Asghari, J. Beltrán Jiménez, S. Khosravi, and D. F. Mota, JCAP 04, 042 (2019), arXiv:1902.05532 [astro-ph.CO].DOI
- [34]J. Beltrán Jiménez, D. Bettoni, D. Figueruelo, and F. A. Teppa Pannia, JCAP 08, 020 (2020), arXiv:2004.14661 [astro-ph.CO].DOI
- [35]D. Figueruelo and F. A. Teppa Pannia, (2026), arXiv:2607.22415 [astro-ph.CO].arxiv.org/abs/2607.22415
- [36]S. Vagnozzi, L. Visinelli, O. Mena, and D. F. Mota, Mon. Not. Roy. Astron. Soc. 493, 1139 (2020), arXiv:1911.12374 [gr-qc].DOI
- [37]M. van der Westhuizen, A. Abebe, and E. Di Valentino, Phys. Dark Univ. 50, 102119 (2025), arXiv:2509.04495 [gr-qc].DOI
- [38]J.-H. He, B. Wang, and E. Abdalla, Phys. Rev. D 83, 063515 (2011), arXiv:1012.3904 [astro-ph.CO].DOI
- [39]A. A. Costa, X.-D. Xu, B. Wang, E. G. M. Ferreira, and E. Abdalla, Phys. Rev. D 89, 103531 (2014), arXiv:1311.7380 [astro-ph.CO].DOI
- [40]M. A. van der Westhuizen and A. Abebe, JCAP 01, 048 (2024), arXiv:2302.11949 [gr-qc].DOI
- [41]K. R. Mishra, S. K. Pacif, R. Kumar, and K. P. Bamba, Phys. Dark Univ. 40, 101211 (2023), arXiv:2301.08743 [gr-qc].DOI
- [42]R. C. Nunes, (2026), arXiv:2611.08636 [astro-ph.CO].arxiv.org/abs/2611.08636
- [43]M. van der Westhuizen, A. Abebe, and E. Di Valentino, Phys. Dark Univ. 50, 102120 (2025), arXiv:2509.04494 [gr-qc].DOI
- [44]Y. L. Bolotin, A. Kostenko, O. A. Lemets, and D. A. Yerokhin, Int. J. Mod. Phys. D 24, 1530007 (2014), arXiv:1310.0085 [astro-ph.CO].
- [45]M. Bouhmadi-López, J. Morais, and A. Zhuk, Phys. Dark Univ. 14, 11 (2016), arXiv:1603.06983 [gr-qc].