1 Introduction

Solar neutrinos represent the most abundant source of neutrinos on Earth, with a flux of the order of \(6 \times 10^{10}~\text {cm}^{-2}~\text {s}^{-1}\) [1]. Even though only a small fraction of this flux is actually detectable, due to many production channels resulting in neutrinos with energies below the typical experimental detection thresholds [2], solar neutrinos provide an invaluable source of information for the study of neutrino properties, solar dynamics and Earth internal structure. Historically, solar neutrinos provided the first hints for the non-conservation of leptonic flavours in neutrino propagation [3], when in 1968 the Homestake experiment reported far less solar electron neutrino events [4] than the number expected from the recently developed solar models [5,6,7,8,9,10,11,12,13]. This so-called solar neutrino problem was only solved in 2001, when the SNO collaboration released [14] the measurement of the total flux of active \({}^8\)B neutrinos, that resulted in a close agreement with solar models predictions and implied that the origin of the discrepancy had to be tracked to new physics effects in the neutrino sector. It is now firmly established that the deficit is due to neutrino oscillations [15,16,17], with oscillation parameters as inferred by solar neutrino experiments well in agreement with data from other neutrino sources [18,19,20].

Nowadays, solar neutrinos continue providing invaluable information, being the only known probes that can directly test the interior structure and dynamics of the Sun, thereby providing strong constraints on the solar models parameters [21,22,23], or probe the internal solar dynamics on long time-scales [24]. More exotic production mechanisms such as neutrino emission during intense solar flares [25, 26], neutrino production from cosmic-rays scattering in the solar atmosphere [27] and neutrinos from dark matter annihilation in the Sun [28] can also be probed. On the other hand, the theoretically established solar models allow to study and constrain neutrino properties, from standard oscillation parameters [29, 30] to more hypothetical scenarios such as non-standard interactions [31] or finite magnetic moment [32].

In all these scenarios, an important wealth of statistical information is encoded in the energy spectra for the individual neutrino flavours. Due to neutrino oscillations, however, the spectra on Earth generally differ from the ones at neutrino production, and a proper account of the oscillation dynamics is mandatory in order to compare a theoretical model with data. The oscillation dynamics is in general non-trivial, including three different regimes and corresponding matter effects [33, 34]: propagation within the slowly-changingFootnote 1 matter density within the Sun, propagation in vacuum between Sun surface and Earth, and propagation within Earth featuring a fastly-evolving matter density profile.

In this work we present PEANUTS (Propagation and Evolution of Active NeUTrinoS), an open-source, fast and flexible package to compute the neutrino oscillation dynamics in all the above-mentioned regimes. The emphasis in developing the software has been put on both performance and flexibility: PEANUTS computes the coherent neutrino propagation inside Earth analytically, completely removing the need for time-consuming numerical integrations. Moreover, the user can input any arbitrary solar model, as well as any custom Earth matter density profile, and simulate experiments at any latitude and underground depth. The software can perform the full chain of computations to simulate the expected neutrino spectra for a given solar model, Earth matter density and detector location, or its modules can be called individually, to compute for instance the evolved neutrino state after Earth crossing given an arbitrary initial (coherent or incoherent) state, or the solar angle distribution for an experiment taking data between two arbitrary days of the year. PEANUTSFootnote 2 is provided as an open-source Python package, under the GPL-3.0 license. It can be run standalone in various different ways, as well as interfaced from other frameworks. Details of the various software requirements and dependencies, as well as instructions on how to use PEANUTS can be found in Sect. 6, whereas the specific functions and classes that perform the computations will be scattered through whenever the physical quantity computed is introduced. We have extensively validated our implementation against the results of the SNO experiment [35, 36], details of which will also be located where useful, including a final comparison of likelihood contours for our simulation of the experiment with the probabilities computed by PEANUTS.

This document is thus structured as follows. Section 2 describes the theoretical background for the computation of the solar neutrino flux and the propagation of the neutrinos from the Sun. In Sect. 3 we describe the effect of Earth regeneration of the neutrino flux, i.e. the propagation of neutrinos through the Earth, followed by a detailed explanation of our fast approximation for the neutrino propagation Hamiltonian in Sect. 4. Section 5 details the time integration over the exposure of a given experiment. For interested users, Sect. 6 provides a quick start guide to PEANUTS and a explanations on how to reproduce our validation procedure. Lastly, we provide our conclusions and outlook in Sect. 7.

2 Solar neutrino flux

2.1 Neutrino survival probability at Sun surface

Solar neutrinos are produced over a wide region within the Sun, making the incertitude over the production point much larger than the typical detectors size (in fact, much larger than the Earth itself. See e.g. Fig. 1) [37]. This feature implies that the solar neutrino flux at Earth is given by an incoherent superposition of neutrino mass eigenstates [38, 39], whose composition remains constant as the flux propagates in vacuum.Footnote 3 If the neutrino oscillation length-scale is much smaller than the scale over which matter density varies significantly, neutrino oscillations in matter proceed adiabatically [41]; the values of the neutrino oscillation parameters inferred by global fits of neutrino data [18,19,20] imply that the adiabatic regime is realised for solar neutrinos as they propagate from the production point towards the Sun surface. In the adiabatic approximation, the neutrino flavour composition at the Sun surface only depends on the matter effects at neutrino production point.

Fig. 1
figure 1

Solar density (left) and fraction of solar neutrinos produced (right), as a function of relative radius \(r \equiv R/R_\odot \), from Solar model BS05(AGS,OP) [2]

Given \(U=U(\theta _{12}, \theta _{13}, \theta _{23}, \delta )\) the PMNS mixing matrix in vacuum (cf. Eqs. (15, 16)), it is possible to define an analogous matrix T that diagonalises the neutrino Hamiltonian in matter by simply replacing the vacuum values of \(\theta _{12}, \theta _{13}\) with their matter-rotated ones [42, 43]Footnote 4:

$$\begin{aligned}{} & {} \cos 2 \widetilde{\theta }_{13} = \frac{ (\cos 2\theta _{13} -A/\Delta m^2_{ee}) }{ \sqrt{(\cos 2\theta _{13}-A/\Delta m^2_{ee})^2 + \sin ^22\theta _{13}}}, \end{aligned}$$
(1)
$$\begin{aligned}{} & {} \cos 2 \widetilde{\theta }_{12}=\nonumber \\{} & {} \frac{ ( \cos 2\theta _{12} - A^{\,\prime } /\Delta m^2_{21} ) }{ \sqrt{(\cos 2\theta _{12} -A^{\,\prime } /\Delta m^2_{21})^2 + \sin ^2 2 \theta _{12} \cos ^2( \widetilde{\theta }_{13}-\theta _{13})}}, \nonumber \\ \end{aligned}$$
(2)

where \(\theta _{12}, \theta _{13}\) are the PMNS mixing angles in vacuum, \(\widetilde{\theta }_{12},\widetilde{\theta }_{13}\) the corresponding ones in matter,

$$\begin{aligned} A = 2 E V = 2 \sqrt{2} E G_F n_e \end{aligned}$$
(3)

represents the matter potential for a neutrino with energy E travelling in a medium with electron density \(n_e\), \(G_F\) is the Fermi constant,

$$\begin{aligned} A^{\,\prime } \equiv A \, \cos ^2 \widetilde{\theta }_{13} +\Delta m^2_{ee} \sin ^2 ( \widetilde{\theta }_{13}-\theta _{13} ) \end{aligned}$$
(4)

is the \(\theta _{13}\)-modified matter potential and

$$\begin{aligned} \Delta m^2_{ee} \equiv \cos ^2 \theta _{12} \Delta m^2_{31} + \sin ^2 \theta _{12} \Delta m^2_{32}. \end{aligned}$$
(5)

The matrix T is then simply defined as

$$\begin{aligned} T\left( E, n_e\right) = U(\widetilde{\theta }_{12}, \widetilde{\theta }_{13}, \theta _{23}, \delta ). \end{aligned}$$
(6)

Notice that the matrix T depends both on local matter density and energy of the produced neutrino.

Numerically (cf. eqs. 4.17, 4.18 in [46])

$$\begin{aligned} V= & {} \sqrt{2} G_F n_e = \frac{3.868 \times 10^{-7}}{\text {m}} \times \frac{n_e}{\text {mol}/\text {cm}^3}, \end{aligned}$$
(7)
$$\begin{aligned} k= & {} \frac{\Delta m^2}{2 E} = \frac{2.533}{\text {m}} \times \frac{\Delta m^2}{\text {eV}^2} \times \frac{\text {MeV}}{E}, \end{aligned}$$
(8)

where the wavenumber k is useful in the relation

$$\begin{aligned} \frac{A}{\Delta m^2} = \frac{2 \sqrt{2} E G_F n_e}{\Delta m^2} = \frac{V}{k}. \end{aligned}$$
(9)

The probability of producing a neutrino mass eigenstate i in matter is thus \(\left| T_{\alpha i}\left( E, n_e \right) \right| ^2\), where \(\alpha \) is the flavour of the charged lepton entering the neutrino production vertex.

PEANUTS assumes the validity of the adiabatic regime when computing the solar neutrino flux, as this guarantees a fast computation and is an excellent approximation for the neutrino oscillation parameters realised in the standard 3-flavour mixing scheme [35, 47,48,49,50]. Hence, it provides a function for the computation of the matrix T in Eq. (6), with signature

figure a

