1 Introduction

With the first observation of a merging binary black hole in 2015 [1], gravitational wave detections have become an active part of observational astronomy. The first detection of a merging neutron star binary [2,3,4,5,6,7,8], in both gravitational waves (GWs) and electromagnetic (EM) radiation, followed in 2017 and this watershed event (hereafter referred to as GW170817) settled many long-standing open questions. It showed, among other things, that neutron star mergers are able to launch relativistic jets and can produce short gamma ray bursts [9,10,11,12] and it confirmed the long-held suspicion [13,14,15,16] that neutron star mergers are major production sites of r-process elements [7, 17, 18]. For an excellent recent review on r-process nucleosynthesis see [19]. The inspiral phase of GW170817 has also provided interesting constraints on the tidal deformability of neutron stars [3, 20, 21] and therefore on the properties of cold nuclear matter. The combined GW-/EM-detection further allowed to tightly constrain the propagation speed of gravitational waves [4] and to measure the Hubble parameter [2].

To connect multi-messenger observations to the physical processes that govern the merger and post-merger phases, one needs 3D numerical simulations that include the relevant physics ingredients. Despite the fact that the first fully relativistic simulations of a binary neutron star merger were performed more than two decades ago [22], the simulation of binary neutron star mergers has remained, until today, a formidable computational physics challenge [23,24,25,26]. Part of this is related to the multitude of involved physics ingredients, such as strong-field gravity, relativistic hydrodynamics, the hot nuclear matter equation of state (EOS) and neutrino transport. The other part is of purely numerical origin and includes, for example, dealing with the very sharp transition from high-density neutron star matter to vacuum, the accurate evolution of a spacetime, the treatment of singularities and horizons, or the huge range of length and time scales in the long-term evolution of ejected matter.

Until very recently all Numerical Relativity codes that solve the full set of Einstein equations used an Eulerian hydrodynamics framework [27,28,29,30]. While these approaches have delivered a wealth of precious insights into the dynamics and physics of compact binary mergers, they are also not completely free of limitations. For example, following the small amounts of merger ejecta, \(\sim 1\%\) of the binary mass, is a serious challenge for such approaches. This is because the advection of matter is not exact and its accuracy depends on the numerical resolution (which usually deteriorates with the distance from the collision site). Moreover, vacuum is usually treated as a low density atmosphere (but still often of the density of a low mass white dwarf star) which can impact the properties of the ejecta. Since the small amounts of ejecta are responsible for the entire EM signature, we have invested a fair amount of effort into developing a new methodology that is particularly well-suited for following such ejecta from a relativistic binary merger.

With a focus on ejecta properties and to increase the methodological diversity, we have recently developed [31] the first Numerical Relativity code that solves the full set of Einstein equations on a computational mesh, but evolves the fluid via Lagrangian particles according to a high-accuracy version of the Smooth Particle Hydrodynamics (SPH) method. This code has been developed from scratch and it has delivered a number of results that are in excellent agreement with established Eulerian codes, see [31]. Here we describe the further development of our new code with a particular focus on simulating the first fully relativistic binary neutron star (BNS) merger simulations with a Lagrangian hydrodynamics code.

Our paper is structured as follows. Section 2 is dedicated to the various new methodological elements of our code SPHINCS_BSSN (“Smooth Particle Hydrodynamics In Curved Spacetime using BSSN”). In Sect. 2.1.1 we summarize the major hydrodynamics ingredients, in Sect. 2.1.2 we describe our new (fixed) mesh refinement approach to evolve spacetime and in Sect. 2.1.3 we describe how the particles and the mesh interact with each other. Section 2.2 is dedicated to the detailed description of how we set up relativistic binary systems with (almost) equal baryon-number SPH particles based on initial configurations obtained with the LORENE library [32,33,34], using the new code SPHINCS_ID. In Sect. 3 we present our first BNS simulation results, in Sect. 2.1.4 we briefly describe the performance of the current code version and in Sect. 4 we provide a concise summary with an outlook on future work.

2 Methodology

Within SPHINCS_BSSN [31] we evolve the spacetime, like the more common Eulerian approaches, on a mesh using the BSSN formulation [35, 36], but we evolve the fluid via Lagrangian particles in a relativistic SPH framework, see [37,38,39,40] for general reviews of the method. Note that all previous SPH approaches used approximations to relativistic gravity, either Newtonian plus GW-emission backreaction forces [15, 41, 42], post-Newtonian hydrodynamics approaches [43,44,45] that implemented the formalism developed in [46], used a fixed background metric [47, 48] or the conformal flatness approximation [49, 50], originally suggested in [51, 52]. The latter approach obtains at each time slice a static solution to the relativistic field equations and therefore the spacetime is devoid of gravitational waves. For this reason GW-radiation reaction accelerations have to be added “by hand” in order to drive a binary system towards coalescence.

SPHINCS_BSSN is to the best of our knowledge the first Lagrangian hydrodynamics code that solves the full Einstein field equations. The code has been documented in detail in the original paper [31] and it has been extensively tested with shock tubes, oscillating neutron stars in Cowling approximation, oscillating neutron stars in fully dynamical spacetimes and with unstable neutron stars that either transit from an unstable branch to a stable one or collapse into a black hole. In all of these tests very good agreement with established Eulerian approaches was found.

Here, we present simulations of the first neutron star mergers with SPHINCS_BSSN and to this end we needed some additional code enhancements. These are, first, the use of a refined mesh (currently fixed in time; our original version used a uniform Cartesian mesh), and second, related modifications to the particle-to-mesh mapping algorithm. The third new element concerns the construction of initial configurations using an adaptation of the recently developed “Artificial Pressure Method” (APM) [31, 53] to the case of binary systems. Based on binary solutions obtained with the library LORENE [34], the APM represents the matter distribution with optimally placed SPH particles of (nearly) equal baryonic mass. We focus here mostly on the new methodological elements of SPHINCS_BSSN, for some technical details we refer the reader to the original paper [31].

As conventions, we use \(G=c=1\), with G gravitational constant and c speed of light, metric signature (\(-,+,+,+\)), greek indices run over \(0,\ldots ,3\) and latin indices over \(1,\ldots ,3\). Contravariant spatial indices of a vector quantity w at particle a are denoted as \(w^i_a\) and covariant ones will be written as \((w_i)_a\).

2.1 Time evolution code

We describe the Lagrangian particle hydrodynamics part of our evolution code in Sect. 2.1.1 and the spacetime evolution in Sect. 2.1.2. A new algorithm to couple the particles and the mesh is explained in Sect. 2.1.3. This new algorithm follows the ideas of “Multidimensional Optimal Order Detection” (MOOD) method [54].

2.1.1 Hydrodynamics

The simulations are performed in an a priori chosen “computing frame,” the line element and proper time are given by \(ds^2= g_{\mu \nu } \, dx^\mu \, dx^\nu \) and \(d\tau ^2= - ds^2\) and the line element in a 3+1 split of spacetime reads

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

where \(\alpha \) is the lapse function, \(\beta ^i\) the shift vector and \(\gamma _{ij}\) the spatial 3-metric. A particle’s proper time \(\tau \) is related to coordinate time t by \(\varTheta d\tau = dt\), where a generalization of the Lorentz factor

$$\begin{aligned} \varTheta \equiv \frac{1}{\sqrt{-g_{\mu \nu } v^\mu v^\nu }} \quad \mathrm{with} \quad v^\alpha =\frac{dx^\alpha }{dt} \end{aligned}$$
(2)

is used. This relates to the four-velocity \(U^\nu \), normalized to \(U^\mu U_\mu = -1\), via

$$\begin{aligned} v^\mu = \frac{dx^\mu }{dt}= \frac{dx^\mu }{d\tau } \frac{d\tau }{dt}= \frac{U^\mu }{\varTheta }= \frac{U^\mu }{U^0}. \end{aligned}$$
(3)

The equations of motion can be derived from the Lagrangian \(L= - \int T^{\mu \nu } U_\mu U_\nu \sqrt{-g}\, dV\), where g is the determinant of the spacetime metric and we use the stress–energy tensor of an ideal fluid

$$\begin{aligned} T^{\mu \nu }= (\rho +P)U^\mu U^\nu + P g^{\mu \nu }. \end{aligned}$$
(4)

Here P is the fluid pressure and the local energy density (for clarity including the speed of light) is given by

$$\begin{aligned} \rho = \rho _{\mathrm{rest}} + \frac{u \rho _{\mathrm{rest}}}{c^2}= n m_0 c^2 \left( 1 + \frac{u}{c^2}\right) . \end{aligned}$$
(5)

The specific internal energy (i.e., per rest mass) is abbreviated as u, and n is the baryon number density as measured in the rest frame of the fluid. The quantity \(m_0\) is the average baryon mass, the exact value of which depends on the nuclear composition of the matter. If the matter is constituted by free protons of mass \(m_p\) and mass fraction \(X_p\), free neutrons (\(m_n\), \(X_n\)) and a distribution of nuclei where species i has a mass fraction \(X_i\), a proton number \(Z_i\), neutron number \(N_i\), mass number \(A_i= Z_i + N_i\) and binding energies \(B_i\), then the average baryon mass is given by

