Skip to main content
Advertisement
Browse Subject Areas
?

Click through the PLOS taxonomy to find articles in your field.

For more information about PLOS Subject Areas, click here.

  • Loading metrics

A direct Primitive Variable Recovery Scheme for hyperbolic conservative equations: The case of relativistic hydrodynamics

  • A. Aguayo-Ortiz ,

    Roles Conceptualization, Data curation, Formal analysis, Funding acquisition, Investigation, Methodology, Project administration, Resources, Software, Supervision, Validation, Visualization, Writing – original draft, Writing – review & editing

    aaguayo@astro.unam.mx

    Affiliation Instituto de Astronomía, Universidad Nacional Autónoma de México, AP 70-264, Ciudad de México 04510, México

  • S. Mendoza,

    Roles Conceptualization, Data curation, Formal analysis, Funding acquisition, Investigation, Methodology, Project administration, Resources, Software, Supervision, Validation, Visualization, Writing – original draft, Writing – review & editing

    Affiliation Instituto de Astronomía, Universidad Nacional Autónoma de México, AP 70-264, Ciudad de México 04510, México

  • D. Olvera

    Roles Conceptualization, Data curation, Formal analysis, Funding acquisition, Investigation, Methodology, Project administration, Resources, Software, Supervision, Validation, Visualization, Writing – original draft, Writing – review & editing

    Affiliation School of Mathematics, University of Bristol, Bristol BS8 1TW, United Kingdom

Abstract

In this article we develop a Primitive Variable Recovery Scheme (PVRS) to solve any system of coupled differential conservative equations. This method obtains directly the primitive variables applying the chain rule to the time term of the conservative equations. With this, a traditional finite volume method for the flux is applied in order avoid violation of both, the entropy and “Rankine-Hugoniot” jump conditions. The time evolution is then computed using a forward finite difference scheme. This numerical technique evades the recovery of the primitive vector by solving an algebraic system of equations as it is often used and so, it generalises standard techniques to solve these kind of coupled systems. The article is presented bearing in mind special relativistic hydrodynamic numerical schemes with an added pedagogical view in the appendix section in order to easily comprehend the PVRS. We present the convergence of the method for standard shock-tube problems of special relativistic hydrodynamics and a graphical visualisation of the errors using the fluctuations of the numerical values with respect to exact analytic solutions. The PVRS circumvents the sometimes arduous computation that arises from standard numerical methods techniques, which obtain the desired primitive vector solution through an algebraic polynomial of the charges.

Introduction

The use of numerical methods to solve differential equations has constituted a substantial amount of work since the conception of approximate solutions to a given set of equations. In the last few decades, digital computers have been a great help to heavily iterate complicated partial differential equations using extensive numerical, parallel and adaptive mesh techniques in personal computers and large clusters.

Physical laws are often written in a set of conservative differential equations, for which there are many well established convergent numerical techniques to obtain accurate solutions. In spite of this, there is an intermediate step that is often, depending on the nature of the problem, extremely cumbersome to deal with. This appears since the general solution to the problem is obtained as a set of vector charges q at every point or cell on a given domain of space at a particular time in the iteration. However, physical phenomena are described and measured by means of a set of vector primitive variables u. Depending on the nature of the physical problem, the function u(q) may not have an analytic form and so, at every point or cell of the integration space a cumbersome technique requires to be performed for each time step. No matter how fast this routine may be, it introduces an extra computational time that can heavily grow when the space-time resolution increases. In problems of special relativistic hydrodynamics this fact appears and, at each time step, a 10th degree algebraic polynomial has to be solved for a unique given value of each component of the vector u (see e.g., for an excellent account on this, [1]).

To make things even more complicated, for each particular physical problem it is necessary to have either an analytic solution u(q) or a specific numerical technique to obtain it.

In this article we show how it is possible to construct a general numerical iteration method, using a combination of finite differences and finite volume integration techniques for the time and spatial evolutions respectively, to directly find the solutions u avoiding any middle cumbersome step such as the ones mentioned above. This technique is so general that requires no analytical knowledge whatsoever of u(q). The method developed is general and valid to any set of coupled conservative equations. We also show how this method can be applied in the particular case of 1D special relativistic hydrodynamics (1DRHD). For this particular case, we construct convergence tests.

The article is organised as follows. In the Appendix, we briefly mention some (mostly used in relativistic hydrodynamics for shock capturing) of the traditional methods to solve a set of conservative equations. In Section 1 we construct our “Primitive Variable Recovery Scheme (PVRS)” which can directly obtain the primitive variables from quite a standard numerical procedure. Section 4 deals with different convergence relativistic Sod [2] shock-tube tests and error estimates are given using a standard L1-norm. Also, the errors are graphically interpreted using the fluctuations of the solution with respect to analytical known values is presented. Finally, in Section 5 we discuss and conclude our results.

1 Primitive Variable Recovery Scheme (PVRS)

In the appendix we discuss some of the standard techniques for discretising any set of scalar and coupled conservative equations. This is done in order to easy understand the further developments of the article for the less expert reader, and not to interrupt the experienced one with such well known methods. However, we note that in the appendix and in what follows Einstein’s summation convention will be used throughout the equations displayed in this article, something that does not usually appear in the literature.