where the arguments correspond, respectively, to \(\theta _{12}\), \(\theta _{13}\), \(\Delta m_{21}^2\) (eV\(^2\)), \(\Delta m_{3\ell }^2\) (eV\(^2\)), E (MeV) and \(n_e\) (mol/cm\(^3\)). Note that in PEANUTS the input variable \(\Delta m_{3\ell }\) has different meanings according to the ordering of neutrino mass eigenstates. In normal ordering (NO) \(l=1\), and thus \(\Delta m_{31}^2 = \Delta m_{3\ell }^2\) and \(\Delta m_{32}^2 = \Delta m_{3\ell }^2 - \Delta m_{21}^2\), whereas for inverted ordering (IO) \(l=2\), so \(\Delta m_{32}^2 = \Delta m_{3\ell }^2\) and \(\Delta m_{31}^2 = \Delta m_{3\ell }^2 + \Delta m_{21}^2\). PEANUTS also provides accessible functions for the mixing angles in matter \(\widetilde{\theta }_{12}\) and \(\widetilde{\theta }_{13}\), as well as useful quantities such as \(\Delta m_{ee}^2\) and the ratio V/k, in the form of the functions

figure b

In the adiabatic approximation neutrinos evolve as pure mass eigenstates within the Sun. For a fixed value of neutrino energy E, the flux composition at Sun surface is given by the average over the neutrino production points inside the Sun. Assuming spherical symmetry, if f(r) is the fraction of neutrinos produced at point \(r \equiv R/R_\odot \), where \(R_\odot \) is the solar radius and R the distance from the center of the Sun, the probability of a solar neutrino with energy E to emerge as mass eigenstate i is

$$\begin{aligned} P_{\nu _e \rightarrow \nu _i}^\odot (E) = \int _0^1 \text {d}r \left| T_{e i}\left( E, n_e(r) \right) \right| ^2 f(r), \end{aligned}$$
(10)

with the normalization

$$\begin{aligned} \int _0^1 \text {d}r f(r) = 1. \end{aligned}$$
(11)

The computation of f(r) assumes a specific solar model. In our validation of PEANUTS we use the BS05(AGS,OP) model [2],Footnote 5 which is one of the models assumed by the SNO collaboration in their neutrino oscillation fit [35]. Figure 1-left shows the value of solar matter density \(n_e(r)\) as a function of solar radius r in the BS05(AGS,OP) model, while Fig. 1-right shows the neutrino production fractions for different production chains. Note that the electron density in [2] is given in units of \(\frac{1}{\text {cm}^3 N_A} = \frac{\text {mol}}{\text {cm}^3\ 6.022 \cdot 10^{23} }\).

The choice of a particular solar model is encoded in PEANUTS as the Python class . Through the constructor of the class, of signature,

figure d

one can select the location of a file describing the chosen solar model with the optional argument . By default, when no other file location is provided, PEANUTS will assume the use of the BS16(AGSS09) model [51]. At the time of publication, PEANUTS can also work out of the box with the B16 (GS98) [51] model, the BS05(AGS,OP) and BS05(OP) models [2], and the BP00 [37] solar model. The user is nevertheless encouraged to implement their own solar model (and thus neutrino fraction distribution f(r)), by providing a custom solar model file via the optional argument and/or flux file with (they will be assumed to be the same if the latter argument is missing), but in such case one must also specify the rows and columns where the relevant information in the files can be located. The options and sets the rows and columns in where one can find the total neutrino flux per fraction, which can be either dictionaries or real numbers, but at least one of the two must be a dictionary with the names of the fractions of interest and the corresponding row or column. If the fluxes must be rescaled, the option can be provided, which can be a real number, for blanket rescaling of all fluxes, or a dictionary with different rescaling for each fraction. The option points to the first row of the table in containing the distributions, i.e. the radius, density and fraction samples, whose columns must also be specified with the options , and , respectively, with the latter a dictionary of names and columns of the fractions of interest. Naturally all of these optional arguments must be provided if the solar model file is not known to PEANUTS.

In addition to allowing the selection of different solar models, PEANUTS also allows the use of different energy spectra for the various neutrino fluxes. By default, the following are provided and taken from: pp and hep [52], \(^8B\) [53], \({}^{13}N\), \({}^{15}O\) and \({}^{17}F\) [54], \(^7Be\) [55]. Different spectra can be provided via the optional argument in the constructor for the class. It should be noted that spectra are assumed in PEANUTS to be normalised to 1, so the user should make sure to renormalise the spectrum accordingly, as it is the case, for instance for the \(^8B\) spectrum from [56], which is normalized to 1000.

In addition to the neutrino fraction distributions and fluxes, the class in PEANUTS provides the density of the Sun at various radius samples, necessary for computing the probability of neutrinos at Sun exit from Eq. (10). This probability, or equivalently the weight of neutrino mass eigenstates in the surface of the Sun, is computed by PEANUTS with the function

figure t

2.2 Neutrino propagation from the Sun

Being it an incoherent flux, the fraction of mass eigenstates within the solar neutrino flux remains constant as long as neutrinos propagate in the vacuum, on their path from Sun surface to Earth. Here we adopt the convention that the unitary PMNS mixing matrix U defines the change of basis between mass and flavour neutrino fields

$$\begin{aligned} \nu _\alpha (x) = U_{\alpha i}\ \nu _i (x), \end{aligned}$$
(12)

with \(\alpha = e,\mu ,\tau \) the flavour indexes, \(i=1,2,3\) the mass ones. With this convention, a neutrino state produced at the origin results from the linear superposition of mass statesFootnote 6

$$\begin{aligned} \left| \nu _\alpha , x=0 \right\rangle = U_{\alpha i}^* \left| \nu _i, x=0 \right\rangle , \end{aligned}$$
(13)

implying that the probability of observing a neutrino of flavour \(\alpha \) from a mass eigenstate i is given by \(|U_{\alpha i}^*|^2\). Thus, the probability for a solar neutrino to manifest as flavour \(\alpha \) is given by

$$\begin{aligned} P^S_{\nu _e \rightarrow \nu _\alpha }(E) = |U_{\alpha i}^*|^2 P^\odot _{\nu _e \rightarrow \nu _i}(E), \end{aligned}$$
(14)

and we assume throughout this paper that repeated indexes are summed.

In PEANUTS the PMNS matrix is implemented as the class, which is constructed from the mixing angles \(\theta _{ij}\) and CP phase \(\delta _{\text {CP}}\) as

figure v

This provides accessor functions for all mixings parameters, as well as other useful quantities such as the orthogonal/unitary matrices \(R_{12}\), \(R_{13}\), \(R_{23}\) and \(\Delta \), which allow the PMNS mixing matrix U to be expressed as

$$\begin{aligned} U = R_{23} \Delta R_{13} \Delta ^* R_{12}, \end{aligned}$$
(15)

and are defined as

$$\begin{aligned} R_{23}= & {} \left( \begin{array}{ccc} 1 &{} 0 &{} 0 \\ 0 &{} c_{23} &{} s_{23} \\ 0 &{} -s_{23} &{} c_{23} \end{array} \right) , \quad R_{13} = \left( \begin{array}{ccc} c_{13} &{} 0 &{} s_{13}\\ 0 &{} 1 &{} 0 \\ -s_{13} &{} 0 &{} c_{13} \end{array} \right) , \nonumber \\ R_{12}= & {} \left( \begin{array}{ccc} c_{12} &{} s_{12} &{} 0 \\ -s_{12} &{} c_{12} &{} 0 \\ 0 &{} 0 &{} 1 \end{array} \right) , \quad \Delta = \left( \begin{array}{ccc} 1 &{} 0 &{} 0\\ 0 &{} 1 &{} 0 \\ 0 &{} 0 &{} e^{i\delta } \end{array} \right) . \end{aligned}$$
(16)

This decomposition of the PMNS matrix will be useful further down when computing the propagation Hamiltonian through Earth. Finally, in order to compute the solar probability for flavour eigenstates with PEANUTS, one can use the function

figure x

which simply implements Eq. (14) using a object and calling the function, and returns a list of the probability for each flavour eigenstate.

3 Neutrino propagation through Earth

3.1 Probability of transition through matter

If the neutrino flux from the Sun crosses the Earth (or any finite density matter in general) the probabilities are modified, since the propagation eigenstates in matter differ from the vacuum ones.

In general, a generic neutrino state at timeFootnote 7t can be expressed in terms of the state at time \(t_0\) by evolving it with an appropriate evolutor operator \(\hat{{\mathcal {U}}}(t,t_0)\)

$$\begin{aligned} \left| \nu , t \right\rangle = \hat{{\mathcal {U}}}(t,t_0)\left| \nu , t_0 \right\rangle . \end{aligned}$$
(17)

The generic state \(\left| \nu ,t \right\rangle \) can be expressed as a linear superposition of pure flavour eigenstates,

$$\begin{aligned} \left| \nu , t \right\rangle = c_\alpha (t) \left| \nu _\alpha \right\rangle , \end{aligned}$$
(18)

where \(c_\alpha (t)\) are complex numbers, implying that the probability of it to interact as a neutrino with flavour \(\alpha \) at time t will be given by \(|c_\alpha (t)|^2\). From Eq. 17 it follows that the evolved probability amplitudes are given by

$$\begin{aligned} c_\alpha (t)= & {} \left\langle \nu _\alpha | \nu ,t \right\rangle = \left\langle \nu _\alpha \right| \hat{{\mathcal {U}}}(t,t_0) \left| \nu _\beta \right\rangle \left\langle \nu _\beta | \nu ,t_0 \right\rangle \nonumber \\= & {} {\mathcal {U}}_{\alpha \beta }(t,t_0) c_\beta (t_0), \end{aligned}$$
(19)

where \({\mathcal {U}}_{\alpha \beta }(t,t_0)\) are the matrix elements of the evolutor operator in flavour basis. The determination of the evolutor operator \({\mathcal {U}}\) is in general a non-trivial problem, and will be discussed in detail in the following sections; for the moment let us assume we know a closed form expression for it.

A mass eigenstate expressed as linear combination of flavour eigenstates is