$$\begin{aligned} m_0= X_p m_p + X_n m_n + \sum _i X_i \frac{Z_i m_p + N_i m_n - B_i}{A_i}. \end{aligned}$$
(6)

In practice, however, the deviations of the exact value of \(m_0\) from the atomic mass unit (\(m_u= 931.5\) MeV) are small. For example, for pure neutrons the deviation is below \(0.9 \%\) and for a strongly bound nucleus such as iron the deviation of the average mass from \(m_u\) would only be \(\approx 0.2 \%\). Therefore, we use in the following \(m_0 \approx m_u\). We further use from now on the convention that all energies are measured in units of \(m_0 c^2\) (and then use again \(c= 1\)). This means practically, that our pressure is measured in the rest mass energy units of \(m_0\), that is, it is the physical pressure divided by \(m_0\), and thus the \(\varGamma \)-law equation of state reads \(P= (\varGamma -1) n u\). Note that the specific energy u is, with our conventions, dimensionless and therefore it is not scaled.

Important choices for every numerical hydrodynamics method are the fluid variables that are evolved in time. We use a density variable that is very similar to what is used in Eulerian approaches [27,28,29, 55], which, with our conventions, reads

$$\begin{aligned} N= \sqrt{-g}\, \varTheta \, n. \end{aligned}$$
(7)

If we decide that each SPH particle a carries a fixed baryon number \(\nu _a\), we can at each step of the evolution calculate the density at the position of a particle a via a summation (rather than by explicitly solving a continuity equation)

$$\begin{aligned} N_a= \sum _b \nu _b\, W(|\vec {r_a} - \vec {r}_b|,h_a), \end{aligned}$$
(8)

where the smoothing length \(h_a\) characterizes the support size of the SPH smoothing kernel W, see below. Here and in all other SPH-summations the sum runs in principle over all particles, but since the kernel has compact support, it contains only a moderate number of particles (in our case exactly 300). We refer to these contributing particles as “neighbours.” As a side remark, we note that non-zero baryon numbers \(\nu _b\) and positive definite SPH kernels W ensure strictly positive density values at particle positions which makes it safe to divide by N in the equations below.

As momentum variable, we choose the canonical momentum per baryon which reads (a detailed step-by-step derivation of the equations can be found in Sec. 4.2 of [38])

$$\begin{aligned} (S_i)_a = (\varTheta {\mathcal {E}} v_i)_a, \end{aligned}$$
(9)

where \({\mathcal {E}}= 1 + u + P/n\) is the relativistic enthalpy per baryon. This quantity evolves according to

$$\begin{aligned} \frac{d(S_i)_a}{dt} = \left( \frac{d(S_i)_a}{dt}\right) _{\mathrm{hyd}} + \left( \frac{d(S_i)_a}{dt}\right) _{\mathrm{met}} \end{aligned}$$
(10)

with the hydrodynamic part being

$$\begin{aligned} \left( \frac{d(S_i)_a}{dt}\right) _{\mathrm{hyd}}= -\sum _b \nu _b \left\{ \frac{P_a}{N_a^2} D^a_i + \frac{P_b}{N_b^2} D^b_i \right\} \end{aligned}$$
(11)

and the gravitational part

$$\begin{aligned} \left( \frac{d(S_i)_a}{dt}\right) _{\mathrm{met}}= \left( \frac{\sqrt{-g}}{2N} T^{\mu \nu } \frac{\partial g_{\mu \nu }}{\partial x^i}\right) _a. \end{aligned}$$
(12)

In the hydrodynamic terms we have used the abbreviations

$$\begin{aligned} D^a_i \equiv \sqrt{-g_a} \; \frac{\partial W_{ab}(h_a)}{\partial x_a^i} \quad \mathrm{and} \quad D^b_i \equiv \sqrt{-g_b} \; \frac{\partial W_{ab}(h_b)}{\partial x_a^i}.\nonumber \\ \end{aligned}$$
(13)

The canonical energy per baryon reads

$$\begin{aligned} e_a= \left( S_i v^i + \frac{1 + u}{\varTheta }\right) _a = \left( \varTheta {\mathcal {E}} v_i v^i + \frac{1 + u}{\varTheta }\right) _a, \end{aligned}$$
(14)

and is evolved according to

$$\begin{aligned} \frac{d e_a}{dt}= \left( \frac{d e_a}{dt}\right) _{\mathrm{hyd}} + \left( \frac{de_a}{dt}\right) _{\mathrm{met}}, \end{aligned}$$
(15)

with

$$\begin{aligned} \left( \frac{d e_a}{dt}\right) _{\mathrm{hyd}} = -\sum _b \nu _b \left\{ \frac{P_a}{N_a^2} \; v_b^i \; D^a_i + \frac{P_b}{N_b^2} \; v_a^i \; D^b_i \right\} \end{aligned}$$
(16)

and

$$\begin{aligned} \left( \frac{de_a}{dt}\right) _{\mathrm{met}}= -\left( \frac{\sqrt{-g}}{2N} T^{\mu \nu } \frac{\partial g_{\mu \nu }}{\partial t}\right) _a. \end{aligned}$$
(17)

Note that the physical gradients in the hydrodynamic evolution equations are numerically expressed in the above SPH equations (11) and (16) by terms involving gradients of the SPH smoothing kernel W, see Eq. (13). This is the most frequently followed strategy in SPH. It is, however, possible to use more accurate gradient approximations that involve the inversion of a \(3\times 3\)-matrix. This gradient version was first used in an astrophysical context by [56] and it possesses the same anti-symmetry with respect to exchanging particle identities as the standard kernel gradient approach, which makes it possible to ensure numerical conservation exactly in a straightforward way; see, for example, Sec. 2.3 in [38] for a detailed discussion of conservation in SPH. This alternative gradient approximation has been extensively tested in [40] and [53] and was found to very substantially increase the overall accuracy of SPH.Footnote 1 Following [40], one can simply replace the quantity \(D_i^a\) in Eq. (13) by

$$\begin{aligned} {\tilde{D}}_i^a= \sqrt{-g}_a \sum _{d=1}^3 C_{id}(\vec {r}_a,h_a) \; (\vec {r}_b - \vec {r}_a)^d \; W_{ab}(h_a), \end{aligned}$$
(18)

and correspondingly for \({\tilde{D}}_i^b\), where the “correction matrix” (accounting for the local particle distribution) is given by

$$\begin{aligned} C_{ki} (\vec {r},h)= \left( \sum _b \frac{\nu _b}{N_b} (\vec {r}_b - \vec {r})^k (\vec {r}_b - \vec {r})^i W(|\vec {r}-\vec {r}_b|,h)\right) ^{-1}.\nonumber \\ \end{aligned}$$
(19)

For the simulations in this paper we use \({\tilde{D}}_i^a\) and \({\tilde{D}}_i^b\) (instead of \(D_i^a\) and \(D_i^b\)) in Eqs. (11) and (16).

With our choice of variables, the SPH equations retain the “look-and-feel” of Newtonian SPH, although the variables have a different interpretation. As a corollary of this choice, we have to recover the physical variables n, u, \(v^i\), P from the numerically evolved variables N, \(S_i\), e at every step. This “recovery step” is done in a similar way as in Eulerian approaches, the detailed procedure that we use is described in Sec. 2.2.4 of [31].

We use a modern artificial viscosity approach to handle shocks, where—following the original suggestion of von Neumann and Richtmyer [57]—the physical pressure P is augmented by a viscous pressure contribution Q. Here we briefly summarize the main ideas, but we refer to [31], Sec. 2.2.3, for the explicit expressions. For the form of the viscous pressure Q we follow [48], but we make two important changes. First, instead of using “jumps” in quantities between particles (i.e., differences of quantities at particle positions) we perform a slope-limited reconstruction of these terms to the midpoint between the particles and use the difference of reconstructed values from both sides in the artificial pressure. This reconstruction in artificial viscosity terms is a new element in SPH, but it has been shown to be very beneficial in Newtonian hydrodynamics [53, 58]. The second change concerns the additional time-dependence of the amount of dissipation applied. The expression for the viscous pressure Q contains a parameter which needs to be of order unity for dealing with shocks. This parameter can be made time-dependent [40, 59,60,61] so that it has a close to vanishing value where it is not needed. In steering this dissipation parameter, we follow the idea of [62] to monitor the entropy evolution of each particle. Since we are simulating an ideal fluid, the evolution should conserve a particle’s entropy perfectly unless it encounters a shock. Since, in our SPH version, entropy conservation is not actively enforced, we can use it to monitor the quality of the flow. If a particle either enters a shock or becomes “noisy” for numerical reasons its entropy will not be conserved exactly and we use this non-conservation to steer the exact amount of dissipation that needs to be applied. For details of the method we refer to the original paper [62] and to [31] for the SPHINCS_BSSN-specific implementation.