The usual way to solve a system of hyperbolic equations (cf. Eq (15)): (1) is by implementing Finite Difference and Finite Volume Methods (FDM & FVM) in order to obtain solutions for the conservative charges q. In the particular case of relativistic and non-relativistic hydrodynamics, these charges are the linear momentum along the three dimensions Si, the energy τ and the particle density D. In order to compare the numerical solution with experiments and/or observations, a set of primitive physical measurable variables u needs to be constructed. For this particular case, this primitive variable set is given by by the pressure p, the velocity along three spacial dimensions vi and, the particle number density n. Some authors prefer to find the particle mass density ρ rather than the particle number density n. For most practical proposes, both variables are related by ρ = mn where m is the average mass per particle. In here and in what follows all thermodynamical quantities (pressure p, particle number density n and energy density e and so on, are measured on its proper reference frame following the convention in [3, 4]). The explicit dependences q = q(u(x, t)) and f = f(u(x, t)) for 1D flow in the special relativistic case are given by (see e.g. [3, 4]): (2) (3) (4) where e is the total (rest plus internal) proper energy per unit volume which can be related with the density and pressure via a state equation e = e(n, p) like the one derived by Tooper [5] for a polytropic relativistic gas: (5) where κ is the polytropic index. In the previous equations and in what follows we choose a system of units in which the velocity of light is set to unity.

As we can see from Eqs (24), obtaining the inverse function u = u(q(x, t)) results in quite a completed algebraic problem. In fact, the solution to this problem leads to a system of transcendental algebraic equations that have been deeply studied by Riccardi [1]. One way of solving this system is by using a Newton-Raphson method (cf. [6]) but this or any other numerical solution to obtain u(q(x, t)) will carry an extra error besides the proper numerical error of the FDM or FVM. This procedure also adds a bit of computational processing time since an iteration loop to find the solution needs to be carried out at each cell every time step. In order to avoid this cumbersome task, we show now how it is possible to obtain a direct numerical solution of the primitive variables, which is valid for all conservative equation systems (cf. Eq (15)).

2 PVRS attempts with finite difference methods

Let us begin by writing the system of m hyperbolic equations showing the explicit dependence on m primitive variables, i.e.: (6) A necessary and sufficient condition for the existence of the solution u1, …, um is that a = 1, …, m. Now, using the chain rule, the above equation can be written in the following quasilinear form: (7) where ∂q/∂u and ∂f/∂u are the Jacobian matrixes of the vectors q and f respectively. Multiplying the previous equation by the inverse matrix (∂q/∂u)−1 we get (8) where (9)

If we perform a discretisation of Eq (8) using a FDM (see e.g. Section Finite differences approach of the appendix), we obtain the following numerical expression: (10)

No matter how complicated the functional representations of q(u) and f(u), it is possible (if not by hand, using a Computer Algebra System) to compute the matrix Mab only once before implementing a discretisation scheme. In what follows we show how to implement a numerical scheme to find directly the primitive variables u solving Eq (8). By doing this, the cumbersome step of recovering u from q at every cell for each time step is not needed anymore.

The discretisation Eq (10) is accurate to the first-order and yields quite good results on smooth solutions. When the solution contains a shock wave, the method is stable but not consistent and so no convergent. This could be understood because Eq (10) is mathematically similar to Eq (16) of the appendix [7] with the substitution of the vector u instead of q. Furthermore, Eq (10) is written in a non-conservative form and so, the entropy and Rankine-Hugoniot jump conditions are not satisfied across the shock waves. Due to this fact, the obtained solution converges to a different weak solution as compared to the one obtained by a conservative method (see e.g. [8]). In other words, this FDM scheme does not work and the approach to follow is to consider flux contributions as in standard FVM.

3 Primitive Variable Recovery Scheme using combined FDM and FVM

We now show how to implement a Primitive Variable Recovery Scheme (PVRS) using both a FDM and a FVM schemes for the time and spatial evolution of the equations. As mentioned at the end of the previous section, the fluxes contribution in the method must not be altered because the entropy and Rankine-Hugoniot jump conditions must be accomplished. To do so, the spatial derivative term must be evolved using a Godunov-type method (e.g. an HLL-type Riemann solver).

In the appendix it is shown that the conservative set of Eq (1) can be discretised in the form of relation Eq (48), which can be written in a semi-discrete form as: (11) where FHLL stands for the HLL-type Riemann solver approximation for the spatial fluxes (see appendix). Using the chain rule on the left hand side of the previous equation, it follows that: (12) where . By applying a forward-difference formula scheme on the left hand side of Eq (12), we get (13)

In Eq (13), we take a numerical flux approach as in standard FVM and a finite difference of the time derivative over the primitive variables u. The approximate solution to the Riemann problem, where Rankine-Hugoniot’s condition take place, is the same as the one presented in the appendix HLL Riemann solver section. Furthermore, the characteristic velocities used in the HLL solver which correspond to the the eigenvalues of the Jacobian ∂f/∂q, can be computed either from matrix Mab Eq (9) or from ∂fa/∂qb since both matrixes are similar [7]. All matrixes and vectors are computed using a piecewise reconstruction of the primitive variables, except for matrix Aab which is evaluated on the midpoint xi of the cell Ci.