$$\begin{aligned} \left| \nu _i \right\rangle = U_{i \alpha }^T \left| \nu _\alpha \right\rangle = U_{\alpha i} \left| \nu _\alpha \right\rangle , \end{aligned}$$
(20)

which implies a transition amplitude from (evolved) mass to flavour eigenstate

$$\begin{aligned} \left\langle \nu _\alpha | \nu _i, t \right\rangle = {\mathcal {U}}_{\alpha \beta } (t, t_0) U_{\beta i}. \end{aligned}$$
(21)

Putting everything together, the final probability for a solar neutrino to manifest as \(\alpha \) flavour while crossing the Earth is given by

$$\begin{aligned} P_\alpha ^{SE}(t, E) = \left| {\mathcal {U}}_{\alpha \beta }(t, t_0) U_{\beta i} \right| ^2 P_{\nu _e \rightarrow \nu _i}^\odot (E), \end{aligned}$$
(22)

where \(t_0\) is defined at the time of neutrino crossing the Earth surface. The interpretation of Eq. (22) is the following: \(U_{\beta i}\) are the coefficients of the mass eigenstate i expressed as linear combination of flavour eigenstates, \(\left| \nu _i \right\rangle = U_{\beta i} \left| \nu _\beta \right\rangle \), and \({\mathcal {U}}_{\alpha \beta }(t, t_0) U_{\beta i} = \left\langle \nu _\alpha | \nu _i, t \right\rangle \) is the transition amplitude from the evolved mass eigenstate i to interaction eigenstate \(\alpha \). Finally, each probability \(|\left\langle \nu _\alpha | \nu _i, t \right\rangle |^2\) is multiplied by the weight of the mass eigenstate i in the incoherent solar flux, \(P_{\nu _e \rightarrow \nu _i}^\odot (E)\).

The probability of oscillation for each flavour eigenstate in Eq. (22) is implemented in PEANUTS by the function , with signature

figure ab

which takes as arguments the neutrino state, , an instance of the Earth density class (see Sect. 3.3 below), , an instance of the PMNS class, , the mass splitting parameters, and , the neutrino energy, , the nadir angle of the incoming neutrino, , and the depth of the experiment at which the probability is to be computed, .

The optional argument defines the basis of the neutrino state. If the initial state is assumed to be a coherent one, expressed in flavour basis, with defining the complex coefficients \(c_\alpha \) in Eq. (18), and final probabilities computed by squaring the coefficients evolved as in Eq. (19). If , the initial state is assumed to be an incoherent superposition of mass eigenstates, with defining the real weights \(P_{\nu _e \rightarrow \nu _i}^\odot (E)\) and final probabilities computed as in Eq. (22). To compute the probability for an antineutrino, one can set the optional argument ( by default).

One can also optionally select the evolution mode to be either numerical or analytical (default) by providing the optional argument with either option. The function thus splits into two functions for each of the methods, and , whose details and differences will be described below in Sect. 4. Lastly, one can request the full evolution of the probability with the optional argument (defaults to ), returned as a list of probability values for each flavour eigenstate and certain discrete coordinate locations along the path of the neutrino. Note that the full oscillation can only be provided via the numerical evolution mode, so if selected along with the analytical mode, PEANUTS will provide a warning and simply compute the final probabilities.

In addition, if one wishes to know the final evolved complex coefficients \(c_\alpha (t)\) from a coherent (flavour basis) initial neutrino state, from Eq. 19, they can be obtained with the function

figure ax

which has the same arguments as , except the basis as this is only available for neutrino states in the flavour basis. As with the probability function, this function splits into and according to the selected mode.

3.2 Evolutor operator

The evolutor operator \(\hat{{\mathcal {U}}}\) is defined by the equations

$$\begin{aligned} \left| \nu , t \right\rangle = \hat{{\mathcal {U}}}(t, t_0) \left| \nu , t_0 \right\rangle , \quad \text {with } \hat{{\mathcal {U}}}(t_0, t_0) = \hat{{\mathbbm {1}}}. \end{aligned}$$
(23)

The equation of motion for \(\hat{{\mathcal {U}}}(t, t_0)\) can be derived from the Schrödinger equation

$$\begin{aligned} i \frac{\text {d}}{\text {d}t}\left| \nu , t \right\rangle= & {} \hat{H}(t) \left| \nu , t \right\rangle \Rightarrow i \frac{\text {d}}{\text {d}t} \hat{{\mathcal {U}}}(t, t_0) \left| \nu , t_0 \right\rangle \nonumber \\= & {} \hat{H}(t) \hat{{\mathcal {U}}}(t, t_0) \left| \nu , t_0 \right\rangle , \end{aligned}$$
(24)

implying

$$\begin{aligned}{} & {} i \frac{\text {d}}{\text {d}t} \hat{{\mathcal {U}}}(t, t_0) = \hat{H}(t) \hat{{\mathcal {U}}}(t, t_0) \quad \text {with }\hat{{\mathcal {U}}}(t_0, t_0) = \hat{{\mathbbm {1}}}. \end{aligned}$$
(25)

The Schrödinger equation in flavour basis takes the form

$$\begin{aligned}{} & {} i \frac{\text {d}}{\text {d}t}\left\langle \nu _\alpha | \nu , t \right\rangle = \left\langle \nu _\alpha \right| \hat{H}(t) \left| \nu _\beta \right\rangle \left\langle \nu _\beta | \nu , t \right\rangle \nonumber \\{} & {} \quad \Rightarrow i \frac{\text {d}}{\text {d}t} c_\alpha (t) = H_{\alpha \beta }(t) c_\beta (t). \end{aligned}$$
(26)

The explicit expression for \(H_{\alpha \beta }(t)\) can be readily derived in vacuum (where there is no time dependence)

$$\begin{aligned} H_{\alpha \beta }= & {} \left\langle \nu _\alpha \right| \hat{H} \left| \nu _\beta \right\rangle = \left\langle \nu _i \right| U_{\alpha i} \hat{H} U_{\beta j}^* \left| \nu _j \right\rangle \nonumber \\= & {} U_{\alpha i} U_{\beta j}^* \left\langle \nu _i \right| \hat{H} \left| \nu _j \right\rangle = U_{\alpha i} U_{\beta j}^* E_j \delta _{ij} \nonumber \\= & {} \left[ U \text {diag}(E_i) U^\dagger \right] _{\alpha \beta }, \end{aligned}$$
(27)

where \(E_i\) is the energy of the mass eigenstate \(\left| \nu _i \right\rangle \). In the presence of matter the Hamiltonian matrix elements receive an additional (time dependent) term, cf. Sect. 4; Eq. (27) determines its vacuum CP-structure, following the definition of the neutrino fields/states in Eqs. (1213).

Table 1 Values of the parameters for the electron density expressed as \(N_j(r) = \alpha _j + \beta _j r^2 + \gamma _j r^4\) with \([N] = \text {mol}/\text {cm}^3\), for each of the Earth internal shells, as derived in [39]. The radial distance r is normalised to the radius of Earth

In PEANUTS the probability of oscillation through vacuum, and its evolved state, are computed with the functions

figure bb

with similar arguments as above, with the notable difference of the oscillation length or baseline , to be provided in km.

Once the Hamiltonian matrix elements are known, they can be used to derive the evolutor ones. The formal solution is

$$\begin{aligned} {\mathcal {U}}(t, t_0) = {\mathcal {T}} \left[ e^{-i \int _{t_0}^t \text {d}t' H(t')} \right] , \end{aligned}$$
(28)

where \({\mathcal {T}}\) is the time-order operator. Equation (28) does not generally admit an analytic closed form, except for very special cases, for instance if the Hamiltonian at different times does commute.

A well known approach to the problem is the Dyson series [57]

$$\begin{aligned} {\mathcal {U}}(t, t_0)= & {} {\mathbbm {1}} + \sum _{n=1}^\infty \frac{\left( -i\right) ^n}{n!} \int _{t_0}^t \text {d}t_1 \int _{t_0}^t \text {d}t_2 \cdots \int _{t_0}^t \text {d}t_n\nonumber \\{} & {} \times \, {\mathcal {T}} \left[ H(t_1) H(t_2) \cdots H(t_n) \right] , \end{aligned}$$
(29)

which allows for an approximate solution obtained by truncating Eq. (29) at finite values of n, if the series is expected to be perturbative. We will return to this approximation in Sect. 4, where we will derive an approximated analytical expression for the evolutor.

3.3 Earth matter regeneration

Due to the incoherent nature of the solar neutrino flux, its relative weights in mass eigenstates components, \(P_{\nu _e \rightarrow \nu _i}^\odot (E)\), are constant while travelling from Sun to Earth in vacuum. However, before arriving at a terrestrial detector, a solar neutrino can cross the Earth itself, along which path the matter potential makes the propagation eigenstates different from the vacuum ones. This results in coherent neutrino oscillations inside the Earth that, on average, result in a regeneration of \(\nu _e\) with respect to the vacuum case [38].

The electron density inside Earth can be parametrised by 5 shells, within which the density itself varies smoothly as [39]

$$\begin{aligned}{} & {} N_j(r) = \alpha _j + \beta _j r^2 + \gamma _j r^4, \quad \text {with } \left[ N\right] = \text {mol}/\text {cm}^3,\nonumber \\ \end{aligned}$$
(30)

and where r is the radial distance normalised to the Earth radius. The numerical values of the parameters are reported for convenience in Table 1.

The parametrisation in Eq. (30) is valid for radial trajectories, i.e. paths crossing the center of the Earth. For a path forming a nadir angle \(\eta \) with the radial trajectory (cf. Fig. 2), the parametrisation is functionally invariant, with modified coefficients