The SPH equations require a smoothing kernel function. We have implemented a large variety of different SPH kernel functions, but here we employ exclusively the Wendland \(C^6\)-smooth kernel [63] that we have also used in our original paper [31]. This kernel has provided excellent results in extensive test series [40, 53]. This kernel needs, however, a large particle number in its support for good estimates of densities and gradients and we therefore assign to each particle a smoothing length so that exactly 300 particles contribute in the density estimate, Eq. (8). This number has turned out to be a good compromise between accuracy and computational effort and it is enforced exactly as a further measure the keep the numerical noise very low. In practice, we achieve this via a very fast “recursive coordinate bisection” tree-structure [64] that we use to efficiently search for neighbour particles. For further implementation details concerning the smoothing length adaptation, we refer to [53].

2.1.2 Spacetime evolution on a structured mesh

We have implemented two frequently used variants of the BSSN equations in SPHINCS_BSSN, the “\(\varPhi \)-method” [35, 36] and the “W-method” [65, 66]. The corresponding code was extracted from the McLachlan thorn [67] in the Einstein Toolkit [68, 69], and we built our own wrappers to call all the needed functions. The complete set of BSSN equations is rather lengthy and will therefore not be reproduced here. It can be found in Numerical Relativity text books [27,28,29, 55, 70] and also in the original SPHINCS_BSSN paper [31]. For all the tests presented later in the paper we use the “\(\varPhi \)-method.” We expect our simulations to be insensitive to this choice, as the two methods differ mostly in their treatment of black hole punctures. Hence the simulations could just as well have been done using the “W-method”.

Our original implementation [31] evolved the spacetime on a uniform Cartesian grid, but for the complex geometry of a neutron star merger a (vertex-centered) fixed mesh refinement scheme is much more efficient. In this scheme, the first refinement level consists of a coarse grid whose outer boundaries represent the physical boundaries of the spacetime simulation. Each next, finer level has the same number of grid points, but the boundaries placed at only half of the previous level, and consequently this refinement level has twice the resolution. Any number of refinement levels can be specified.

As we are using finite differences (FD) to calculate the spatial derivatives for the spacetime evolution, we need to surround the finer grids with a number of ghost grid points that are filled with values from the previous, coarser grid via an interpolation (“prolongation”) operator. This is illustrated for two levels of refinement in Fig. 1. When prolongating in 3D, the fine grid points can be divided into four classes depending on where they are located on a cube defined by eight coarse grid points: (1) at the corners (vertices), (2) at the center of edges, (3) at the center of faces and (4) at the center of the cube. Hence we do not need a fully general interpolation scheme and it is sufficient, and also more efficient, to implement only a small subset specialized for those four specific cases. In the current code version, we have linear and cubic polynomial interpolation implemented. For linear interpolation, the interpolated value is simply the value of the coinciding coarse grid point for the corner case. When the fine grid point is located on the edge of the cube, it is exactly between two coarse grid points and linear interpolation reduces to the average of those two coarse grid points. Similarly when the fine grid point is located on the face or center of a cube, it is always located at the exact center of four (face) or eight (center) coarse grid points and linear interpolation reduces to just the average of those coarse grid points. For the edge-centered fine grid points (for simplicity we only write the x-direction here) the cubic interpolation stencil consists of four coarse grid points located at \(x_i-3\delta x\), \(x_i-\delta x\), \(x_i+\delta x\) and \(x_i+3\delta x\) with values \(\vec {f_{\mathrm {e}}}=(f_{i-3},f_{i-1},f_{i+1},f_{i+3})\), where \(\delta x\) is the fine grid spacing. In this case, the unique interpolating cubic polynomial corresponds to weights \(\vec {w}_{\mathrm {e}}=(-1/16,9/16,9/16,-1/16)\) so that the interpolated value at \(x_i\) is \(f_i=\vec {w}_{\mathrm {e}}\cdot \vec {f_{\mathrm {e}}}\). The interpolating operators in the y- and z-directions are similarly defined. For interpolation of face-centered points, the stencil, \(\vec {f}_{\mathrm {f}}\), will consist of \(4\times 4\) coarse grid points that we flatten into a row vector of length 16 and the weights are simply the vectorization of the outer product of the weights for the edge interpolation (producing a column vector of length 16) \(\vec {w}_{\mathrm {f}}=\mathrm {vec}(\vec {w}_{\mathrm {e}}\bigotimes \vec {w}_{\mathrm {e}})\) and the interpolated value is \(f_i=\vec {w}_{\mathrm {f}}\cdot \vec {f_{\mathrm {f}}}\). In practice the flattening is done in the x-direction first, but the order does not matter since the outer product of weights for the edge interpolation is symmetric.

Finally, for interpolation of the cube centered points, the stencil, \(\vec {f}_{\mathrm {c}}\), will consist of \(4\times 4\times 4\) coarse grid points flattened into a row vector of length 64 and, again, the weights are simply the vectorization of the outer product of the weights for the edge interpolation \(\vec {w}_{\mathrm {c}}=\mathrm {vec}(\vec {w}_{\mathrm {e}}\bigotimes \vec {w}_{\mathrm {e}}\bigotimes \vec {w}_{\mathrm {e}})\) (this time producing a column vector of length 64) and the interpolated value is \(f_i=\vec {w}_{\mathrm {c}}\cdot \vec {f_{\mathrm {c}}}\).

Fig. 1
figure 1

An illustration of 2 levels of grid refinement used in the code. The coarse grid points are shown as blue squares, the fine grid points as green ones and the ghost points (needed for the finite difference operators near the boundary of the fine grid) are marked as red crosses

During the evolution, we update the values in the coarse grid points wherever possible with values from the fine (more accurate) grid (“restriction”). As coarse grid points that need restriction always coincide with a fine grid point, restriction simply consists of copying the value from the fine grid point to the coarse grid point.

We integrate our coupled system of hydrodynamics and BSSN equations via a 3rd order Total Variation Diminishing (TVD) Runge–Kutta integrator [71]. During each substep, the right-hand-sides (RHS) for the BSSN variables are calculated using finite differences (FD) where possible, that is, everywhere except at the ghost points (taking into account the size of the FD stencil) on all refinement levels. The state vector (consisting of all evolved variables on all possible grid points) is then evolved forward in time on all refinement levels where the RHS has been computed. After that, the state vector is updated in the ghost zones on each fine grid, via prolongation from the next-coarser grid, in a loop over refinement levels starting from the coarsest level. Finally, the solution on the coarser grids are updated via restriction from the finer grids in a second loop over refinement levels starting from the finest refinement level.

When interpolating metric information from the grid to the particles, we first find out which refinement level to interpolate from. Obviously, we want to use the finest possible refinement level in order to get the most accurate metric information on the particles. We therefore start on the finest refinement level and check whether the considered particle is located inside this grid. If it is, we perform the interpolation the same way as described in [31]. If it is not, we move on to the next refinement level. We repeat until the interpolation can be performed or we reach the coarsest refinement level. Handling particles that leave the coarsest grid is not necessary for the cases presented here, but it will be implemented for future studies of merger ejecta.

2.1.3 Particle–mesh coupling: A MOOD approach

A crucial step in our approach is the mapping of \(T_{\mu \nu }\), originally known at the particle positions, to the mesh (“P2M-step”) and the mapping of the metric acceleration terms \((dS_i/dt)_{\mathrm{met}}\) and \((de/dt)_{\mathrm{met}}\) from the mesh to the particle positions (“M2P-step”), see Eqs. (12) and (17). In this paper, we provide a further refinement of the P2M-step, see below, whereas the M2P-step is the same as in our original paper [31].

We map a quantity A known at particle positions \(\vec {r}_p=(x_p,y_p,z_p)\) to the grid point \(\vec {r}_g\) via

$$\begin{aligned} A_g= A(\vec {r}_g)= \frac{\sum _p V_p A_p \,\varPsi _g(\vec {r}_p)}{\sum _p V_p \, \varPsi _g(\vec {r}_p)}, \end{aligned}$$
(20)

where \(V_p= \nu _p/N_p\) is a measure of the particle volume. We construct the functions \(\varPsi \) as tensor products of 1D shape functions

$$\begin{aligned} \varPsi _g(\vec {r}_p)= \varPhi \left( \frac{|x_p-x_g|}{l_p}\right) \varPhi \left( \frac{|y_p-y_g|}{l_p}\right) \varPhi \left( \frac{|z_p-z_g|}{l_p}\right) ,\nonumber \\ \end{aligned}$$
(21)

where \(l_p=V_p^{1/3}\). After extensive experimenting, we had settled in the original paper on a hierarchy of shape functions that have been developed in the context of vortex methods [72].