It is important to note that in Eqs (8) and (13) the second term on the right hand side has an implicit sum over the repeated index a.

Note that, although it seems that the PVRS discretisation Eq (13) arises directly from discretising the hybrid quasilinear equation –which can be directly obtained by using the chain rule on Eq (1), it is impossible to obtain the PVRS discretisation shown in Eq (13) using a standard conservative FVM as presented in the appendix, and which satisfies the entropy and Rankine-Hugoniot jump conditions.

By using Eq (13) on a numerical code, it would no longer be a concern to recover the primitive variables from the computed conservative charges; they would instead be solved directly! Therefore, it would not be necessary to create a module in the code to obtain the final required solution u(x, t). In general terms, this procedure works out for any kind of conservative system in which q(u(x, t)) and f(u(x, t)) are at least given at some initial time.

The time step evolution of the Eq (13) that we use for our numerical simulations is given by the Method of Lines (MoL): (14) where L(u(xi)) is the right hand side of Eq (13) (see e.g. [9]), which can be further implemented with a Runge-Kutta integration.

4 Convergence test for PVRS in relativistic hydrodynamics

In this section we are going to show how this new method handles the evolution of a relativistic gas in a particular Riemann problem namely the shock tube (see e.g. [9]). This relativistic Sod [2] shock tube problem is a standard test that any code must fulfil for its validation. It has an exact analytical solution for both special relativistic and non-relativistic hydrodynamics and it is used for comparisons with numerical methods.

We calculated the numerical solution using PVRS discretisation Eq (13) with an approximate HLL Riemann solver, a minmod limiter for the reconstruction and a 4th order Runge-Kutta Method of Lines (MoL-RK4) for the integration. The problem was solved in the domain [0, 1] with N = 800 identical grid cells. We made three relativistic Sod tests with the initial discontinuity located at x = 0.5 and with initial states shown on Table 1. Furthermore, we compared the numerical results with the exact solution [9]. Also, we have estimated the usual L1-norm error for the following different resolutions: Δx1 = 1/200, Δx2 = 1/400, Δx3 = 1/800, Δx4 = 1/1600, Δx5 = 3200 and Δx6 = 1/6400.

thumbnail
Table 1. Initial parameters used for the relativistic Sod [2] shock tube tests described in the article.

κ stands for the polytropic index.

https://doi.org/10.1371/journal.pone.0195494.t001

The time-step condition used in this method is different from the commonly used by many authors (cf. [10]). A general CFL-condition applied to this numerical scheme was constructed by us and used in the set of examples presented. The exact condition and its derivation is a subject beyond the scope of this article and will be published elsewhere. For practical purposes, the time step interval can be chosen as a sufficiently smaller number than the corresponding CFL condition (cf. Eq (40)). For the examples presented below, we have chosen a fixed time step for each simulation.

4.0.1 Test 1: Weak relativistic blast wave

The first test corresponds to a lowly relativistic blast wave explosion. The results can be seen in Fig 1, where we compare the numerical solution (points) with the exact solution (lines). It is clear that for both, smooth parts and discontinuities, the numerical solution converges quite well to the exact one.

thumbnail
Fig 1. Test 1.

The figure shows the result of the simulation of a weak relativistic (Sod shock tube) blast wave explosion at t = 0.35 for the particle number density n, pressure p and velocity v. The time step used for the simulation was 0.001.

https://doi.org/10.1371/journal.pone.0195494.g001

4.0.2 Test 2: Mildly relativistic blast wave

The second test corresponds to a mildly relativistic blast wave explosion. The results can be seen in Fig 2, where we compare the numerical solution (points) with the exact one (lines). The importance of this test is to see if, with a relative high difference in pressure between both states, the numerical method is capable of solving the density function at the contact discontinuity.

thumbnail
Fig 2. Test 2.

The figure shows the result of a mildly relativistic (Sod shock tube) blast wave explosion at t = 0.35 for particle number density n, pressure p and velocity v. The time step used for the simulation was 0.001.

https://doi.org/10.1371/journal.pone.0195494.g002

4.0.3 Test 3: Strong relativistic blast wave

Finally, the last test corresponds to a strongly relativistic blast wave explosion. In this case, the density discontinuity is produced by a a 5 orders of magnitude difference between right and left initial detonation pressure, creating a thin shell which numerically is harder to resolve at low resolutions. However, with a relatively small number of cells and a weak variable reconstruction, the results shown on Fig 3 are as good as the ones obtained by other codes (cf. [10, 11]).

thumbnail
Fig 3. Test 3.

The figure shows the result of a strong relativistic (Sod shock tube) blast wave explosion at t = 0.35 for particle number density n, pressure p and velocity v. The time step used for the simulation was 0.0001.

https://doi.org/10.1371/journal.pone.0195494.g003

4.1 Error estimates

We have calculated the error of each test using the traditional L1—norm value. The convergence order of this test is given by log(errori/errori−1)/log(1/2), where errorj is the L1—norm of the Δxj resolution. As we can see from Table 2, the error decreases when the resolution increases, as expected. Also, we obtain first order convergence for all test in at least one resolution. Additionally, we made an experiment following [6] of a static Gaussian curve in order to estimate the order of convergence of a smooth static profile which, for this case, reaches a convergence value of about 2 in all the tested resolutions for a fixed time step of 0.01. As expected, this means that the important error of the relativistic Sod shock tube test relays on the discontinuities. This is the reason as to why we consider that taking the L1—norm is not a clear indicator of the “real” error at the shock waves, so we propose a more relevant useful visual interpretation of this estimation as follows.