$$\begin{aligned} N_j(x)= & {} \alpha '_j + \beta '_j x^2 + \gamma '_j x^4, \end{aligned}$$
(31)
$$\begin{aligned} \alpha '_j= & {} \alpha _j + \beta _j \sin ^2 \eta + \gamma _j \sin ^4\eta , \end{aligned}$$
(32)
$$\begin{aligned} \beta '_j= & {} \beta _j + 2 \gamma _j \sin ^2\eta , \end{aligned}$$
(33)
$$\begin{aligned} \gamma '_j= & {} \gamma _j, \end{aligned}$$
(34)

where the trajectory coordinate x is defined as the distance from the trajectory mid-point, i.e. \(x = \sqrt{r^2-\sin ^2\eta }\). The Earth density profiles for some example values of the nadir angle \(\eta \) are reported in Fig. 3.

Fig. 2
figure 2

Earth section showing the different shells and the path of a solar neutrino having nadir angle \(\eta \). The trajectory coordinate x is also schematised

Fig. 3
figure 3

Earth density profile for different values of the nadir angle \(\eta \), following the parametrisation in [39]

This parametrisation assumes a nadir angle defined for a detection at the surface of Earth. If the detector is located underground, we can define a “detector shell” at the detector radial distance. For instance, SNO was placed \(H=2\) km underground, so we can define \(r_{det} = r_{\text {SNO}} = 1 - H /R_{\text {E}} \equiv 1 - h\), where \(R_{\text {E}}\) is the (not rescaled) Earth radius, \(R_E = 6.371 \cdot 10^3\) km. There are two modifications for the scenario of an underground detector with respect to the treatment in [39]: the first is that the measured nadir angle \(\eta \) differs from the angle \(\eta ' = \arcsin (r_{det} \sin \eta )\) that one would measure at the Earth surface, for same neutrino trajectory, cf. Fig. 4. This implies that it is the \(\eta '\) angle that should be used in Eq. (31) to compute the value of the electron density profile along the neutrino trajectory, and not the value \(\eta \) measured by the experiment. The second modification is that matter effects are present even for values of \(\eta \ge \pi /2\), if the detector is underground. The contribution to the trajectory from the outer layer (between Earth surface and detector shell) is given by

$$\begin{aligned} \Delta x(\eta ) = \left\{ \begin{array}{ll} -r_{det} \cos \eta + \sqrt{1 - r_{det}^2 \sin ^2 \eta } &{} \quad \text {for}\ 0 \le \eta \le \frac{\pi }{2}, \\ r_{det} \cos \eta + \sqrt{1 - r_{det}^2 \sin ^2 \eta } &{} \quad \text {for}\ \frac{\pi }{2} \le \eta \le \pi . \end{array} \right. \nonumber \\ \end{aligned}$$
(35)

\(\Delta x\) reduces to h for \(\eta =0, \pi \), and attains the maximum value \(\sqrt{h(2-h)}\) for \(\eta =\pi /2\) (this is approximately 160 km for SNO).

Fig. 4
figure 4

Schematic representation of Earth shell and “detector shell” for an underground detector

In general, not every shell is crossed by solar neutrinos: a shell i is crossed by a neutrino trajectory with nadir angle \(\eta \) if \(r_i > r_{det} \sin \eta \). The value of the trajectory coordinate at each shell crossing is given by

$$\begin{aligned} x_i= & {} \sqrt{r_i^2 - r_{det}^2 \sin ^2 \eta }, \quad \text {for } i\text { such that} \nonumber \\{} & {} r_i > r_{det} \sin \eta . \end{aligned}$$
(36)

PEANUTS implements the Earth density as a Python class called , with signature

figure bf

where the optional arguments , and allow the user to supply any Earth density profile. If supplied by file, using the argument, the density profile is either expected as a table with columns \(\{r_j, \alpha _j, \beta _j, \gamma _j\}\), following Eq. (30) (additional optional columns \(\delta _j^{2n}\), with \(n\ge 3\), are allowed, corresponding to higher orders in the polynomial expansion of the density); or if it is expected as a two-column table of radii and density, where each entry will be treated as a new layer of constant density. Consequently PEANUTS can work with an arbitrary number of shells and arbitrary densities. In addition to supplying the density profile by file, it is also possible to provide an analytical expression for the density. Upon selecting the optional argument in the constructor, PEANUTS will use the earth density computed by the member function , where a user can implement their own analytical density profile. However, custom density profiles and higher orders in the polynomial expansion are only fully used when computing the oscillation probabilities numerically; the analytical computation, described below in Sect. 4.1, relies on the density described as in Eq. (30), and thus any density provided will be Taylor expanded and truncated to fit that form, when used for the analytical computation of the oscillation probability. Regardless of the source and form of the density profile, the class provides methods to compute the value of the density at given coordinate x, as well as, when appropriate, the modified coefficients \(\alpha '_j\), \(\beta '_j\) and \(\gamma '_j\) (and \(\delta ^{'2n}_j\) if needed), corresponding to each Earth shell, from the radii and nadir angle \(\eta \) using Eq. (31) (or modified to accommodate higher orders).

4 Neutrino propagation Hamiltonian

The propagation Hamiltonian for an ultrarelativistic neutrino propagating in a medium with electron density \(n_e(x)\) is, in the flavour basis [46]

$$\begin{aligned} H_\nu = \underbrace{U \text {diag}(k) U^\dagger }_{H_\nu ^0} + \underbrace{V(x)\ \text {diag}(1,0,0)}_{V_\nu }, \end{aligned}$$
(37)

with

$$\begin{aligned} k_i= & {} \frac{m_i^2}{2E}, \end{aligned}$$
(38)
$$\begin{aligned} V(x)= & {} \sqrt{2}G_F n_e(x). \end{aligned}$$
(39)

For antineutrinos, the same Eq. (37) holds, with the replacements

$$\begin{aligned} U\rightarrow & {} U^*, \end{aligned}$$
(40)
$$\begin{aligned} V\rightarrow & {} -V. \end{aligned}$$
(41)

To streamline computations and statistical analysis, it is more convenient to redefine the Hamiltonian by subtracting a constant term

$$\begin{aligned} H_\nu \rightarrow H_\nu - U \left( k_j {\mathbbm {1}}\right) U^\dagger , \end{aligned}$$
(42)

with \(j=1\) for normal ordering (NO) and \(j=2\) for inverted ordering (IO), such that

$$\begin{aligned} \left( \begin{array}{ccc} k_1 &{}&{}\\ &{} k_2 &{} \\ &{}&{} k_3 \end{array} \right) - k_1 {\mathbbm {1}}= & {} \frac{1}{2E} \left( \begin{array}{ccc} 0 &{}&{} \\ &{} \Delta m_{21}^2 &{} \\ &{}&{} \Delta m_{31}^2 \end{array} \right) \quad \text {for NO},\nonumber \\ \end{aligned}$$
(43)
$$\begin{aligned} \left( \begin{array}{ccc} k_1 &{}&{}\\ &{} k_2 &{} \\ &{}&{} k_3 \end{array} \right) - k_2 {\mathbbm {1}}= & {} \frac{1}{2E} \left( \begin{array}{ccc} - \Delta m_{21}^2 &{}&{} \\ &{} 0 &{} \\ &{}&{} \Delta m_{32}^2 \end{array} \right) \quad \text {for IO}, \nonumber \\ \end{aligned}$$
(44)

so that we can use as free parameters \(\Delta m_{21}^2 >0\) and \(\Delta m_{3\ell }^2\), with \(\ell =1\) for NO \((\Delta m_{31}^2 > 0)\) and \(\ell =2\) for IO \((\Delta m_{32}^2 < 0).\) In the following we keep using the notation \(\text {diag}(k)\) for the general expressions, valid for any choice of mass ordering. A specific scenario can then be easily recovered by specifying the structure of this diagonal matrix, e.g. in Eqs. (43, 44).

With the parametrisation in Eq. (15) and using \(\left[ \Delta ,R_{12}\right] = \left[ V_\nu ,R_{23}\right] =\left[ V_\nu ,\Delta \right] =0\), the propagation Hamiltonian can be rewritten as

$$\begin{aligned} H_\nu = R_{23} \Delta \tilde{H} \Delta ^* R_{23}^T, \end{aligned}$$
(45)

with

$$\begin{aligned} \tilde{H} = R_{13} R_{12} \text {diag}(k) R_{12}^T R_{13}^T + V(x) \text {diag}(1,0,0). \end{aligned}$$
(46)

Notice that \(\tilde{H}\) does not depend on \(\theta _{23}\), \(\delta \).

Given that \(R_{23}\) and \(\Delta \) do not depend on position, they can be factorised in the time-ordered definition of the evolutor operator

$$\begin{aligned} {\mathcal {U}}= & {} {\mathcal {T}} e^{-i \int \text {d}x H_\nu (x)}\nonumber \\= & {} {\mathbbm {1}} + R_{23} \Delta {\mathcal {T}}\left[ -i \int \text {d}x \tilde{H}_\nu (x)\right] \Delta ^* R_{23}^T \end{aligned}$$
(47)
$$\begin{aligned}{} & {} {+} \frac{1}{2} R_{23} \Delta {\mathcal {T}}\left[ \left( \left( {-}i\right) ^2 \int \text {d}x_1 \text {d}x_2 \tilde{H}_\nu (x_1) \underbrace{\Delta ^* R_{23}^T R_{23} \Delta }_{{=} {\mathbbm {1}}} \tilde{H}_\nu (x_2)\right) \right] \nonumber \\{} & {} \quad \Delta ^* R_{23}^T \end{aligned}$$
(48)
$$\begin{aligned}{} & {} + \cdots (\text { other terms of the Dyson series for } n \rightarrow \infty ) \end{aligned}$$
(49)
$$\begin{aligned}= & {} R_{23} \Delta {\mathcal {T}} \left[ e^{- i \int \text {d}x \tilde{H}(x)} \right] \Delta ^* R_{23}^T = R_{23} \Delta \tilde{{\mathcal {U}}} \Delta ^* R_{23}^T. \end{aligned}$$
(50)