The interpolation quality of the shape functions is closely related to the order with which they fulfill the so-called moment conditions [72]

$$\begin{aligned} \sum _q x_q^\alpha \varPhi (x_q-x)= x^\alpha \quad \mathrm{for} \quad 0 \le |\alpha | \le m-1, \end{aligned}$$
(22)

for points located at \(x_q\). This means that the interpolation is exact for polynomials of a degree less than or equal to \(m-1\) and such an interpolation is said to be “of order m” [72]. Good interpolation quality, however, does not automatically guarantee the smoothness of the shape functions, understood as the number of continuous derivatives. In fact, a number of shape functions that are commonly used, e.g. in particle-mesh methods for plasmas, are of low smoothness only and this can introduce a fair amount of noise in simulations. Being of higher order m, however, comes at the price of a larger stencil and therefore at some computational expense. Positive definite functions can only be maximally of order two [73], for higher orders the shape functions need to contain negative parts which can become problematic when the particle distribution within the kernel is far from being isotropic. A particularly disastrous case is encountering a sharp (e.g. stellar) surface. Here, violent Gibbs-phenomenon like oscillations can occur that can lead to unphysical results. For this reason we have implemented a hierarchy of kernels, so that the highest order shape functions can be used when it is safe, and less accurate, but more robust functions are used when it is not. How this is decided and implemented is described below.