thumbnail
Table 2. The L1-norm for the error in the numerical density for the minmod limiter with different numerical resolutions.

The L1-norm is computed for all shock-tube and Gaussian tests at time t = 0.35. We also show the order of convergence between different resolutions. Since the error decreases when the resolution increases, the PVRS constructed in the article is stable and converges to the exact solution. The data of this is presented in S1 File.

https://doi.org/10.1371/journal.pone.0195494.t002

In Fig 4 we show both exact (red dashed-line) and numerical (blue dashed-line) solution vs. the fluctuation |unumuexact|/uexact at each point (black line), for the density in Test 3 at every resolution. We can see how the Full Width at Half Maximum (FWHM) of the fluctuation tends to zero as the resolution increases. Working with the fluctuation of the numerical solution about the exact solution is a much better way to easily see the convergence of a numerical method, rather than the traditional L1-norm for which smoothing of the errors can be wrongly interpreted as a positive convergence test.

thumbnail
Fig 4. Comparison between the exact (red dashed-line) and the numerical solution (blue dashed-line) of the contact discontinuity in density for the Test 3 vs. the fluctuation |unumuexact|/uexact (black continuous line) at each point, for all the tested resolutions.

Note that as the resolution increases, the width of the fluctuation decreases, showing the convergence in a straightforward manner.

https://doi.org/10.1371/journal.pone.0195494.g004

5 Discussion

In this article we have developed a new numerical algorithm to solve any set of coupled differential conservative equations for which the primitive variable vector u is directly obtained. This is a forward step in numerical methods, since it avoids any intermediate step reconstruction of the primitive variable vector from a previously obtained charge vector q at all points or cells in space at each time. In principle, this means that numerical codes can be written in a more direct form. Also, depending on the nature of the physical problem to solve, the computational time may be reduced with this technique.

For practical purposes, we always had in mind special relativistic hydrodynamical problems and for this reason the specific techniques used throughout the article deal with hydrodynamical shock capturing schemes. We demonstrated in the article that the Primitive Variable Recovery Scheme (PVRS) showed good convergence for three shock-tube and one Gaussian tests. Further explorations in other directions, such as a non-static Gaussian test [12] need to be investigated. We will explore more details in future works.

The PVRS presented in this article can be implemented straightforward to any standard hydrodynamical code that already uses HLL Riemann solvers given by Eq (13).

In summary, the PVRS is a numerical maneuver to circumvent the embroiling construction of the primitive vector once the charge vector is obtained from any standard procedure used to solve a set of coupled conservative equations in physical systems.