A numerical solution for the evolutor can be obtained by solving Eq. (50) or by resolving the differential equation in Eq. (25). PEANUTS offers a numerical evaluation of the evolutor, via the function

figure bp

and the evolved coefficients from a coherent neutrino state, with

figure bq

These computations, however, can be extremely time-consuming, and thus it is convenient to find an approximated analytical expression by performing a perturbative expansion of the Hamiltonian.

4.1 Perturbative expansion of the neutrino propagation Hamiltonian

We are interested in an expression for the operator in Eq. (50)

$$\begin{aligned} \tilde{{\mathcal {U}}} = {\mathcal {T}} \left[ e^{- i \int \text {d}l \tilde{H}(l)} \right] , \end{aligned}$$
(51)

where l is the coordinate along the neutrino path. We normalise distances to the Earth radius \(R_E\), by defining \(x = l/R_E\). The Hamiltonian \(\tilde{H}\) can be divided in a kinetic and a matter dependent terms

$$\begin{aligned} \tilde{H}(x) = \tilde{H}_k + \sqrt{2} G_F n_e(x)\text {diag}(1,0,0), \end{aligned}$$
(52)

where \(\tilde{H}_k\) does not depend on x.

To work out a perturbative expression for \({\mathcal {U}}\)Footnote 8 it is convenient to express the electron density as a perturbation along its mean value along the path [39]

$$\begin{aligned} n_e(x) = \bar{n}_e + \delta n(x),\quad \bar{n}_e =\frac{1}{x_2-x_1} \int _{x_1}^{x_2} \text {d}x \ n_e(x), \end{aligned}$$
(53)

from which it follows

$$\begin{aligned} \int _{x_1}^{x_2} \text {d}x\ \delta n(x) = 0. \end{aligned}$$
(54)

We can analogously divide the Hamiltonian into a zeroth order term and a perturbation

$$\begin{aligned} \tilde{H}(x)= & {} \underbrace{\tilde{H}_k + \sqrt{2}G_F \bar{n}_e \text {diag}(1,0,0)}_{\tilde{H}_0} \nonumber \\{} & {} + \underbrace{\sqrt{2}G_F \delta n(x) \text {diag}(1,0,0)}_{\delta \tilde{H}(x)}, \end{aligned}$$
(55)

where again \(\tilde{H}_0\) does not depend on x.

The evolutor can thus be expressed as [39]

$$\begin{aligned} {\mathcal {U}}(x_2,x_1)&{=}&\bar{{\mathcal {U}}}(x_2,x_1) {-} i \int _{x_1}^{x_2} \text {d}x\ \bar{{\mathcal {U}}}(x_2,x)\ \delta \tilde{H}(x)\ \bar{{\mathcal {U}}}(x,x_1) \nonumber \\{} & {} +{\mathcal {O}}(\delta \tilde{H}^2), \end{aligned}$$
(56)

where \(\bar{{\mathcal {U}}}\) is the evolutor for constant matter density \(\bar{n}_e\).

The evolutor for a constant Hamiltonian \(\bar{H}\) can generally be expressed in a closed form [58]

$$\begin{aligned} e^{- i \bar{H} x}&{=}&\phi \sum _{a=1}^3 e^{{-}i x \lambda _a} \frac{1}{3\lambda _a^2 {+} c_1}\left[ \left( \lambda _a^2 {+} c_1\right) {\mathbbm {1}} + \lambda _a T + T^2 \right] \nonumber \\\equiv & {} \phi \sum _{a=1}^3 e^{-i x \lambda _a} M_a, \end{aligned}$$
(57)

where \(T = \bar{H} - \text {Tr}(\bar{H}) {\mathbbm {1}}/3 \) is a traceless matrix and \(\lambda _a\) are the roots of the characteristic equation

$$\begin{aligned} \lambda ^3 + c_1 \lambda + c_0 = 0, \end{aligned}$$
(58)

with

$$\begin{aligned} c_1= & {} T_{11} T_{22} - T_{12} T_{21} + T_{11} T_{33} - T_{13} T_{31} + T_{22} T_{33} \nonumber \\{} & {} \quad - T_{23} T_{32}, \end{aligned}$$
(59)
$$\begin{aligned} c_0= & {} - \det T.\nonumber \\ \end{aligned}$$
(60)

Finally

$$\begin{aligned} \phi = e^{- i x \frac{\text {Tr}(\bar{H})}{3} }. \end{aligned}$$
(61)

By noticing that the full dependence on x in \(e^{-i \bar{H} x}\) is now contained within the scalar functions \(e^{- i \lambda _a x}\), the first order correction in Eq. (56) can be computed as

$$\begin{aligned} {\mathcal {U}}^{(1)}(x_2,x_1)= & {} - i \int _{x_1}^{x_2} \text {d}x\ \bar{{\mathcal {U}}}(x_2,x)\ \delta \tilde{H}(x)\ \bar{{\mathcal {U}}}(x,x_1) \end{aligned}$$
(62)
$$\begin{aligned}= & {} - i \sum _{a,b=1}^3 \int _{x_1}^{x_2} \text {d}x e^{- i \tilde{\lambda }_a (x_2-x)} M_a \nonumber \\{} & {} \times \text {diag}\left( \sqrt{2} G_F \delta n(x),0,0\right) M_b e^{- i \tilde{\lambda }_b (x-x_1)} \end{aligned}$$
(63)
$$\begin{aligned}= & {} - i \sum _{a,b=1}^3 M_a \text {diag}\left( \sqrt{2}G_F I_{ab}(x_2, x_1), 0, 0\right) M_b,\nonumber \\ \end{aligned}$$
(64)

where \(\tilde{\lambda }_a = \lambda _a + \text {Tr}(\bar{H})/3\) and we defined

$$\begin{aligned} I_{ab}(x_2,x_1) = \int _{x_1}^{x_2}\text {d}x\ e^{- i \tilde{\lambda }_a (x_2-x)}\ \delta n(x)\ e^{- i \tilde{\lambda }_b (x-x_1)}. \end{aligned}$$
(65)

For a path fully contained within one shell we can parametrise

$$\begin{aligned} \delta n (x) = \tilde{\alpha }' + \beta ' x^2 + \gamma ' x^4, \end{aligned}$$
(66)

where \(\tilde{\alpha }' = \alpha ' - \bar{n}_e\), implying that \(I_{ab}(x_2,x_1)\) can be expressed analytically in closed form.

Summarising, we can perturbatively expand the evolutor operator as

$$\begin{aligned} {\mathcal {U}}(x_2,x_1)= & {} {\mathcal {U}}^{(0)}(x_2,x_1) +{\mathcal {U}}^{(1)}(x_2,x_1) + {\mathcal {O}}(\delta \tilde{H}^2), \end{aligned}$$
(67)
$$\begin{aligned} {\mathcal {U}}^{(0)}(x_2,x_1)= & {} e^{- i \bar{H} (x_2-x_1)} = \phi \sum _{a=1}^3 e^{-i (x_2-x_1) \lambda _a} M_a, \end{aligned}$$
(68)
$$\begin{aligned} {\mathcal {U}}^{(1)}(x_2,x_1)= & {} - i \sum _{a,b=1}^3 M_a\ \text {diag}\left( \sqrt{2}G_F I_{ab}(x_2, x_1), 0, 0\right) \ M_b.\nonumber \\ \end{aligned}$$
(69)

In PEANUTS we implement these perturbative expressions to compute \({\mathcal {U}}\) in Eq. (51) at first order in perturbation theory, using a “reduced” mixing matrix \(\tilde{U} = R_{13} R_{12}\), with he function

figure br

which depends on the neutrino mass differences squared and , the PMNS matrix , neutrino energy , the start and end points of the shell along the neutrino path and , as well as the density parameters of the traversed shell, with = \(\alpha \), = \(\beta \) and = \(\gamma \). The flag labels whether the computation is to be done for a neutrino () or antineutrino ().

The procedure outlined above allows to express the evolutor at 1st order in \(\delta H\), for a path fully contained within one shell. In general, the full evolutor on a generic path \((x_1,x_2)\) can be expressed as a time-ordered product of evolutors along the same path

$$\begin{aligned} {\mathcal {U}}(x_2, x_1) = {\mathcal {U}}(x_2, x_i) {\mathcal {U}}(x_i, x_1), \end{aligned}$$
(70)

where \(x_i\) is a generic point \(x_1< x_i <x_2\) contained on the original path. It can be shown that [39]

$$\begin{aligned} {\mathcal {U}}(0, -x) = {\mathcal {U}}(x,0)^T. \end{aligned}$$
(71)

The consequences of Eqs. (7071) are twofold: first, for a path starting at \(x=x_i\), with \(0\le x_i < x_1\), crossing n shells with boundaries at trajectory coordinate \((0, x_1, x_2, \ldots , x_n)\), and ending at the point \(x=x_f\), with \(x_{n-1} < x_f \le x_n\), the full evolutor can be expressed as

$$\begin{aligned} {\mathcal {U}}(x_f, x_i){} & {} = {\mathcal {U}}(x_f, x_{n-1}){\mathcal {U}}(x_{n-1},x_{n-2})\ldots {\mathcal {U}}(x_2, x_1)\nonumber \\{} & {} \quad {\mathcal {U}}(x_1, x_i). \end{aligned}$$
(72)

Second, for detectors placed at surface, the Earth spherical symmetry implies that the electron density is symmetric with respect to the trajectory midpoint at \(x=0\); thus we only need to compute the evolutor on one half-path (cf. Fig. 2)

$$\begin{aligned} {\mathcal {U}}(x_F,x_I) = {\mathcal {U}}(x_F, 0) {\mathcal {U}}(0, - x_F) = {\mathcal {U}}(x_F, 0) {\mathcal {U}}(x_F, 0)^T.\nonumber \\ \end{aligned}$$
(73)