Last, but not least, another characteristics of shape functions is their highest involved polynomial degree (“degree”).Footnote 2 In this work we use smooth shape functions of high order that were constructed by Cottet et al. [74]. We follow their notation of using \(\varLambda _{p,r}\) for a function that is of order \(p+1\) (i.e., reproduces polynomials up to order p) and of smoothness \(C^r\). Our chosen shape functions are the following:

  1. (i)

    the \(\varLambda _{4,4}\)-kernel (order 5, regularity \(C^4\) and degree 9) [74]

    $$\begin{aligned}&\varLambda _{4,4} (|x|) \nonumber \\&\quad =\left\{ \begin{array}{lll} 1 - \dfrac{5}{4}|x|^2 + \dfrac{1}{4} |x|^4 - \dfrac{100}{3} |x|^5 + \dfrac{455}{4} |x|^6 &{}\\ -\dfrac{295}{2} |x|^7 + \dfrac{345}{4} |x|^8 - \dfrac{115}{6}|x|^9, &{} |x|< 1,\\ -199 + \dfrac{5485}{4} |x| - \dfrac{32975}{8} |x|^2 &{}\\ + \dfrac{28425}{4} |x|^3 -\dfrac{61953}{8}|x|^4 + \dfrac{33175}{6} |x|^5 &{}\\ - \dfrac{20685}{8} |x|^6 + \dfrac{3055}{4} |x|^7 - \dfrac{1035}{8} |x|^8 &{}\\ + \dfrac{115}{12} |x|^9, &{} 1 \le |x|< 2,\\ 5913 - \dfrac{89235}{4} |x| + \dfrac{297585}{8} |x|^2 &{}\\ -\dfrac{143895}{4} |x|^3 + \dfrac{177871}{8} |x|^4- \dfrac{54641}{6} |x|^5 &{}\\ + \dfrac{19775}{8}|x|^6- \dfrac{1715}{4} |x|^7 + \dfrac{345}{8} |x|^8 &{}\\ - \dfrac{23}{12} |x|^9, &{} 2 \le |x| < 3, \\ 0, &{} \mathrm{else}. \end{array}\right. \end{aligned}$$
    (23)
  2. (ii)

    \(\varLambda _{2,2}\) kernel (order 3, smoothness \(C^2\), degree 5 [74]

    $$\begin{aligned} \varLambda _{2,2} (|x|) = \left\{ \begin{array}{llr} 1 - |x|^2 - \dfrac{9}{2} |x|^3 + \dfrac{15}{2}|x|^4 &{} \\ - 3 |x|^5, &{} \; |x|< 1, \\ -4 + 18 |x| -29|x|^2 &{} \\ + \dfrac{43}{2}|x|^3 - \dfrac{15}{2} |x|^4 + |x|^5 , &{} \; 1\le |x| <2,\\ 0, &{} \; \mathrm{else}. \end{array}\right. \end{aligned}$$
    (24)
  3. (iii)

    and, finally, the \(M_4\) kernel (order 2, smoothness \(C^2\), degree 3) [72]

    $$\begin{aligned} M_4 (x) = \left\{ \begin{array}{llr} \dfrac{1}{6}\big (2-|x|\big )^3 - \dfrac{2}{3}\big (1-|x|\big )^3, &{} |x|< 1,\\ \dfrac{1}{6}\big (2-|x|\big )^3, &{} 1 \le |x| < 2,\\ 0, &{} \mathrm{else.} \end{array}\right. \end{aligned}$$
    (25)

Note that \(\varLambda _{4,4}\) and \(\varLambda _{2,2}\) are, differently from usual SPH-kernels, not positive definite. The supports of these kernels are sketched (for a 2D example) in Fig. 2. We apply a hierarchy of these kernels starting with \(\varLambda _{4,4}\) followed by \(\varLambda _{2,2}\) and we use the safest (positive definite, but least accurate) kernel \(M_4\) as a “parachute.”

In the original paper we applied a heuristic method based on the particle content of the neighbour cells to decide which kernel to use. Instead of this, we use here a Multidimensional Optimal Order Detection (MOOD) method. The main idea is to use a “repeat-until-valid” approach, that is, to use the most accurate kernel that does not lead to any artifacts. To detect artifacts we check whether the resulting grid values of \(T^g_{\mu \nu }\) are outside of the range of the values of the contributing particles, see below. This strategy is actually similar to MOOD approaches that are used in hydrodynamics; see, for example, [54]. Specifically, we proceed according to the following steps:

  1. (i)

    Start with the highest order kernel \(\varLambda _{4,4}\) for the mapping.

  2. (ii)

    Check whether the \(\varLambda _{4,4}\)-result is acceptable: if all components of \(T^g_{\mu \nu }\) at a given grid point are inside of the bracket \([T^\mathrm{min}_{\mu \nu },T^\mathrm{max}_{\mu \nu }]\), where the maximum and minimum values refer to the particles inside the \(\varLambda _{4,4}\) support, we accept the \(\varLambda _{4,4}\)-mapping. Otherwise, we consider the mapping as questionable and proceed to the next kernel, \(\varLambda _{2,2}\).Footnote 3

  3. (iii)

    Check whether the \(\varLambda _{2,2}\)-result is acceptable: as in the previous step, we check whether the grid-result is outside of the bracket given by the particles in the support of \(\varLambda _{2,2}\). If it is not, the \(\varLambda _{2,2}\)-mapping is accepted.

  4. (iv)

    If also the \(\varLambda _{2,2}\)-result is not acceptable, we resort to our “parachute” solution, the positive definite \(M_4\)-mapping.

Fig. 2
figure 2

2D sketch of the support sizes for the different kernels that are used in the MOOD-mapping for a specific grid point (red square). The green square indicates the support of the \(\varLambda _{4,4}\)-kernel, blue refers to \(\varLambda _{2,2}\) and red to the “parachute” kernel \(M_4\)

Fig. 3
figure 3

For an efficient mapping of the particle-\(T_{\mu \nu }\) to the gravity grid on refinement level n (on which the spacetime is evolved; grid spacing \(\delta ^{(n)}\); thin lines), we employ an additional hash grid with twice the grid-spacing (\(\varDelta ^{(n)}\); thick lines). This is illustrated for the 2D-case in the upper part of the figure. The actual particle data needed for the mapping is stored in a cache-friendly linear array, see the lower part of the figure and the main text for more details

Efficient implementation via a hash grid. The tasks involved in the P2M-step are (a) identify all particles that contribute to any given grid point, see Eq. (20), that is, those particles that are within the (tensor-product) support of the grid point’s kernel, (b) loop over all grid points and add the particle \(T_{\mu \nu }\)-contributions.

We have implemented an efficient P2M-step that involves a hash grid at each refinement level n. The mesh size of our hash grid \(\varDelta ^{(n)}\) is chosen to be twice the mesh size of the gravity grid, \(\delta ^{(n)}\), see upper part of Fig. 3 for an illustrating sketch in 2D. The reason why we chose a factor of two is that when updating the stress–energy tensor at a given gravity grid point, we need to collect the contributing particles from the hash grid. We do not want to have to check too many hash grid cells, so the hash grid cells should be larger than the gravity grid cells. On the other hand, they should not be too large, since then we would loop over many particles that in the end do not contribute to the grid point. A factor of two fulfils these criteria and makes the involved details (e.g., getting the hash grid indices from the gravity grid indices) very simple.

For performance reasons we store the data needed in the P2M-mapping process in a simple linear cache-array. The hash grid is only “virtual” in the sense that its structure is only needed to identify particles belonging to the same hash grid cell, but the data is actually stored in the linear cache-array. We first identify the 3D indices (ijk) of the hash grid cell that contains the particle. These indices are then translated into a single index in our linear cache-array via \(l^\mathrm{lin}= i + (j-1)n_x + (k-1)n_xn_y\), where \(n_x,n_y, n_z\) are the numbers of hash grid cells in the x-, y- and z-direction on the current mesh refinement level. The index \(l^\mathrm{lin}\) labels a segment in the cache-array that contains all the data associated with the particle in hash grid cell (ijk) that is needed for the mapping. Since all data is stored in exactly the order in which it is needed, this approach guarantees virtually perfect cache efficiency.

The particles are filled into this hash grid as follows:

  • In one first linear loop over the particles, each particle determines in which hash cell (ijk) it is located. Each of the hash cells keeps track of how many particles it contains.

  • After this loop, we can quickly count the number of entries, so that each (ijk) hash cell knows how many entries there are in the cache-array corresponding to the previous cells. In other words, after this (very fast) counting step, each hash grid cell knows the starting and finishing index that define the cache-array section storing all the properties of the particles contained in this (ijk) hash cell. Hence, all subsequent summations can be performed very efficiently.

  • In another linear loop, those particle properties that are needed during the actual mapping are filled into the 1D array in exactly the same order in which they will be addressed during the mapping step (position, particle volume, stress–energy tensor components): \((x,y,z,V,T_{00},T_{0x}, ... ,T_{zz})\). The resulting cache-array is sketched in the bottom part of Fig. 3. This cache-array approach has the advantage that the array has a fixed maximum length of 14 times the SPH particle number. We apply this mapping sequentially for each grid refinement level. If all particles are contained in the grid of a given level, the cache-array is completely filled, otherwise it is shorter since it does not contain entries from the particles outside the grid. Most importantly, the cache-array has to be allocated only once during the simulation, its size is known at compile time, and it can be used for every refinement level as a memory-efficient, “read-only” data structure in the P2M-step.

  • The actual contribution-loop for each grid cell is then performed by checking the particle content of each potentially contributing hash cell and, if applicable, the particle contribution is added according to Eq. (20).

Compared to our initial, straightforward implementation, the above described cache-efficient P2M-step is more than 20 times faster for the simulations shown in this paper.

2.1.4 Code performance

Table 1 Breakdown of the time spent in different parts of the code. The different parts of the code are, in order: computation of the right-hand-sides (RHSs) in the hydro (SPH) and BSSN equations, mapping of the stress–energy tensor from the particles to the grid (P2M), mapping of the metric from the grid to the particles (M2P), restriction operators, prolongation operators, and finally the state vector update (see Sect. 2.1 for more details). Note that not all parts of the code are listed, so numbers do not add up to 100%. The symbols LR, MR and HR refer to low, medium and high resolution, see Sect. 3.1

The code is written in modern Fortran, except for the C++ routines which we extracted from McLachlan from the Einstein Toolkit in order to be able to evolve the spacetime. Currently the code is parallelized for shared memory architectures using OpenMP directives and pragmas. As the time spent in different parts of the code depends on the particle distribution, it is impossible to uniquely quantify the performance, but based on the simulations presented here, we can give some representative numbers.

In Table 1 we give a breakdown of how the time is spent in various important parts of the code for representative low, medium and high resolution runs. As can be seen, the major part of the time is spent in the hydrodynamics and spacetime evolution routines with additional significant time spent in the mapping of the stress–energy tensor to the grid. Running the code on compute nodes equipped with 128 AMD EPYC 7763 processors it initially takes 1.3, 3.2, 7.8 minutes to evolve one code unit of time at low, medium and high resolution respectively. This is maintained for the duration of the inspiral but as smaller time steps are required for hydrodynamic stability during and after the merger, the times required to evolve 1 code unit of time at the end are 2.2, 5.1 and 11.3 minutes at low, medium and high resolution, respectively. The memory usage for one of the medium resolution runs presented here is about 30 GB.

The OpenMP scaling is decent, but can certainly be improved. Scaling experiments show a speedup of about 43 on 128 cores.

2.2 Initial data

A crucial ingredient for every relativistic simulation are initial data (ID) that both satisfy the constraint equations and accurately describe the physical system of interest. In the following, we describe how we compute such ID for BNS, that we subsequently evolve with SPHINCS_BSSN.

2.2.1 Quasi-equilibrium BNS with LORENE

The library LORENE computes ID for relativistic BNS under the assumption of “quasi-equilibrium,” see [32] and [75, Sec. 9.4] for more details. This assumption states that the radial velocity component of the stars is negligibly small compared to the azimuthal one and the orbital evolution is essentially realized via a sequence of circular orbits. Equivalently, one assumes that a helical Killing vector field exists. This assumption is reasonably well justified since at a separation of \(\sim 50\) km, the time derivative of the orbital period (at the second post-Newtonian level) is about \(2\%\) of the period itself [32].

LORENE allows to compute ID for corotational and irrotational binaries. Since any neutron star viscosity is too small to spin up the neutron stars during the rapid final inspiral stages to corotation [32, 76, 77], the irrotational case is generally considered more realistic, but mergers with rapidly spinning neutron stars can lead to interesting effects and the corresponding simulations are now feasible [78,79,80]. In this paper, we restrict ourselves to irrotational binaries. Another assumption that is made in LORENE is the conformal flatness of the spatial metric \(\gamma _{ij}\). This is a commonly made approximation which substantially simplifies the solving of the constraint equations.

LORENE provides spectral solutions that can be evaluated at any point. By default, the code BinNS in LORENE allows to export the LORENE ID to a Cartesian grid. However, this is not sufficient for our purposes, since we need to evaluate the solution not only on our refined mesh, but also at the positions of the SPH particles. Hence, we have extended BinNS to evaluate the spectral data at any given spacetime point. We have further linked the relevant functions in BinNS to our own code that sets up the ID for SPHINCS_BSSN and is called SPHINCS_ID. Since in the original version of LORENE, BinNS was able to handle only BNS with single polytropic EOS, we extended it to read and export also configurations with piecewise polytropic and tabulated EOS such as those available in the CompOSE database [81]. In other words, all the needed information that LORENE provides about the BNS is accessible within SPHINCS_ID. Despite having these capabilities, we restrict ourselves to purely polytropic equations of state in this first study.

2.2.2 The “Artificial Pressure Method” for binary systems

SPH initial conditions are a delicate subject. The particle distribution has to, of course, accurately represent the physical system under consideration (e.g., densities and velocities), but there are additional requirements concerning how the particles are actually distributed, see, for example, [40, 82, 83]. The particle arrangement should be stable, so that in an equilibrium situation, the particles ideally should not move at all. Many straightforward particle arrangements (such as cubic lattices), however, are not stable and particles quickly start to move if set up in this way. The reason is a “self-regularization” mechanism built into SPH that tries to locally optimize the particle distribution (see, e.g., Sec. 3.2.3 in [84] for more details). To make things even harder, the particles should be distributed very regularly, but not in configurations with pronounced symmetries, since the latter can lead to artifacts, for example if a shock propagates along such a symmetry direction.Footnote 4 Last, but not least, the SPH particles should ideally have practically the same masses/baryon numbers, since for large differences numerical noise (i.e., small scale fluctuations in the particle velocities) occurs that can have a negative impact on the interpolation accuracy.

All of these issues are addressed by the “Artificial Pressure Method” (APM) to optimally place SPH particles. The method has been suggested in a Newtonian context [53] and was recently generalized to the case of general relativistic neutron stars [31]. In this work, we go one step further and apply the APM in the construction of relativistic binary systems.

The main idea of the APM is to start from a distribution of equal-mass particles and let the particles find the positions in which they minimize their density error with respect to a desired density profile. In other words, each particle has to measure in which direction the density error is decreasing and move accordingly.

In practice, this is achieved by assigning to each particle a an “artificial pressure,” \(\pi _a\), that is based on the discrepancy between actual, measured SPH-density, \(\rho _a\), and the desired profile value at the position of the particle, \(\rho ^P(\vec {r}_a)\):

$$\begin{aligned} \pi _a= \mathrm{max}\left( 1 + \frac{\rho _a-\rho ^P(\vec {r}_a)}{\rho ^P(\vec {r}_a)}, 0.1 \right) \end{aligned}$$
(26)

where the max-function has been used to avoid negative pressures. For more details of the method we refer to the original paper [53]. This pressure is then used in a position update formula that is modelled after a fluid momentum equation (see [53] for the derivation):

$$\begin{aligned} {\delta \vec {r}_a}^\mathrm{APM}= -\frac{1}{2}h_a^2\nu _0 \sum _b \frac{\pi _a+\pi _b}{N_b} \nabla _a W_{ab}(h_a), \end{aligned}$$
(27)

where the quantities have the same meaning as in the fluid section, Sect. 2.1.1, and \(\nu _0\) is the baryon number desired for each particle (equal to the total baryon mass divided by the chosen particle number). Iterations with such position updates drive the particles towards positions where they minimize their density error. It does, however, not necessarily guarantee that the particle distribution is locally regular and provides a good interpolation accuracy (for corresponding criteria see, e.g., Sec. 2.1 in [84]). To achieve this, we add a small additional “regularization term” [85]Footnote 5

$$\begin{aligned} {\delta \vec {r}_a}^\mathrm{reg}= h_a^4 \sum _b W_{ab}(h_a) {\hat{e}}_{ab}, \end{aligned}$$
(28)

where \({\hat{e}}_{ab}= (\vec {r}_a-\vec {r}_b)/|\vec {r}_a-\vec {r}_b|\), so that the final position update reads

$$\begin{aligned} \vec {r}_a \rightarrow \vec {r}_a + (1-\zeta ){\delta \vec {r}_a}^\mathrm{APM} + \zeta {\delta \vec {r}_a}^\mathrm{reg}. \end{aligned}$$
(29)

The parameter \(\zeta \) determines how important the local regularity requirement on the particle distribution is compared to the accuracy with which the desired density profile is reproduced. Since our main emphasis is on reproducing the desired density, the value of \(1-\zeta \) should not be too much below unity, but the exact parameter value is only of minor importance. We find good results for \(\zeta =0.05\), which we use throughout this paper. We start the APM iteration with an initial particle distribution obtained by first placing particles on spherical surfaces, as described in Appendix B.1, and then slightly moving them away from the surfaces by a small random displacement. We noticed that the use of such random displacements led to better results of the APM procedure.

A crucial ingredient of the method is the placement of the “boundary” or “ghost” particles. These serve as a shield around the star to prevent the real particles from exiting the surface of the star during the APM iteration. The artificial pressure that we assign to these ghost particles is a few times higher (we use three times) than the maximum value inside the star. This is to ensure that particles that approach the stellar surface from the inside, see an increasing pressure gradient which keeps them inside the stellar surface. Since the stars in a close binary system are tidally deformed, the ghost particles have to be placed in a way that allows the real particles to model the surface geometry, see Appendix B.2 for more details on how this is achieved. Once the APM iteration has converged, the ghost particles are discarded. Figure 4 shows the ghost particles (red) placed around the real particles (black) on spherical surfaces before and after applying the APM, for one star of one of our simulations (run LR_2x1.3_G2.00, see Table 2).

Fig. 4
figure 4

Shown are the particle distributions before (a) and after (b) the APM iteration for one neutron star of our run LR_2x1.3_G2.00, see Table 2. The physical SPH particles are shown in black and the ghost/boundary particles (discarded after the APM iteration) are shown in red. The plots are cuts through the xz and xy plane, within \(y \in [-1.18,1.18]\) km and \(z \in [-1.18,1.18]\) km

Fig. 5
figure 5

Typical relative density errors (i.e., relative difference between the SPH kernel density estimate at particle positions and the LORENE density) after the APM iteration on the xz and xy planes (the contours are computed using particles in \(y\in [-0.44,0.44]\) km and \(z\in [-0.44,0.44]\) km, respectively). The same star as in Fig. 4 (LR_2x1.3_G2.00, see Table 2) is shown. Typical density errors in the bulk of the star are below 1%, whereas in the hard-to-resolve surface layers, errors can reach 10%

After each step of the APM iteration, the particle positions are reset so that the center of mass of the particle distribution coincides (within machine precision) with the stellar center of mass given by LORENE. In addition, at each step of the APM iteration, the particle positions are reflected about the xy plane, to impose exact equatorial-plane symmetry.

Once the APM iteration with particles of equal baryon number, \(\nu _0\), has converged, we perform one single, final correction of the individual particle baryon numbers, \(\nu _a\). To this end we first calculate the SPH particle number density,Footnote 6

$$\begin{aligned} {\tilde{N}}_a= \sum _b W_{ab}(h_a), \end{aligned}$$
(30)

and then assign to each particle the “desired” baryon number

$$\begin{aligned} \nu _a^\mathrm{des}= \frac{N_a}{{\tilde{N}}_a}, \end{aligned}$$
(31)

where \(N_a\) is the density according to LORENE. The baryon number assigned to each particle is a “capped” version of \(\nu _a^\mathrm{des}\) in (31), so that \(\nu _a\) remains in the interval \([\sqrt{2}\nu _o,\nu _o/\sqrt{2}]\) and the baryon number ratio is \(\le 2\). This correction step changes the baryon masses only moderately, but improves the density estimate in the outer layers by roughly an order of magnitude.

This method allows to obtain a low baryon number ratio on each star, separately. In order to have a low baryon number ratio overall, that is, across both stars, we set the particle numbers within each star to have a similar ratio as the binary mass ratio. For more details, see Appendix B.1.

Figure 5 shows contour plots of the relative difference between the LORENE mass density and the SPH kernel estimate of the mass density performed on the final particle distribution (including the one update on the baryon number). In the bulk of the stars the errors are lower than \(\sim 1\)%. Only in the surface layers are the errors larger. Here, the very steep physical density gradients are difficult to capture at finite resolution with nearly equal SPH particle masses. These layers will adjust slightly at the beginning of a simulation, trying to find a true numerical equilibrium.

As the last comment, we note that, for equal-mass BNS, we use the APM to place particles within one star only. The particles in the second star are obtained by simply reflecting those on the first star with respect to the yz plane. In this way, the symmetry of the system is preserved also at the level of the particle distribution.

2.2.3 Initial values for the SPH particles

Once the final particle locations have been found, we need to assign particle properties according to the  LORENE solution. The computing frame fluid velocity in Eq. (3) is related to the fluid velocity with respect to the Eulerian observer \(v^i_\mathrm {Eul}\) (provided by LORENE) by

$$\begin{aligned} v^0 = 1, \quad v^i = \alpha \, v^i_\mathrm {Eul} - \beta ^i. \end{aligned}$$
(32)

The generalized Lorentz factor \(\varTheta \) can then be computed from \(v^i\) using Eq. (2). The baryon number per particle \(\nu \) is determined as described in Appendix B.1 and Sect. 2.2.2. The smoothing length h of each particle is computed so that each particle has exactly 300 contributing neighbours in the density estimate, as in SPHINCS_BSSN. Then, knowing \(\nu \) and h, the density variable N can be computed using Eq. (8), and the local rest frame baryon number density n is computed inverting Eq. (7),

$$\begin{aligned} n= \dfrac{N}{\sqrt{-g}\; \varTheta }. \end{aligned}$$
(33)

The local rest frame baryon mass density is then

$$\begin{aligned} \rho _{\mathrm{rest}}=n\, m_{0}, \end{aligned}$$
(34)

where \(m_{0}\) is the average baryon mass. The specific internal energy u and the pressure P are then computed using the EOS, starting from \(\rho _{\mathrm{rest}}\).

Table 2 Parameters of the performed simulations. The masses are gravitational masses in solar units. \(\varGamma \) is the polytropic exponent and K the corresponding constant in code units. The initial orbital angular velocity \(\varOmega _0\) is in units of rad/s. The quantity \(h_{\mathrm{min}}\) is the minimal smoothing length during the evolution, \(\varDelta _g^\mathrm{min}\) is the grid resolution at the finest refinement level, and they are both given in m. \(n_\mathrm{grid}\) is the number of grid points on each refinement level. All simulations start from a coordinate separation of \(a_0= 30.4748\) (corresponding to 45 km) and use 7 levels of grid refinement, with the outermost refinement level’s boundary at \(\approx 2268\) km

2.2.4 BSSN initial data on the refined mesh

The ID for the BSSN variables is computed straightforwardly by first importing the LORENE ID for the standard 3+1, or ADM, variables to each level of the mesh refinement hierarchy, and then computing the BSSN variables from them using a routine extracted from the McLachlan thorn from the Einstein Toolkit [69].Footnote 7 For the sake of clarity, we note that, for the runs shown in this paper, we use the initial values for the lapse function and the shift vector that LORENE provides.

3 Simulations

In our original paper, we had focused on test cases where the outcomes are accurately known. These included shock tubes (exact result known), oscillating neutron stars in Cowling approximation and in dynamically evolved space times (in both cases oscillation frequencies are accurately known) and, finally, the evolution of an unstable neutron star that, depending on small initial perturbations, either transitions into a stable configuration or collapses and forms a black hole (results known from independent numerical approaches, e.g., [87,88,89]). In all of these benchmarks our results were in excellent agreement with established results.

Here, we want to take the next step towards more astrophysically motivated questions. In particular, we want to address for the first time the merger of two neutron stars with SPHINCS_BSSN.

3.1 Initial Setup

In this first study, we simulate two binary systems with \(2\times 1.3\) M\(_{\odot }\) and \(2\times 1.4\) M\(_{\odot }\), each time with a soft (\(\varGamma = 2.00\), \(K= 100\) in code units; \(M_{\mathrm{max}}^\mathrm{TOV}\approx 1.64\) M\(_{\odot }\)) and a stiff (\(\varGamma = 2.75\), \(K= 30~000\) in code units; \(M_{\mathrm{max}}^\mathrm{TOV}\approx 2.43\) M\(_{\odot }\)) EOS. Both equations of state are admittedly highly idealized, and in one of our next steps we will include the physical EOSs that are provided by the CompOSE database [81]. Each of the simulations are run at three different resolutions: (a) low-resolution (LR) with \(5 \times 10^5\) SPH particles and \(121^3\) grid points on every refinement level, (b) medium-resolution (MR) with \(10^6\) SPH particles and \(143^3\) grid points on each refinement level and (c) high-resolution (HR) with \(2\times 10^6\) SPH particles and \(193^3\) grid points on each refinement level. All simulations start from a coordinate separation of 45 km, and employ seven refinement levels out to 1536 code units (\(\approx \) 2268 km) in each direction. The parameters of the performed simulations are summarized in Table 2, the quoted numbers are accurate to \(\sim \) 1%.Footnote 8 Note that we also show the minimum smoothing length, \(h_{\mathrm{min}}\), during a simulation. This is, of course, a quantity that adapts automatically according to the dynamics and that is not determined beforehand. For example, the \(h_{\mathrm{min}}= 40\) m in run LR_2x1.3_G2.00 is so small because the central object at very late times (\(\sim \) 18 ms) collapses to a black hole. This is a very low resolution result, it should be interpreted with caution.

3.2 Results

Fig. 6
figure 6

Density evolution of the simulations (top to bottom) HR_2x1.3_G2.00, HR_2x1.3_G2.75, HR_2x1.4_G2.00 and HR_2x1.4_G2.75, see Table 2 for the corresponding parameters

In Fig. 6 we show snapshots of the rest-mass density evolution of the HR runs of our different binaries, with \(t= 0\) corresponding to the simulation start. Figure 7 shows the evolution of the maximum density (left) and minimum lapse value (right) of the corresponding runs and Fig. 8 shows the quadrupole GW amplitudes \(h_{\mathrm{max}}\) (for an observer located along the rotation axis; see Appendix A) times the distance to the observer \(D_{\mathrm{obs}}\). These quadrupole approximation results are written out “on the fly” and they can be compared to the more accurate results that can be extracted in a post-processing step from the spacetime evolution, see below.

Fig. 7
figure 7

Evolution of the maximum density and the minimum lapse value for the HR-runs

As expected, the cases with the soft EOS, where the stars are more compact and therefore closer to the point mass limit, show a substantially longer inspiral and chirp signal (lines 1 and 3 vs lines 2 and 4 in Fig. 8). Being more compressible, their peak density evolution is also more impacted by the merger, see the left panel of Fig. 7, and this is also reflected in the evolution of the minimum lapse value (right panel). In the cases with the stiff EOS, in contrast, where the stars are larger and more mass is at larger radii from the stellar centre, tidal effects are much more pronounced and effectively represent a short-range, attractive interaction [26, 90]. Therefore our binaries with stiff EOS merge within less than two orbital revolutions from the chosen initial separation. Being rather incompressible, the post-merger central densities are actually only moderately above the central densities of the initial individual stars, see Fig. 7, left panel, and also the lapse oscillations (right panel) are small. All of the remnants seem to evolve to more compact configurations, but of the shown cases only HR_2x1.3_G2.00 collapses to a black hole during the simulated times.

For the simulations afforded in this study, numerical resolution still has a noticeable effect on the inspiral as, for example, demonstrated by simulation HR_2x1.3_G2.00, which takes about one orbit more until merger than LR_2x1.3_G2.00 (upper right vs upper left in Fig. 8). The HR runs with the soft equation of state do show some signs of amplitude variations that could be attributed to eccentricity, whereas the low and medium resolutions do not seem to show that. We certainly do expect some eccentricity due to the assumptions going into the ID construction. As to why it is more pronounced in the HR case, it is possible that the low and medium resolution runs are short enough so that signs of eccentricity are washed out. Finally, these extracted waveforms are calculated from gauge dependent quantities and the amplitude variations could be entirely spurious. All investigated systems, apart from the \(2\times 1.4\) M\(_{\odot }\) cases with \(\varGamma =2.00\), leave a stable remnant (at least on the simulation time scale) and therefore keep emitting gravitational waves. The exceptional case, see row three in Fig. 6, undergoes a prompt collapse to a black hole within \(\sim \) 1 ms after merger (Fig. 7) which efficiently shuts off the gravitational wave emission (row three in Fig. 8). A collapse to a black hole is expected when the binary mass exceeds \(\sim 1.5 \times M_{\mathrm{max}}^\mathrm{TOV}\) [91,92,93,94], so the collapse in HR_2x1.4_G2.00 is actually expected given that \(M_{\mathrm{max}}^\mathrm{TOV}\) is only 1.64 M\(_{\odot }\) and the initial ADM mass of the system is 2.9M\(_{\odot }\).

Fig. 8
figure 8

Gravitational wave amplitudes computed with the quadrupole formula, see Appendix A, for the simulations (top to bottom) HR_2x1.3_G2.00, HR_2x1.3_G2.75, HR_2x1.4_G2.00 and HR_2x1.4_G2.75, see Table 2. The quantity \(D_{\mathrm{obs}}\) is the distance to the observer in code units, and \(h_{\mathrm{max}}\) is the maximal amplitude for an observer located on the z axis

We have, in addition to using the quadrupole formula, also extracted gravitational waves based on the spacetime data using both thorn Extract and (in combination) thorns WeylScal 4 and Multipole from the Einstein Toolkit [69]. The procedure was to read in metric data from our third coarsest refinement level at the times we had checkpoint data, run the wave extraction tools and finally use the formulae in Appendix A.2 to calculate the strain as well as the radiated energy and angular momentum. We used detectors at spheres of coordinate radii 50, 100, 150, 200, 250 and 300. We see very good agreement between the results from Extract and WeylScal 4, but as the WeylScal 4 waveforms are less noisy we only report on those results in the following.

In Fig. 9 we plot the radiated energy, \(\varDelta E\), and z-component of the angular momentum, \(\varDelta J_z\), as function of time for the system with two 1.4 M\(_{\odot }\) neutron stars and \(\varGamma =2.75\). The quantities are plotted as percentages of the initial ADM values of the spacetime, \(E^0\) and \({J_z}^0\). We can clearly not yet claim convergence of these results as the rate of energy and angular momentum emission after merger increases significantly from the medium to high resolution runs and the behavior of the low resolution run is substantially different showing a decreasing rate of emission at late times.

Fig. 9
figure 9

The accumulated radiated energy, \(\varDelta E\) (left plot), and z-component of the angular momentum, \(\varDelta J_z\) (right plot) in percent of the initial values, \(E^0\) and \({J_z}^0\) for the system with two 1.4 M\(_{\odot }\) neutron stars and \(\varGamma =2.75\) extracted at the detector at coordinate radius R = 300. In both plots the green, orange, black curves are for the low, medium and high resolution runs, respectively

In Table 3, we list the final radiated energy at the end of our simulations, \(\varDelta E\), andz-component of the angular momentum, \(\varDelta J_z\), again as percentages of the initial ADM energy \(E^0\) and angular momentum \(\varDelta J_z^0\) of the spacetime for a sample of our simulations. Note that in the simulations listed, the merger remnant has not yet collapsed to a black hole, hence the systems are still emitting strong gravitational waves. In addition, as we cannot claim that the quantities are converged, we can are unable to perform a conclusive comparison with, for example, the results of [95], but for now we can only state that our simulations appear to be consistent.

Table 3 Percentage of radiated energy, \(\varDelta E\), and z-component of angular momentum, \(\varDelta J_z\), with respect to the initial ADM energy, \(E^0\), and ADM angular momentum, \(J_z^0\) for a sample of our simulations. As all simulations were not run for the same amount of time, we also list the simulation duration, \(t_{\mathrm {end}}\)

In Fig. 10 we show a comparison of the maximal strain amplitude extracted using either the quadrupole formula or the Weyl scalar \(\varPsi _4\). Here the strain from \(\varPsi _4\) is the sum of spin weight \(-2\) spherical harmonic modes from \(\ell =2\) to 4 evaluated on the z-axis (\(\theta =0\) and \(\phi =\pi /2\) to match the observer orientation) and then shifted in time (by about 1.54 ms) to account for the signal travel time to the detector. As can be seen, the quadrupole formula consistently underestimates the amplitude (especially after the merger; less so during the inspiral). This is in agreement with [96] where it was found that the amplitudes could be over- or underestimated by more than 50% depending on the definition of density used. On the other hand, also in agreement with [96], the frequencies are well captured by the quadrupole formula.

Fig. 10
figure 10

Comparison of the maximal strain amplitude as calculated by the extraction of \(\varPsi _4\) (black) and the quadrupole formula (QF, orange) for the simulations with two 1.4M\(_{\odot }\) neutron stars and \(\varGamma =2.75\). The strain from \(\varPsi _4\) is the sum of spin-weight \(-2\) modes from \(\ell =2\) to 4 evaluated on the z-axis (\(\theta =0\)) and shifted in time by 1.54 ms in order to align it with the quadrupole waveform. The quantity \(D_{\mathrm{obs}}\) is the distance to the observer (code units), and \(h_{\mathrm{max}}\) is the maximum amplitude for an observer located on the z axis

Fig. 11
figure 11

Particle positions (within \(|z| < \) 1 km) in run HR_2x1.4_G2.75, see Table 2, prior to merger. Modelling the transition between the neutron star matter and vacuum represents a serious numerical challenge for Eulerian hydrodynamic approaches. In our approach, however, the stellar surface does not require any special treatment and it remains smooth and well-behaved during the inspiral without any “outlier particles”

We also want to briefly illustrate a major advantage of our methodology: the treatment of the neutron star surface. Contrary to traditional Eulerian approaches, the sharp transition between the high-density neutron star and the surrounding vacuum does not pose any challenge for our method and no special treatment such as an “artificial atmosphere” representing vacuum is needed. The particles merely adjust their positions according to the balance of gravity and pressure gradients to find their true numerical equilibrium and vacuum simply corresponds to the absence of particles. Throughout the inspiral, the neutron star surface remains smooth and well-behaved without any “outliers,” see Fig. 11. This illustrates the quality of both the evolution code and the initial particle setup, see Sect. 2.2.2.

At the interface where the two neutron stars come into contact, a Kelvin–Helmholtz unstable shear layer forms. Although we are presently not modelling magnetic fields, it is worth pointing out that this shear layer is important for magnetic field amplification. In the resulting Kelvin–Helmholtz vortices initially present magnetic fields can be efficiently amplified beyond magnetar field strength [97,98,99,100], which obviously has a large astrophysical relevance for potentially increasing the maximum remnant mass, magnetically ejecting matter and for launching GRBs. Traditional SPH-approaches have been found to be challenged in resolving weakly triggered Kelvin–Helmholtz instabilities [101, 102], but these problems are absent in the modern high-accuracy SPH-approach that is implemented in SPHINCS_BSSN, mostly due to the reconstruction procedure in the dissipative terms and to the much more accurate gradients than those used in “old school SPH.”Footnote 9 To illustrate the Kelvin–Helmholtz instabilities that emerge in our SPHINCS_BSSN simulations, we show the density near the shear interface between the two stars for our simulation HR_2x1.4_G2.75 in Fig. 12. In this simulation four vortices are initially triggered, that subsequently move inwards and finally merge. While the initial stages show an almost perfect symmetry, see Fig. 12, tiny asymmetries, seeded by the numerics, are amplified by the Kelvin–Helmholtz instability and finally lead to a breaking of exact symmetry. It goes without saying that such a breaking of perfect symmetry will also occur in nature.

The Kelvin–Helmholtz instability also seeds physical odd-m instabilities in the merger remnant. In fact, [103] found, in a dedicated study, that several odd-m modes are seeded, among which the \(m=1\) is the most pronounced one. These modes grow exponentially and saturate on a time scale of \(\sim 10\) ms. The study concluded that the appearance of the \(m=1\) one-armed spiral instability is a generic outcome of a neutron star merger for both “soft” and “stiff” equations of state. They found, however, the instability to be very pronounced for their stiff EOS (MS1b [104]) and hardly noticeable for their soft EOS (SLy [105]). These findings are consistent with our results shown in Fig. 6, where the \(\varGamma = 2.75\) cases show noticeable deviations from perfect symmetry, whereas the \(\varGamma =2.00\) cases show no obvious deviations.

Last, but not least, we show in Fig. 13 the Hamiltonian constraint along the x-axis for representative simulations (two 1.3 M\(_{\odot }\) stars with the \(\varGamma =2.0\) equation of state) at 4 different times: shortly after the start of the simulations, after half an orbit, a full orbit (shortly before the neutron stars touch) and a significant time after the merger. In each plot 3 resolutions are shown, scaled for \(2^\mathrm{nd}\) order convergence. In the top left plot (early in the simulations) the accuracy of the initial data limits the convergence for \(|x|>50\) km. In the three remaining plots, it is clear that the constraint violations are largest where the matter is located, but remain low in the exterior and converge at about 2nd order. See Appendix C for the computation of the constraint violations for the initial data.

4 Summary and outlook

In this paper, we have described the current status of our freshly developed general-relativistic, Lagrangian hydrodynamics code SPHINCS_BSSN. Since the focus of our original paper [31] was to demonstrate the ability to accurately handle fully dynamical, general relativistic single stars, our main focus here is on those new methodological elements that are needed to simulate relativistic binary neutron star mergers. These elements include, in particular, a structured mesh (“fixed mesh refinement”; see Sec 2.1.2) on which we evolve the spacetime. This, in turn, requires improvements to the particle–mesh coupling, as explained in detail in Sect. 2.1.3. Finally, we describe a new method to accurately set up SPH particles based on the results from initial data solvers such as LORENE, see Sect. 2.2. The method is implemented in a new code called SPHINCS_ID.

Given the central role of Numerical Relativity for relativistic astrophysics and for gravitational wave astronomy, we consider this (to the best of our knowledge) first Lagrangian hydrodynamics approach that solves the full set of Einstein equations, as an important step forward. It will allow to validate both Eulerian Numerical Relativity approaches as well as Lagrangian ones that use only approximate strong-field gravity.

Despite this progress, it is clear that our current code version only contains the most basic physics ingredients, that is, relativistic hydrodynamics, dynamical evolution of the spacetime and simple equations of state. The first detection of a binary neutron star merger [3, 4], however, has impressively underlined the multi-physics nature of neutron star merger events. It has demonstrated in particular that neutron star mergers are, as it had been expected for some time [14,15,16, 106], prolific sources of r-process elements [9, 17, 18, 107]. The detection of the early blue kilonova component [108] and the identification of strontium [109], a very light r-process element that is only synthesized for moderately large electron fractions, have emphasized that weak interactions play a crucial role in shaping the observable features of a neutron star merger event. Moreover, the short GRB following GW170817 demonstrated that (at least some) neutron star mergers are able to launch relativistic jets. Taken together, these observations suggest that at least nuclear matter properties, neutrino physics and likely magnetic fields are major actors in a neutron star merger event.

Fig. 12
figure 12

Evolution of the Kelvin–Helmholtz vortices in simulation HR_2x1.4_G2.75, see Table 2

Fig. 13
figure 13

The Hamiltonian constraint along the x-axis scaled for \(2^\mathrm{nd}\) order convergence for the runs with two 1.3 M\(_{\odot }\) stars and the soft equation of state (\(\varGamma =2.00\)) at different times in the simulations. We have only plotted the three finest refinement levels and have indicated the boundaries between refinement levels with vertical thin lines. The top left plot is at \(t=0.05\) ms, that is, shortly after the beginning of the simulation. The top right plot is at the \(t=1.81\) ms (low resolution), \(t=1.84\) ms (medium resolution) and \(t=1.87\) ms (high resolution), when the neutron stars have returned to the x-axis after half an orbit. The bottom left plot is at \(t=3.13\) ms (low resolution), \(T=3.23\) ms (medium resolution) and \(t=3.33\) ms (high resolution), when the stars have again returned to the x-axis after having completed a full orbit. The final bottom right plot is at a \(t=13.1\) ms, that is, a time significantly after the merger

Our next SPHINCS_BSSN development steps will be geared towards both further technical improvements and towards more realistic micro-physics. On the technical side, for example, we expect that the amount of dissipation that is applied in the hydrodynamic evolution can be further reduced and we aim at further increasing the code’s computational performance. In the current stage, both (artificial) dissipation and finite resolution likely still leave a noticeable imprint on the simulation outcome. On the micro-physical side, we consider the implementation of realistic nuclear matter equations of state as they are provided in the CompOSE database as an important and natural step forward. In addition to increasing the physical accuracy of the matter description, this ingredient is also indispensable to follow the electron fraction \(Y_e\) of the ejecta and to implement (any kind of) neutrino physics. CompOSE equations of state can be used in LORENE but, in its present form, SPHINCS_BSSN does not yet support tabulated EOSs. The implementation of tabulated equations of state requires changes in the very core of our hydrodynamics scheme; in particular, we have to change the algorithm for the conversion from conserved to primitive variables. This has, of course, been successfully done in Eulerian contexts [110, 111], and is certainly also doable for our equation set, but it will require some dedicated effort. Once this has been achieved, we will tackle the implementation of a fast, yet reasonably accurate neutrino treatment such as the Advanced Spectral Leakage Scheme (ASL) [112,113,114]. These issues will be addressed in future work.