We are constructing a GNU Public Licensed (GPL) free software (http://www.gnu.org) called “aztekas” (http://www.aztekas.org) that deals with relativistic hydrodynamics using this PVRS technique.

Appendix

Traditional approach for numerically solving conservative equations

In this appendix, we deal with traditional well known methods for solving conservative equations. Our intention is to briefly introduce the less versed reader to this topics using Einstein’s summation convention.

A system of m conservative equations in one dimension is usually written as: (15) where the subindex a takes values from 1 to m, qq(u(x, t)) is the vector of conservative charges and ff(q(u(x, t))) is the corresponding flux vector along the x axis at a given time t. The vector u corresponds to the primitive variables for which its number of entries and functional form of q(u) depends on the particular problem to solve. From this point onwards, we are going to use f(x, t) instead of the cumbersome notation f(q(u(x, t))), bearing in mind that both, charges and flux vectors, depend on the primitive variables u(x, t). As it is shown in section 1, the fluxes also have an explicit dependence on the primitive variables but are usually written in terms of the conservative charges.

We can rewrite Eq (15) in the quasilinear following form (16) where Jab is the Jacobian matrix of f(q). From now on, we use Einstein implicit sum convention over two repeated subindexes contained in the set {a, b, c, d}. If the Jacobian matrix satisfies the conditions of having real eigenvalues and a set of independent eigenvectors, then we say that the system Eq (15) is hyperbolic (see e.g. [8]).

In the linear cases (when f is a linear function of q), there exists an analytical solution for (15), but many physical cases give rise to nonlinear conservative systems which are required to be solved using numerical methods.

In the following subsections we briefly mention two of the main numerical methods used to solve 1D conservative systems such as the one written in Eq (15).

Finite differences approach

The finite differences method (FDM) is one of the most useful and simple numerical methods for solving ordinary and partial differential equations. It consists of an approximation of the derivatives of fluxes and charges based on approximations of their values on sufficiently small intervals of space and time. The space is divided in a grid of N centred points spaced by equal length Δx intervals in which the equation is evaluated.

Using Taylor expansions of the involved quantities, it is possible to work out the finite difference form of Eq (15) to find the value of q in all the grid at time t + Δttn+1 based on its value at ttn: (17) where xi is the i-th point on the grid. This is the Forward Time Central Space (FTCS) Euler method [8]. In Eq (17), the derivative ∂fa/∂x at a given time tn was written using a central approximation value given by (fa(xi+1) − fa(xi−1))/(2Δx). For the left and right boundary points this derivative can be written using a right or left derivative approximation given by: (fa(x1) − fa(x0))/Δx and (fa(xN−1) − fa(xN))/Δx respectively. Unfortunately, Eq (17) leads to numerical unstable solutions [13]. To overcome this problem, many higher order methods have been developed and successfully implemented over time [14].

When a second-order finite differences approximation method is used, additional source artificial viscosity terms appear in Eq (17). Those additional terms are either due to the second derivative approximation in Taylor series or to second differences approximation of the first derivatives (see e.g. [14]). The artificial viscosity name was given by von Neumann [13] since it resembles the viscosity term of the Navier-Stokes equation, but has nothing to do with any physical viscosity.

The general form of the artificial viscosity can be written as [14]: (18) where are the coefficients of second-order explicit artificial viscosity and . The choice simplifies the above equation to: (19) which is known as the Lax-Friedrich method. Other second-order-two-step methods, such as the Lax-Wendroff method, have been developed and successfully implemented in many numerical codes.

One such favourite two-step method was proposed by MacCormack [15]. It makes a forward-prediction of q and with it, a backward-correction: (20) (21) where . This method has been proved to be consistent, convergent and stable which is the requirement for any numerical method used in a computational code. Nevertheless, in discontinuities and regions with high pressure gradients, such as regions with shock-waves, this algorithm introduces a dispersive error called the Gibbs phenomenon, which consists on the presence of large spurious oscillations near the finite-jump, such as the example shown in Fig 5.

thumbnail
Fig 5. The graph shows the numerical solution of the advection equation: ∂t q + ∂x q = 0, using exclusively the MacCormack method.

The solution shows non-physical oscillations in a finite-jump discontinuity due to the Gibbs phenomenon. At later times, the oscillations grow breaking even more the expected solution. The graph was constructed using the initial conditions of q = 1.0 if x < 0.5 and q = 0.125 elsewhere at a fixed time t = 0.03.

https://doi.org/10.1371/journal.pone.0195494.g005

To solve this problem, it is common to apply a corrective diffusion in the regions where the non-physical oscillations appear. The correction presented by Book [16] is (22) where η is the antidiffusion coefficient at space-time points xi and tn: (23)

Finite volume approach

A more natural way of obtaining the discretisation form of (15) is the Finite Volume Method (FVM) which is based on a subdivision of the spatial domain into intervals (also called control volumes or grid cells) Ci ≔ [xi−1/2, xi+1/2]. The integration of Eq (15) over Ci between times tn and tn+1 yields: (24) The integral of ∂t q over time and the integral of ∂x f over space can be solved exactly and so, the next integral form of the previous equation is found: (25)

At this point, both integrals in the previous equation cannot be integrated unless we have the exact form of q, which is precisely the solution to the problem. In order to overcome this, we define each integration as a new numerical vector in the following form: (26) (27) where is the average charge vector of q over Ci at time tn and is the average flux vector across the boundaries of Ci. From now on, the square brackets notation [ ] around any numerical function is used to denote the corresponding (space or time) average related to that specific numerical function.

If q(u(x, t)) is a smooth function, then the integral Eq (26) agrees with the value of q at the midpoint of the interval to [8].

The indexes outside the square bracket do not denote the spatial and time evaluation of the average vector, they are just labels that refer to the time and grid positions of the corresponding numerical values.

Substituting the definitions Eqs (26) and (27) in Eq (25) we obtain the main discretisation for the finite volume scheme usually presented in the literature (cf. [8]): (28)

Eq (28) is a numerical recipe of how to compute the mean value using the average flux and charge values one time-step backwards for each grid cell Ci. This discretisation has the same exact form as Eq (15) except for the choice of the values Eqs (26) and (27).

The advantage of this method over any finite difference scheme is that the conservative nature of the system is preserved, even across strong discontinuities such as shock waves. This is the reason as to why a finite volume scheme is often used when dealing with the physics of high energy flows where discontinuities may appear.

Numerical flux

The flux f at Eq (27) depends on the value of q at every time. This is why it is impossible to integrate the average flux. Somehow, we have to find a good approximation for this integral. Moreover, the flux f inside the integral is evaluated on the boundaries xi±1/2 of the grid cell which, numerically speaking, has no sense because we can only approximate the values of the average charges on the midpoint of the finite volume. This set of midpoints can be “safely” considered the ones used in the finite difference mesh mentioned in the Finite differences approach section.

One way to approximate is to assume that it can be obtained as a function of the cell average values of q on either side of the interface xi±1/2, i.e., and : (29) The previous result is expected since in a hyperbolic problem the information of how q change on every cell propagates at a finite characteristic speed (see e.g. [3, 14]). The function can be thought as a numerical flux function for which its functional form will depend on the problem or the particular numerical scheme used to solve it.

Substitution of Eq (29) into Eq (28) yields: (30) The numerical flux function is then determined by the evolution of the solution in each interface. A good first guess for the function is to relate it to the corresponding average flux function of a local (for each cell) Riemann problem [9] with two constant states on each side of the boundary.

In order to obtain an accurate numerical flux function, is important to study the behaviour of the solution based on the form and properties of the governing equation at these particular initial conditions.

Riemann problem

Let us now consider a single conservative equation (i.e. Eq (15) with a = 1 only) in which the flux is written as where is a constant value: (31) This is the advection equation in which corresponds to the propagation velocity of q. Note that, since , Eq (31) is also its own quasilinear version.

The function satisfies Eq (31) for any function . However, it is more useful for us to describe the problem observing the behaviour of the solution q along characteristic curves in the tx plane. To do so, we perform the time derivative of q(X(t), t) and equate the result to zero, i.e.: (32) Direct comparison of the above equation with Eq (31), means that that the solution q(X(t), t) is constant all along the ray , where x0 is some initial value. In the most general case, the set of all rays X(t) are called the characteristics of the equation.

If we consider the particular case in which the initial conditions of the problem consists on two constant states (33) where ql and qr are the left and right states respectively, the characteristics X(t) of (31) are then rays with slope in the tx plane. With this, the solution can be written as (34)

Let us consider now a system of m conservative equations (i.e. a = 1, 2, …, m in Eq (15)), where fa = Aabqb, i.e.: (35) where Aab is a constant m × m matrix and so, the system of conservative equations is linear. If Aab is diagonalisable such that: (36) where Rac is the matrix of eigenvectors, with the p-th eigenvector, its inverse and , for λp the p-th eigenvalue. If we define the characteristic variables wa as (37) it is then possible to rewrite Eq (35) as the following system of m advective equations: (38) In the case of the Riemann problem, the solution for the p-th advective equation is , and the solution qa(x, t) is obtained using the definition of wa: (39)

In this way one can think that qa is a superposition of m waves moving with characteristic velocities λ1, λ2, … and λm, respectively [14].

Another way to see this is by comparing Eq (35) with the time derivative of q(X(t), t) in (32). From this, it follows that the characteristics are curves for which their corresponding slopes are exactly the eigenvalues of the matrix Aab.

In order to obtain a real contribution of one of these waves to the evolution of a contiguous grid cell, the size of the control volume must be larger than the distance travelled by the wave, moving at its characteristic velocity, at a certain fixed time Δt, i.e., (40) The quantity λΔtx is know as the Courant number and the fulfilment of Eq (40) is called Courant-Friedrich-Levy (CFL) condition. This is a convergence requirement for several numerical methods that solve conservative equations.

The Riemann problem discussed in this subsection, is used to accurately estimate the value of the numerical fluxes at the boundaries of two contiguous grid cells as will be seen in the following section.

Godunov scheme

Godunov in 1959 [17] proposed a numerical scheme for solving conservative equations and this method can be used in terms of the Riemann problem as follows. Consider the single Eq (31). The algorithm proposed by Godunov has the following recipe:

  1. Compute the average values of the charges q at the time t = tn using Eq (26) for a = 1 only: (41)
  2. Reconstruct from a polynomial function for every value of x. The simplest case for this is to take a constant function: (42) In practice [18], the value is consider to be q evaluated at the midpoint of the grid cell.
  3. Evolve the hyperbolic equation in an exact or approximate way by a time Δt to obtain .
  4. Take the average of over Ci to obtain .
  5. Go back to the first item on the list and iterate until a final time is reached.

As we discuss above, it is impossible to compute exactly the average flux because we do not know the value of q at all times. However, if we consider a Riemann problem in the interface xi±1/2 between the grid cells Ci and Ci±1 and apply step 3 of Godunov’s algorithm, we get that is constant along the curves that satisfies (xxi±1/2)/t = const.

In summary, if we denote by the solution to the Riemann problem at xi±1/2, the computation of the average fluxes reduces on computing an integral over a constant function [8]. In this way, the Godunov’s algorithm can be expressed in terms of average fluxes using the following recipe:

  1. Solve the Riemann problem in the interfaces xi±1/2 of the Ci grid cell in order to obtain .
  2. Define .
  3. Apply discretisation Eq (30).

The problem with applying Godunov’s scheme on non-linear systems and considering wave propagation of characteristic waves on all interfaces, is that the characteristic velocities are not constant at all times and also they change values at different grid cells. For the case of a quasilinear system such as the one of Eq (16), an approximation has to be made. Many methods for obtaining an approximate Riemann solution have been developed and successfully implemented in classical and relativistic magnetohydrodynamic codes (see e.g. [11, 19]).

HLL Riemann solver

One of the most popular approximate Riemann solvers is the called HLL solver [20]. This Godunov’s base method considers a Riemann problem with constant states qL and qR on each side of the interface in a space-time grid cell [xL, xR] × [0, T] as shown on Fig 6.

thumbnail
Fig 6. Space-time grid cell [xL, xR] × [0, T].

The figure shows the evolution of the 1D conservative equation solution along rays with slope λL and λR, together with the intermediate state qHLL generated by the HLL solver.

https://doi.org/10.1371/journal.pone.0195494.g006

Instead of following the solution of all the characteristic variables along their own characteristic velocities, the idea of the HLL approximation consists on considering the larger eigenvalues λR and λL moving across the interface to the right and left respectively. The region delimited by these characteristic rays is denoted by the state qHLL.

Note that, since we are working with a system of m conservative equations, 2m characteristic rays will emerge from each interface. The values λL and λR are to be chosen taking into account all 2m characteristic velocities.

The approximate solution to the Riemann problem derived by this scheme has the following form (see e.g. [8] or [21]): (43) where (44) where fR,Lf(qR,L). One can work out the approximate solution to the flux through the interface by integrating the hyperbolic equation over the space-time domain outlined in Fig 6 and using the Rankine-Hugoniot jump condition at each characteristic ray (λR,L). The final result is that [21]: (45) Notice that fHLLf(qHLL). The flux Eq (45) can be used along with the Godunov scheme to solve the local Riemann problem of to contiguous grid cells.

Let us now consider the boundary xi−1/2 between two control volumes Ci and Ci−1 and suppose that a constant reconstruction from the average values of q has been made. With this, let and to be the reconstruction points that lay at the interface xi−1/2. Note that these values are going to be different if a polynomial reconstruction is made. With this, we can write the numerical flux at xi−1/2 used in the Godunov scheme in the following form: (46) The flux through xi+1/2 is obtained in an analogous way. So, by substituting these numerical fluxes in the discretisation Eq (30), we finally get the numerical solution for the hyperbolic Eq (15) in the finite volume scheme using Godunov’s algorithm with a high resolution [22] approximate Riemann HLL solver: (47) A simple way of computing is by considering that this average value match the magnitude of q evaluated at the midpoint of the grid cell xi. If q(x, t) is smooth, the error introduced by this approximation is of order [8]. In other words: (48)

Many other HLL-type Riemann solvers have been developed (cf. [21]) and successfully implemented (cf. [19]) but they are beyond the scope of the present article.

Limiters

At first approximation, the reconstruction of q over the grid cell was made considering a constant value which is taken as the midpoint value of q of the corresponding control volume Ci. A better way of improving the precision of the above procedure is by considering a piecewise polynomial approximation for this variable.

In the linear case, the reconstruction of q over Ci is given by (49) where is the slope of the linear reconstruction. To use the limiters together with a HLL-type Riemann solver, all we need to consider are those points of in each contiguous grid cells, evaluated at the interfaces xi±1/2. In this respect, it is not important to do a complete reconstruction of q. The knowledge of q at the boundaries is sufficient for this approximation, and so the values required to effectively evolve the solution of the hyperbolic equation over the grid cell Ci are: (50) (51) (52) (53) Each pair Eqs (50 and 51) and Eqs (52 and 53), constitute a Riemann problem to be solved at the interface xi−1/2 and xi+1/2, respectively. The polynomial reconstruction are useful to accurate capture discontinuities such as shock-waves. Eqs (50)–(53) are also valid for each component of the vector q when a coupled system of conservative equations is required.

The usual way of computing σ is by considering some useful function based on finite derivatives of q over Ci. The most used but dissipative reconstruction (also called limiter [8]) is the minmod limiter (MM) introduced in [23]: (54) where the function mi±1/2 is the average slope (or the finite derivative) of q centred at xi±1/2: (55) (56) The minmod function of two values a and b stands for: (57)

This limiter has been successfully implemented in the case of relativistic hydrodynamics (cf. [11, 18]).

The monotonic centred limiter MC, proposed by van Leer [24], has less dissipation than minmod near discontinuities, but has been proved to create spurious oscillations in the strong shock cases [11]. Nevertheless, it produces relatively well damped solutions that capture not too strong shock waves. The slope σ is written as in Eq (54) but the MC function has the following form: (58) where c ≔ (a + b)/2.

Another piecewise linear reconstruction is the superbee limiter, also proposed by Roe in 1986 [23]. This one has a better shock-wave capture than the previous scheme as shown in Fig 7, where comparisons of the superbee limiter with the previous ones and with the piecewise constant reconstruction (godunov) is made. For this slope, the function is slightly more complicated than the previous ones and is given by: (59) where (60) (61) and (62)

thumbnail
Fig 7. Comparison between the piecewise linear reconstructions (minmod, MC and superbee) with the piecewise constant one (godunov).

As the complexity of the algorithm grows the shock capture is better, as it is shown in the figure by the superbee simulation. The graph shows the quantity q corresponding to the pressure as a function of the position at a fixed time t = 0.35 for a particular Riemann problem in a relativistic Sod shock tube that evolves from the initial value t = 0 in such a way that, at this time, p = 1.69 for x <0.77 and p = 0.1 for x ≥ 0.77.

https://doi.org/10.1371/journal.pone.0195494.g007

Colella in 1984 [25] developed a piecewise parabolic reconstruction (PPM), that have been successfully used by many authors in both relativistic [11] and non-relativistic hydrodynamics (cf. [26]) but for the purposes of this paper, it will not be considered.

Supporting information

S1 File. Numerical vs. exact data.

In the file “S1_File.tar.gz”, we attached the relevant data of the comparison between numerical simulations and exact solutions used to obtain the L1—norm.

https://doi.org/10.1371/journal.pone.0195494.s001

(GZ)

Acknowledgments

This work was supported by Direccion General de Asuntos del Personal Academico—Universidad Nacional Autonoma de Mexico (DGAPA-UNAM project number IN112616, http://dgapa.unam.mx) and Consejo Nacional de Ciencia y Tecnologia (CONACyT project ID:CB-2014-1 #240512 http://www.conacyt.gob.mx). AAO, SM and DO acknowledge economic support from CONACyT (788898, 26344, 255602). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

References

  1. 1. Riccardi G, Durante D. Primitive Variable Recovering in Special Relativistic Hydrodynamics Allowing Ultra-Relativistic Flows. International Mathematical Forum. 2008;42:2081–2111.
  2. 2. Sod GA. A survey of several finite difference methods for systems of nonlinear hyperbolic conservation laws. Journal of Computational Physics. 1978 Apr;27:1–31.
  3. 3. Landau LD & Lifshitz EM. Fluid Mechanics. vol. 6 of Course of Theoretical Physics. 2nd ed. London: Pergamon Books.; 1987.
  4. 4. Weinberg S. Gravitation and Cosmology: Principles and Applications of the General Theory of Relativity; 1972.
  5. 5. Tooper RF. Adiabatic Fluid Spheres in General Relat ivity. Astrophysical Journal. 1965 June;142:1541–1562.
  6. 6. Yousaf M, Ghaffar T, Qamar S. Application of Central Upwind Scheme for Solving Special Relativistic Hydrodynamci Equations. Plos One. 2015 Jun;.
  7. 7. Font JA, Ibanez JM, Marquina A, Marti JM. Multidimensional relativistic hydrodynamics: Characteristic fields and modern high-resolution shock-capturing schemes. Astronomy and Astrophysics. 1994 Feb;282:304–314.
  8. 8. LeVeque RJ. Finite-Volume Method for Hyperbolic Problems. Cambridge University Press; 2002.
  9. 9. Lora-Clavijo FD, Cruz-Pérez JP, F S, González JA. Exact solution of the 1D Riemann Problem in Newtonian and Relativistic Hydrodynamics. Revista Mexicana de Física. 2013 January-June;59:28–50.
  10. 10. Del Zanna L, Bucciantini N. An efficient shock-capturing central-type scheme for multidimensional relativistic flows. I. Hydrodynamics. Astronomy and Astrophysics. 2002 Aug;390:1177–1186.
  11. 11. Lora-Clavijo FD, Cruz-Osorio A, Guzmán FS. CAFE: A New Relativistic MHD Code. ApJS. 2015 Jun;218:24.
  12. 12. Radice D, Rezzolla L. THC: a new high-order finite-difference high-resolution shock-capturing code for special-relativistic hydrodynamics. å. 2012;547:A26. Available from: https://doi.org/10.1051/0004-6361/201219735.
  13. 13. von Neumann J, Richtmyer RD. A Method for the Numerical Calculation of Hyd rodynamic Shocks. Journal of Applied Physics. 1950 Mar;21:232–237.
  14. 14. Laney CB. Computational Gasdynamics. Cambridge University Press; 1998. Available from: https://books.google.com.mx/books?id=r-bYw-JjKGAC.
  15. 15. MacCormack RW, Paullay AJ. Computational efficienciy achieved by time splitting of finite differences operators. American Institute of Aeronautics and Astronautics AIAA. 1972;.
  16. 16. Book DL, Boris JP, Hain K. Flux-Corrected Transport. II—Generalizations of the method. Journal of Computational Physicis. 1975;18:248–283.
  17. 17. Godunov SK. A Difference Scheme for Numerical Solution of Discontinuos Solution of Hydrodynamic Equation. vol. 47. Mat. Sb. (N.S.); 1959.
  18. 18. Rezzolla Lea. Relativistic Hydrodynamics. Oxford University Press; 2013.
  19. 19. Miyoshi T, Kusano K. A multi-state HLL approximate Riemann solver for ideal magnetohydrodynaics. Journal of Computational Physics. 2005 Apr;208:315–344.
  20. 20. Harten A, Lax PD, Leer B. On Upstream Differencing and Godunov-Type Conservation Laws. SIAM Review. 1983 04;25. Available from: http://gen.lib.rus.ec/scimag/index.php?s=10.2307/2030019.
  21. 21. Toro EF. Riemann Solvers and Numerical Methods for Fluid Dynamics. Springer; 2009.
  22. 22. Martí José María, Müller E. Numerical Hydrodynamics in Special Relativity. Living Reviews in Relativity. 2003;6(7). Available from: http://relativity.livingreviews.org/Articles/lrr-2003-7/. pmid:28179862
  23. 23. Roe PL. Characteristic-based schemes for the Euler equations. Annual Review of Fluid Mechanics. 1986;18:337–365.
  24. 24. van Leer B. Towards the ultimate conservative difference scheme. III—Upstream-centered finite-difference schemes for ideal compressible flow. IV—A new approach to numerical convection. Journal of Computational Physics. 1977 Mar;23:263–299.
  25. 25. Colella P, Woodward PR. The Piecewise Parabolic Method (PPM) for Gas Dynamical Simulations. Journal of Computational Physicis. 1975;54:174–201.
  26. 26. St-Cyr A, Jablonowski C, Dennis JM, Tufo HM, Thomas SJ. A Comparison of Two Shallow-Water Models with Nonconforming Adaptive Grids. Monthly Weather Review. 2008;136:1898.