Notice that the final evolutor is only a function of \(\eta \), since both the density profile and travelled distance within Earth are a function of the nadir angle.

If the detector is placed underground at trajectory coordinate \(x_{det} < x_F\), we distinguish two cases. For \(0 \le \eta < \pi /2\)

$$\begin{aligned} {\mathcal {U}}(x_{det},x_I)= & {} {\mathcal {U}}(x_{det}, 0) {\mathcal {U}}(0, - x_F) \nonumber \\= & {} {\mathcal {U}}(x_{det}, 0) {\mathcal {U}}(x_F, 0)^T, \quad \left( 0 \le \eta < \frac{\pi }{2} \right) \nonumber \\ \end{aligned}$$
(74)

where \(x_{det} = r_{det} \cos {\eta }\). For \(\pi /2 \le \eta \le \pi \) the electron density can be approximated to a constant value, since the neutrino path is never deeper than H and density variations are negligible for realistic detectors. For instance, taking the SNO reference value \(H = 2\) km,

$$\begin{aligned} \frac{N(R_E) - N(R_E-H)}{N(R_E) + N(R_E - H)} = 10^{-4}. \end{aligned}$$
(75)

We fix for simplicity the electron density value to the one at Earth surface, \(n_1 = 1.67\) mol/cm\({^3}\). Having assumed constant density along the path, the evolutor is simply given by

$$\begin{aligned} {\mathcal {U}}(\eta )= & {} e^{-i R_E \Delta x(\eta ) \left( \tilde{H}_0 + \text {diag}\left( \sqrt{2}G_F n_1, 0, 0\right) \right) },\nonumber \\{} & {} \quad \left( \frac{\pi }{2} \le \eta < \pi \right) . \end{aligned}$$
(76)

To obtain the full dynamics and thus the full evolutor \({\mathcal {U}}\), PEANUTS computes the time-ordered product of “reduced” evolutors \(\tilde{{\mathcal {U}}}\) from above, and inputs it in Eq. (50) to re-introduce the dependence on \(\theta _{23}\) and \(\delta \). The PEANUTS function that implements these two steps is

figure ce

with dependency also on the mass differences squared, PMNS matrix and neutrino energy, but also on the full Earth density profile , the nadir angle and experiment depth . This full evolutor is finally used to compute the probability of oscillation at the detector by the function

figure ci

and the evolved coefficients with

figure cj

5 Time integration and exposure

Solar neutrino experiments typically collect data over a finite interval of time. As such, the measured survival probability is averaged over exposure

$$\begin{aligned} \left\langle P_E \right\rangle = \frac{\int _{\tau _{d_1}}^{\tau _{d_2}} \text {d}\tau _d \int _{\tau _{h_1} (\tau _d)}^{\tau _{h_2} (\tau _d)} \text {d}\tau _h P_E \left( \eta (\tau _d, \tau _h) \right) }{\int _{\tau _{d_1}}^{\tau _{d_2}} \text {d}\tau _d \int _{\tau _{h_1} (\tau _d)}^{\tau _{h_2} (\tau _d)} \text {d}\tau _h }, \end{aligned}$$
(77)

where \(\tau _d\) is the daily time, \(\tau _h\) the hourly time and \(\eta \) the Sun nadir angle at detector location. The integration in Eq. (77) is typically not the most convenient choice for practical applications; a more effective option is to transform the double integral into a single one over \(\eta \) [39]

$$\begin{aligned} \left\langle P_E \right\rangle = \int _{0}^{\pi } \text {d}\eta W(\eta ) P_E(\eta ), \end{aligned}$$
(78)

where \(W(\eta )\) is a normalized weight function representing the fraction of time in which the experiment collected data at nadir angle \(\eta \). For real experiments, \(W(\eta )\) must be provided by the collaboration, taking into account the actual times at which the detector collected data or has been offline. It is nevertheless possible to compute \(W(\eta )\) analytically, for the ideal case of an experiment continuously taking data between days \(\tau _{d_1}\) and \(\tau _{d_2}\) [39]. This is done by changing integration variables

$$\begin{aligned}{} & {} \int _{\tau _{d_1}}^{\tau _{d_2}} \text {d}\tau _d \int _{\tau _{h_1} (\tau _d)}^{\tau _{h_2} (\tau _d)} \text {d}\tau _h P_E \left( \eta (\tau _d, \tau _h) \right) \nonumber \\{} & {} \quad = \int _{\tau _{d_1}}^{\tau _{d_2}} \text {d}\tau _d \int _{0}^{\pi } \text {d}\eta \frac{\text {d}\tau _h (\tau _d, \eta )}{\text {d}\eta } P_E \left( \eta \right) \end{aligned}$$
(79)
$$\begin{aligned}{} & {} \quad = \int _{0}^{\pi } \text {d}\eta P_E \left( \eta \right) \int _{\tau _{d_1}}^{\tau _{d_2}} \text {d}\tau _d \frac{\text {d}\tau _h (\tau _d, \eta )}{\text {d}\eta } \nonumber \\{} & {} \quad = \int _{0}^{\pi } \text {d}\eta P_E(\eta ) W(\eta ). \end{aligned}$$
(80)

By normalising the daily and hourly times to the interval \([0, 2 \pi ]\)

$$\begin{aligned} \tau _d = \frac{\text {day}}{365} 2\pi ,\quad \tau _h = \frac{\text {hour}}{24} 2\pi , \end{aligned}$$
(81)

with \(\tau _d=0\) at winter solstice and \(\tau _h=0\) at the middle of the night, it is possible to express

$$\begin{aligned} \tau _h = \arccos \left( \frac{\sin (\lambda ) \sin (\delta _S) + \cos (\eta )}{\cos (\lambda ) \cos (\delta _S)} \right) , \end{aligned}$$
(82)

with \(\lambda \) the detector latitude and \(\delta _S\) the Sun declination, given by

$$\begin{aligned} \delta _S = \arcsin \left( -\sin (i) \cos (\tau _d)\right) , \end{aligned}$$
(83)

with \(i=0.4091\) rad being the Earth inclination. With these definitions it is possible to perform the integral defining \(W(\eta )\) in Eq. (80); it is convenient to restrict \(\tau _d\) within the interval \([0, \pi ]\) (the alternative case can be easily derived from this one by using the symmetry of the orbit) and to change the integration variable from \(\tau _d\) to \(T = \cos (\tau _d)\). The resulting indefinite integral is expressed in terms of elementary functions and of the incomplete elliptic integral of the first kind; its analytic expression is not particularly illuminating but can be easily evaluated numerically. Some care must be taken in defining the range of integration for the definite integral, as this is given by the intersection of three distinct intervals: (i) \(T \in [-1, 1]\) is the interval where \(T=\cos (\tau _d)\) is defined, (ii) \(T \in [\sin (\lambda - \eta )/\sin (i), \sin (\lambda + \eta )/\sin (i)]\) is the range where T can take values for fixed values of \(\eta , \lambda , i\), (iii) \(T \in [\cos (\tau _{d_2}), \cos (\tau _{d_1})]\) is the observation time. If the intersection of the three intervals is null then \(W(\eta )\) will vanish for that given combination of \(\lambda , \eta \) values.

The exposure function \(W(\eta )\) is computed in PEANUTS by the function

figure ck

which has no required arguments, but either the latitude of the experiment, , or an exposure file , must be provided. It returns tabulated values of the function \(W(\eta )\) for samples (default 1000) in nadir angle \(\eta \), assuming an exposure from day to day , where corresponds to the northern hemisphere winter solstice. The exposure may be selected to be normalized with the option (defaults to ).

Under default conditions, the function computes analytically the ideal exposure function performing the integral in Eq. (80), which is implemented in PEANUTS by the function

figure cu

which depends on the nadir angle , latitude and day interval {,}. We plot in Fig. 5 the exposure function \(W(\eta )\) for one full year of exposure for three ideal detectors located at latitudes \(\lambda = 0, 45^\circ , 89^\circ \).

Fig. 5
figure 5

Weight of the nadir angle exposure for an ideal experiment located at latitude \(\lambda \), taking data continuously over a full year. The coloured regions represent the nadir angles subtending the Earth internal shells as parametrised in Table 1, for a detector located at the Earth surface

In a realistic case, the exposure must be provided by the experiment. For this purpose, one can provide an exposure file via the option of the function , which shall contain the tabulated values of the exposure. By default it is assumed that the exposure is tabulated in values of the nadir angle \(\eta \), but in some cases, the experiments provide the exposure tabulated in either the zenith angle \(\theta \) or \(\cos \theta \). In those cases, one must specify which angle is used for the tabulation with the options or , respectively. If an exposure file is provided, the latitude is no longer required, and if the argument is provided it will be ignored. Note that irrespective of the original tabulated values, the function only returns values tabulated in \(\eta \).

Lastly, PEANUTS provides the averaged probability of oscillation at detector location taking into account the finite time exposure, as in Eq. (78), with the function

figure df

which has the same arguments as the function, but without the nadir angle , and adds the same optional arguments as , with the final addition of an optional argument to select integrating only the nadir angles corresponding to the night period \(\eta < \pi /2\), with , or the day period \(\eta \ge \pi /2\), with . Note that this function requires the input neutrino state to be on the mass basis, since the integration is performed for an incoming incoherent flux of mass eigenstates, and thus it is not possible to provide a state on the flavour basis.

6 Quick start guide

PEANUTS is an open-source software written in Python, and as such we expect it to run seamlessly in every Python 3 environment, irrespective of the architecture. Nevertheless it has been tested thoroughly on Linux and Mac OS X systems. An example installation guide using the conda environment can be found in Appendix A. PEANUTS is optimised to run fast with minimal I/O operations, in order to allow effortless interface with other frameworks. Hence, it uses extensively the pre-compile numpy package as well as just-in-time compilation from numba. The full list of required and optional packages is as follows

  • numpy: fast pre-compiled array operations

  • numba: just-in-time compilation of functions and classesFootnote 9

  • os: file paths

  • copy: shallow and deep copies of objects

  • time: timing information

  • math, cmath, mpmath: mathematical operations

  • scipy: integration and interpolation routines

  • pyinterval: define integration intervals

  • decimal: output formatting

  • pandas: reading of csv files

  • pyyaml: reading of yaml files Optional

  • pyslha: reading of slha files Optional

  • gitpython: extract git tags Optional.

There are two operational modes of PEANUTS, which we will call the simple and expert modes. The simple mode allows PEANUTS to be run just from the command line, appending the input parameters as arguments to the command. Naturally this is a more limited mode as only provides a fraction of the functionalities, but it is a fast way to run PEANUTS just from the command line. The expert mode uses all of the functionalities in PEANUTS, and thus requires a configuration file, in YAML format, to be written.

In the simple mode one can run one of two provided scripts and . The first script computes the probability of neutrinos at the surface of the Sun, and has a signature

figure do

where and are mandatory arguments that refer to the neutrino energy, in MeV, and fraction respectively. The list of available neutrino fractions is .Footnote 10 With no options provided, the remaining arguments are required to populate the PMNS matrix and the mass splittings. However, if the option is provided, a file location is expected after the flag, corresponding to a SLHA file where the neutrino parameters are defined, and thus only two arguments are required. Note that this method only works if the package pyslha is installed. Other options are for a different solar model file, for verbose output and to print usage information.

The second script computes the probability of neutrinos at a given experimental location below the Earth’s surface. It is used in the following way

figure dz

where, as before, one can provide the full PMNS parameters and mass splittings explicitly, or as an SLHA file (with the option). In addition one must provide the initial neutrino state with the option in the flavour basis, or in the mass basis for an incoherent incoming flux. The neutrino state must be given as comma-separated list of three real or complex numbers, without spaces in between them, e.g.

figure ed

Other necessary arguments are the neutrino energy , in MeV, the nadir angle, , in radians, and the depth of the experiment , in meters. Additional options include to provide a different Earth density file, to perform the computations for antineutrinos, or to select either analytical or numerical evolution, for verbose output and to print usage information.

The expert mode allows the user to exploit all the functionalities of PEANUTS. It requires writing a configuration file in YAML format, hence this mode is only available if the optional pyyaml module is installed. For a given YAML file, the expert mode can then be used by using the executable in the following way

figure eo

Since most of the options are provided in the YAML file, this command only takes the options for verbose output and to print usage info. An example YAML file to compute the probability at the surface of the Sun can be seen below

figure er

The YAML file must contain the and nodes, as well as either the , or nodes. The and nodes can appear simultaneously to combine the effects, whereas the node cannot be combined with either. The node must simply contain a real number representing the neutrino energy in MeV. The node can either contain a map of the neutrino parameters, as in the example above, or a single string with the location of a SLHA file (provided pyslha is installed), always relative to the location of the executable, in the following way

figure fd

The node must contain a map with at least an entry for the neutrino fraction . As above, the list of available neutrino fractions is . By default, this will compute and print the probabilities of oscillation at Sun exit for all flavour eigenstates, but it can be disabled with the entry . Additionally, one can choose to print the total flux with (defaults to ) and the distorted or undistorted spectrum with or , both of which are disabled by default. Lastly one can select the specific solar model to use with the entry , the flux file with and the spectrum files with the entry . Note that if the solar model is not known to PEANUTS, in addition to the path to the relevant files, one must provide the location within those files where the information can be found, that is the entries , , , , , and , in the format described above in Sect. 2.

The node must contain a map with necessary entries to compute the probability at some location on Earth. Consequently, it requires an entry for the depth under the Earth’s surface, , and either a nadir angle or a . In addition, if the node is not present in the YAML file, a neutrino state is required as the entry (see below for an example), as well as an entry to specify in which basis it is, (coherent) or (incoherent). If the entry is select, the computations will be performed for an antineutrino. One can provide a user-defined Earth density profile by providing a density file with the entry , and indicate whether the density comes from tabulated data, with the entry or from a custom analytical expression, with the entry . It is also possible to choose either the numerical or analytical computation of the evolutor with or (the latter being the default). Lastly, if the entry is present, the probabilities will be computed integrated over exposure, and thus one provides entries to modify the normalization, days interval, number of samples, exposure file and exposure angle (see Sect. 5 for the meaning of these quantities) with the options ( or ), ([,]), (number of samples), (path) and (, or ), respectively. An example YAML file with only the earth node can be seen below

figure gx

The node must contain the minimal requirements to compute oscillations in vacuum. This means it requires an input neutrino and its , as for the earth oscillations above. It must also contain the distance traveled as , in km. Lastly, optionally one can request vacuum oscillations for antineutrinos with , and to switch on or off the printing of the probabilities or the evolved state with the and options, respectively.

By default, the results of a PEANUTS run will be printed to screen, but one can redirect the output to a file by adding the node to the YAML file. This node must contain a single string corresponding to the output file location, which will be created if it does not exist, or to print to screen (default). As an example, in order to redirect output to a file called out.dat in the same directory as the executable, the following node must be added to the YAML file

figure hh

Finally, PEANUTS allows the possibility to run simple grid scans of the input parameters provided in the YAML file. This can be achieved easily by providing a range of values instead of a single real value for the parameters. This range can be provided as , where a specific step size is selected, or , where the step will be computed so that a total of 10 samples for the parameter are produced. For instance, to scan over the energy between 20 and 100 MeV, with a step of 10 MeV, one could add the following to the YAML file.

figure hk
Fig. 6
figure 6

Survival probability at the surface of the Sun for \(^8B\) (left) and hep (right) neutrinos. The solid lines are the PEANUTS predictions, the dashed lines are the digitised curves for the SNO experiment, from Fig. 6.3 in [35]

PEANUTS can perform such simplistic grid scans on the neutrino energy (as seen above), as well as on any neutrino parameter (\(\Delta m_{21}^2\), \(\Delta m_{3l}^2\), \(\theta _{12}\), \(\theta _{13}\), \(\theta _{23}\) and \(\delta \)),Footnote 11 and on the nadir angle . Furthermore, one can scan a parameter in log scale by setting the parameter entry in the YAML file as , in which case , and are taken to be in log scale too. As these are crude grid scans, we do not recommend using this functionality for thorough scans of the full neutrino parameter space. For that purpose one should use smart sampling algorithms (see [59]), which can be easily interfaced with PEANUTS.Footnote 12

6.1 Validation

We have validated the results from PEANUTS with those published by the SNO experiment [35, 36], both against their predictions, e.g. fluxes and spectra, and their measured data, e.g. exposure and observed events. Here we document some of the validation tests that were performed. These can be reproduced by running the file shipped with PEANUTS, in the following way

figure hr

which allows for additional options to be supplied, such as to add a custom solar model, to add a custom earth density profile, to modify the default neutrino parameters with an SLHA file, and the ever present options for debug output and for usage info.

In order to compare the probability results with those from SNO, we use the same input values for the neutrino parameters, \(\theta _{12}\), \(\theta _{13}\), \(\Delta m_{21}^2\) and \(\Delta m_{3l}^2 = \Delta m_{31}^2\). The values of \(\theta _{23}\) and \(\delta \) are, for the most part, irrelevant for this comparison, but required by PEANUTS to build the full PMNS matrix, so for those we take the values found in [18]. Thus, the values used here are

$$\begin{aligned} \tan ^2\theta _{12}&= 0.469, \quad \sin ^2 \theta _{13} = 0.01, \quad \theta _{23} = 0.85521,\nonumber \\ \delta&= 3.4034\nonumber \\ \Delta m_{21}^2&= 7.9\times 10^{-5}, \quad \Delta m_{31}^2 = 2.46\times 10^{-3}. \end{aligned}$$
(84)

With these values, we can compare in Fig. 6 the prediction from our code with the SNO survival probabilities at the surface of the Sun for the \({}^8B\) and hep neutrinos, digitised from Fig. 6.3 in [35]. Naturally, for the same Solar model, the predictions of PEANUTS for each neutrino fraction match very well that reported by the SNO experiment.

Fig. 7
figure 7

Neutrino spectrum for the \(^8B\) (left) and hep (right) neutrino fractions at the surface of the Sun. Solid lines ares are the PEANUTS predictions for the distorted spectrum (with oscillations). The dotted lines are the undistorted spectrum (no oscillations). Dashed lines are computing distorting the spectrum with the survival probability from the digitised curves for the SNO experiment, from Fig. 6.3 in [35]

In addition to comparing the survival probability, we can compare the distorted (i.e. including oscillations) energy spectrum of neutrinos at the surface of the Sun. Figure 7 shows the effect of the oscillation distortion on the electron neutrino spectrum, as well as the comparison with the spectrum distorted by the SNO survival probability. For this comparison we have used the spectra in [53] for the \(^8B\) fraction and [52] for the hep fraction.

Fig. 8
figure 8

Oscillations of neutrino flavour eigenstates for \(\eta = 0\) (left) and \(\eta = \pi /2\) (right). The error quoted is the difference between the analytical and numerical results

Fig. 9
figure 9

Relative error between the numerical and analytical computations of the probability after Earth regeneration as a function of the energy for a chosen value of \(\eta = 0\) (left). Speed comparison of the analytical and numerical computations by PEANUTS and the computations by nuSQuIDS for two values of the neutrino energy (right)

In addition to validating the results against those of the SNO experiment, we have also validated our analytical approximation from Sect. 4.1 against the full numerical calculation described at the beginning of Sect. 4. Figure 8 shows the oscillation pattern of the neutrino flavour eigenstates for a neutrino crossing all Earth shells, \(\eta =0\) (left), and for a neutrino coming from the horizon, \(\eta =\pi /2\) (right), starting from a pure mass neutrino eigenstate \(\nu _\alpha = U_{\alpha 2}\). As expected, only in the first case the oscillations are significant, since the neutrinos traverse the whole Earth before reaching the detector, whereas in the second case the neutrino path only crosses part of Earth’s crust between the surface and the detector, and thus only minimal oscillation occurs. Since only the numerical computation can provide the full trajectory, the oscillations shown in Fig. 8 correspond exclusively to the numerical mode. However, for the same choice of parameters we have also used the analytical computation for the final probabilities, and the error reported in the figures precisely corresponds to the relative difference between the numerical and analytical models.Footnote 13 The difference is almost negligible, of the order of \(10^{-4}\) for the night period (left), and effectively zero during the day period. The left panel in Fig. 9 confirms this by showing the relative error as a function of the energy for the worse case of the ones above (i.e. during the night) for \(\eta =0\), where it can clearly be noticed that the error is small for all values of the energy, and only approaches \(\sim 10^{-2}\) at the worst for \(E_\nu \sim 10^2\) MeV. This comparison serves as a validation that the approximated analytical solution is a very good approximation and, since it is much faster, can be used in place of the full numerical evaluation.Footnote 14 For completeness, for the production of Fig. 9, the unitarity of the evolution matrix was confirmed, and no unphysical solutions were found. Figure 9 also shows a comparison with the results from the state-of-the-art tool for neutrino oscillations nuSQuIDS [62], where it can be seen that the agreement is also good with a relative error consistently below \(10^{-2}\). Therefore, the massive increase in computational speed provided by PEANUTS certainly justifies the small loss in precision.Footnote 15

To quantify this speed increase gained with the analytical implementation, we show in the right panel of Fig. 9 the computational time of the numerical and analytical computations as a function of number of evaluations, for two values of the neutrino energy \(E_\nu = 10\) MeV and \(E_\nu = 100\) MeV. For small number of evaluations the computational time is very similar between the analytical and numerical methods, but for a number of evaluations \(N \gtrsim 10\), the computational time for the numerical method increases drastically and soon becomes computationally unfeasible. In contrast the total CPU time of the analytical method remains constant for increasing number of evaluations, and it is mostly dominated by the overhead of the initialisation step. Only for \(N \gtrsim 10^5\) the computation time starts to increase noticeably, but still remains manageable up to large N. To emphasise further the increase of speed with the analytical implementation, the relative error shown on the left-hand panel of Fig. 9 required over \(9.2 \times 10^3\) seconds of CPU time to perform the numerical computations for all energies on a 2,3 GHz Intel Core i7 quad-core, compared to 5 s with the analytical method. Lastly, the right panel of Fig. 9 also shows a comparison with nuSQuIDS. For low number of evaluations, nuSQuIDS clearly outperforms PEANUTS, by virtue of being written in C++, but for large number of evaluations, as early as \(N\gtrsim 5\) for low energies and \(N\gtrsim 50\) for high energies, the analytical implementation of PEANUTS becomes significantly faster and, again, is the only feasible option for these large number of evaluations. It is worth noting that this comparison is done in the worst case scenario, where \(\eta =0\) and the neutrino path crosses almost the whole Earth. In less extreme scenarios, the computational speed of the numerical implementation of PEANUTS and the computations by nuSQuIDS are somewhat faster than shown.

Section 5 showed how to compute the ideal exposure time for a hypothetical experiment. For specific experiments, however, the exposure is often provided tabulated in bins of either the nadir angle \(\eta \), the zenith angle \(\theta \) or \(\cos \theta \). In the case of the SNO experiment, the exposure is provided in bins of \(\cos \theta \), hence we convert it into bins of \(\eta \) in order to match fit our computations of the probability. We then show in Fig. 10 the exposure of the SNO experiment compared to the ideal case. As SNO is located at a latitude of \(46.475^{\circ }\), we can see that it matches very well the ideal exposure at \(46^{\circ }\), with a slight under-exposure during the day and a slight over-exposure, during the night, which is consistent with the livetime of the SNO experiment.Footnote 16

Fig. 10
figure 10

Exposure of the SNO experiment in nadir angle \(\eta \) (red), compared to the ideal exposure for hypothetical experiments at various latitudes. Coloured bands are as in Fig. 5

Finally, in order to match the computations of PEANUTS with that of the SNO experiment, we reproduce the statistical fit of the oscillation parameters \(\theta _{12}\) and \(\Delta m_{21}^2\) performed by the SNO experiment. Figure 11 shows the results of the fit as a profile likelihood ratio. The dark purple star corresponds to the best fit point as found using PEANUTS, while the red star is that reported by the SNO collaboration. Similarly the purple and blue shared contours correspond to the 68% and 95% confidence intervals around the best fit point for our results, whereas the red dashed contours are the same from the SNO results. Note that this comparison, both our results and those from the SNO experiment, corresponds only to Phase I of the experiment [36], and for normal ordering of neutrino masses.Footnote 17 Details about this comparison will appear in a global fit by the GAMBIT Neutrino working group [60]. The results show a decent match with those reported by the SNO collaboration, with the best fit points laying very close to each other. The shape and reach of the contours is larger in our study, which can be attributed to a slight difference on the treatment of systematic uncertainties. It is crucial here to emphasize that a parameter scan of this magnitude is only feasible with the analytical implementation of PEANUTS, due to the large number of evaluations required. For reference, the scan sampled around 380k parameter points, each of which performed, on average, around 5k evaluations of the probability.

Fig. 11
figure 11

Profile likelihood ratio for the results of a statistical fit of the oscillation parameters \(\theta _{12}\) and \(\Delta m_{21}^2\) using PEANUTS (purple-blue) compared to the results reported by the Phase I of the SNO experiment (red). The fit was performed using GAMBIT [67] and the figure was generated with pippi [68]

7 Conclusions and outlook

We have presented in this paper PEANUTS, a fast and flexible software to automatically compute the energy spectra of solar active neutrinos, for arbitrary solar models and custom Earth density profiles. PEANUTS assumes adiabatic propagation of neutrinos within the Sun, and provides analytic computation for the coherent evolution of active neutrinos while crossing the Earth, thus completely avoiding any time-consuming numerical integration. This, together with extensive use of pre-compiled and just-in-time compilation optimisations, makes the software extremely fast and optimised for large-scale parameter scans.

PEANUTS provides algorithms to automatically perform the full chain of computations to simulate a solar neutrino experiment, as well as easy individual access to the modules and functions for specific computations. These include, for instance: mixing parameters in matter, incoherent flux at Sun surface, evolved neutrino state after Earth crossing, Earth density profile for given nadir angle, evolutor operator for given neutrino energy and nadir angle, nadir exposure for an experiment between two arbitrary days of the year, integrated probability of oscillation over a finite observation time. In the present version of PEANUTS we focused on providing automatisation for solar neutrinos, but the modularity of PEANUTS also allows a user to employ, for example, the function to compute the evolution of an atmospheric neutrino, or simulate the evolved spectra for hypothetical neutrinos produced in solar flares.

PEANUTS can be run in simple mode, for quick computations directly from the command line, as well as in expert mode, in which case the user provides a set of comprehensive instructions in the form of a YAML file. The expert mode is thus ideal for scripting, as it exploits all the possible functionalities of PEANUTS, and to perform simple explorations of the parameter space, as it natively allows the scanning of various input parameters on a grid.

We extensively validated PEANUTS against the results of the SNO experiment, and provide ready-to-run scripts to reproduce our results. We observed excellent agreement for the survival probability at Sun surface, distorted neutrino spectra for the \({}^8B\) and hep channels, annual nadir exposure and ability to reproduce the profile likelihood of the Phase I of the experiment for the parameters \(\theta _{12}\) and \(\Delta m^2_{21}\). We also validated our analytic computation of the evolved neutrino state with a numerical solution, and find excellent agreement on a wide range of energies. We performed a quick estimation of the CPU time scaling of the analytical and numerical computations with the number of evaluations, and conclusively found our analytical implementation to significantly outperform the numerical one for as few as \({\mathcal {O}}(10)\) evaluations. We also compared our results with those of nuSQuIDS and found good agreement as well. As with the numerical implementation, we found that our analytical solution vastly outperforms nuSQuIDS in terms of the computational time. PEANUTS thus presents a very fast alternative to existing tools without appreciable loss of precision. Therefore, due to its speed and user-friendly interface, we argue that PEANUTS is a very capable and useful tool for the computation of the propagation of neutrinos in the Sun and through Earth and a crucial addition to the software toolbox of the neutrino physics community.

Concerning the limitations of the software, the current PEANUTS version assumes adiabatic evolution within the Sun, which provides an excellent approximation for solar neutrino energies given the currently allowed range of oscillation parameters; the user is thus encouraged to check the validity of this regime if working in non-standard scenarios. We also stress that the code assumes coherent forward scattering for the propagation of neutrinos in matter: for Earth-type densities, inelastic scattering becomes important at energies above the TeV scale, and such effects must thus be taken into account. We plan to incorporate a more general routine for the arbitrary evolution of neutrinos in the Sun in a future version of PEANUTS. For inelastic scattering, other softwares are currently available, cf. e.g. [62, 69,70,71,72,73]. Though PEANUTS v1.0 does not yet provide all the functionalities that other software tools have, it vastly outperforms them in speed, which can be a critical factor in e.g. global studies, where the number of evaluations is very large.

Further improvements that will extend the scope of PEANUTS are under investigation, most notably the implementation of algorithms for the automatic computation of the atmospheric neutrino flux at a given location, as well as the simulation of accelerator neutrinos beams.