Systematic Testing of Explicit Positivity Preserving Algorithms For The Heat-Equation
Systematic Testing of Explicit Positivity Preserving Algorithms For The Heat-Equation
Systematic Testing of Explicit Positivity Preserving Algorithms For The Heat-Equation
org
https://doi.org/10.28919/jmcs/7407
ISSN: 1927-5307
Copyright © 2022 the author(s). This is an open access article distributed under the Creative Commons Attribution License, which permits
unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
Abstract: In this work, we performed systematic tests of recently invented stable and explicit algorithms which
preserve the positivity of the solution for the linear heat equation. It is well known that the widely used explicit finite
difference schemes are typically unstable if the time step size is below the so called CFL limit, and even if they are
stable, they can produce negative temperatures. However, the numerical solutions should satisfy the same properties
as the exact solution, such as positivity. Thus, we collected the available explicit positivity preserving methods, most
of them created by us recently to examine their performance and relative competitiveness. We tested them in the case
of several 2D systems to find how the errors depend on the stiffness ratio and the CFL limit of the system for each
algorithm. Then we created an anisotropic but equidistant grid by shrinking the vertical dimension of the 2D system
Keywords: heat equation; diffusion equation, positivity preserving methods; stiff systems; unconditional stability;
hopscotch methods.
*
Corresponding author
E-mail address: fizendre@uni-misksolc.hu
Received April 02, 2022
1
2
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
1. INTRODUCTION
In recent years our group develops novel numerical methods for parabolic partial differential
equations (PDEs), most importantly the heat conduction or diffusion equation and similar
diffusion-reaction equation. In a homogeneous space, the diffusion equation has analytical
solutions, old and new ones as well, [1], but when the material properties are functions of space,
numerical integration is necessary. We are aware that many new and efficient methods are
proposed and tested recently as well, [2]–[7], but here we are investigating the so-called positivity
preserving methods. It is well known that the true solution of the heat or diffusion equation always
follows the maximum and minimum principles [8] (p. 87). We know that these principles typically
do not hold if there is a source term in the diffusion equation, either if it is constant, or if it is
nonlinear, such as in the case of the Fisher and Huxley equations. But even in the latter cases, if
the source term is necessarily positive, the dependent variable (e.g., the concentration) cannot be
negative. It is important [9], [10] to have numerical schemes that preserve the positivity of the
solution, because the quantities that are being modelled, concentrations of chemical species,
populations sizes or number of neutrons, etc. are positive. Standard finite difference or finite
element discretization does not explicitly incorporate the condition that the solutions be positive.
So even though these algorithms usually yield positive values, due to truncation or other errors
their solutions may become negative and non-physical. Then the solutions will usually start
oscillating leading to numerical instabilities. That is why unconditionally positive schemes are
investigated by some scholars [9]–[13]. We note that numerical methods that include the positivity
of solutions have been used for ordinary differential equations, [14], [15] as well.
This work can be considered a continuation of our previous papers, [16]–[25], in which we
developed novel numerical algorithms to solve the heat or diffusion equation. In our case,
maximum and minimum principles hold, thus we say a method is positivity preserving if it never
violates this principle. It means that we use this term in a stricter sense than most of the literature.
In this paper we perform systematic tests for systems by gradually changing some parameters of
the grid to examine how the performance of the individual methods changes and which of them is
3
EXPLICIT POSITIVITY PRESERVING ALGORITHMS FOR THE HEAT-EQUATION
Eq. (1) can be used if the medium where the diffusion takes place is homogeneous. Otherwise, one
can use a more general form:
u
c = ( k u ) , (2)
t
conductivity, specific heat and mass density, respectively. These quantities cannot be negative and
the = k / (c ) relation connects the four quantities. We consider the initial function u ( t = 0 ) as
given, while the boundary conditions will be specified when we present the concrete examples.
Eq. (1) is usually spatially discretized in one dimension by applying the well-known central
difference formula for obtain a system of ordinary differential equations (ODEs) for nodes
i = 1,...,N − 2 :
du i u − 2u i + u i+1
= i-1 (3)
dt x 2
In this paper, we don’t exactly follow this formalism as explained in the following. We examine 2
The space step size (dimensions of the cells) in the horizontal and vertical directions is denoted by
xi , i = 1,...,N and zk , k = 1,...,N , respectively. The mesh is general in the sense that these
quantities are not necessarily equal, i.e., xi xi +1 zk can happen. Moreover, the k, c, and ρ
quantities, which represent the material properties, can be functions of the space variables. Now
4
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
we give briefly the essential elements of the generalization procedure which is explained in more
details in our previous papers, Kovács et al., [18], [22], [26] (which is based on the appropriate
literature, e.g. Chapter 5 of the book, M. Munka and J. Pápay [27]). The (2-dimensional) volume
of the cell can be given as Vi = xi zi , and with this the heat capacity of the cells can be calculated
as Ci = ci iVi , while the thermal resistance between the cells in the x and z direction is
xi zi
Rxi,i +1 and Rzi, Nx +i , provided that the cell has a right and lower neighbor,
ki,i +1zi ki, Nx +i xi
Figure 1. Arrangement of the generalized variables for the case when the mesh is not necessarily regular.
The red double arrow is for conduction between cells with neighboring capacities indexed with number 3
Now the spatially discretized form of Eq. (2) can be written as follows:
du i u j −ui
= , (4)
dt j R ijC i
where the summation is going over all neighbors of the cell i, i.e., j i − 1, i + 1, i − N x , i + N x
for an inner cell. Eq. (4) is the generalization of Eq. (3) in the sense that if the definition of the
volume, capacity and resistance is substituted back to (4) in the case of an equidistant 1D mesh,
we obtain (3).
Equation systems (3) and (4) can be written into a matrix-form:
5
EXPLICIT POSITIVITY PRESERVING ALGORITHMS FOR THE HEAT-EQUATION
du
= Mu (5)
dt
In the one-dimensional case of Eq. (3), the matrix M is tridiagonal with the following elements:
2
m ii = − (1 i N ), m i,i+1 = (1 i N ), m i,i −1 = (1 i N ) (6-a)
x 2
x 2 x 2
In the general case of Eq. (4), the nonzero elements of the matrix can be given as:
1
m ij = , m ii = − m ij (6-b)
R i, jC i ji
The characteristic time or time constant τi of cell i can be introduced, which is always a non-negative
quantity:
−1
i − ( m ii ) (7)
The time variable is discretized by setting time levels according to the standard rules:
h u jn
ri = and Ai = h m iju jn = h (8)
i ji ji C i R ij
h
The quantity ri is similar to the standard mesh ratio r = , while the Ai collects the effect coming
x 2
from the neighbors of the cell i.
uin +1 =
(
uin + r uin−1 + uin+1 ) , (9)
1 + 2r
and the general form for Eq. (2) is:
6
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
uin + Ai
uin +1 = (10)
1 + 2ri
We emphasize that this method was not invented by us but other scholars, while all the upcoming
8 methods are our constructions.
The second formula we use is the constant neighbor (CNe) method, which is introduced and tested
in our papers, Kovács et al., [17], [18]. In the simplest case of Eq. (1),
uin−1 + uin+1
uin+1 = uin e− 2r +
2
(
1 − e− 2r ) (11)
u in +1 = u in e
− ri
+
Ai
ri
( −r
1−e i ) (12)
The third and fourth methods we use are the 2 and 3 stage linear-neighbor (LNe and LNe3)
methods, which are introduced in our paper, Kovács [18]. They are based on the CNe method,
which is used as a predictor to calculate new uiCNe values valid at the end of the actual time step.
u CNe
Using them we can recalculate Ainew = h
j
, with which we can make the corrector step for
j i C i R ij
The values given in (13) can be used to recalculate again Ainew which makes sense to repeat (13)
to obtain even more accurate results, which is called three-stage LNe3 method. We mention that
this iteration can be repeated even more times to obtain LNe4, etc. methods, but as we showed in
our paper, Kovács [18], usually these don’t significantly improve the accuracy.
The fifth method we examine is the two-stage Constant-neighbor (briefly: CpC) algorithm which
is introduced in our paper, Kovács et al., [25]. This generally starts with a fractional time step with
length ph, but here we take p = 1 , because it is the simplest and usually the most accurate choice.
2
7
EXPLICIT POSITIVITY PRESERVING ALGORITHMS FOR THE HEAT-EQUATION
So, at the first stage, we can calculate new predictor values of the variables, but with a h1 = h / 2
time step:
uiCp = uin e− ri /2 +
Ai
ri
(
1 − e− ri /2 . ) (14)
u Cp
= h
j
Ainew , (15)
ji Ci Rij
and take a full-time step size corrector step. Thus, the final values at the end of the time step are
u in +1 = u in e
− ri
+
ri
(
Ainew −r
1−e i ) (17)
Now let us turn the attention to the hopscotch-type methods. First, we recall the original OEH
method, where we need to construct a bipartite grid, in which the set of nodes (or cells) is divided
into two similar subsets, the odd and even nodes, such that all nearest neighbors of even nodes are
odd nodes and vice versa, like on a checkerboard. We treat the odd nodes in the first stage in odd
time steps, and only the u values belonging to the beginning of the time step are used. Then, in the
second stage, the new values of odd neighbors, which have just been calculated, are used, when
the values of their even neighbors are calculated. The roles of the nodes are interchanged when
even time steps start, as shown in Figure (2-a).
The original OEH method applies the standard explicit Euler formula in the first stage and the
implicit Euler formula in the second stage. This is a powerful explicit method which is
unconditionally stable for the heat equation, but it is far from being positivity preserving. In fact,
as we have shown in, Kovács et al., [21], the deviation from the true values can be very large in case
of stiff systems. Therefore, we substitute all the formulas by the CNe scheme (12) to obtain our
sixth method denoted by OEH-CNe.
For the seventh method, we modify the time and space structures of the original OEH method to
construct the so called shifted-hopscotch method, Kovács et al., [22], as follows. The calculation
starts with taking a half-sized time step for the odd nodes which is symbolized by a light green box
8
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
containing the number 0 in Figure (2-b). Then, a full-time step is taken for the even nodes, then
for the odd nodes and for the even nodes again. Finally, a half-size time step closes the calculation
of the values. We use the latest available u values of the neighbors in each stage, so that the method
is fully explicit and the previous values do not need to be stored at all. We have a structure
consisting of five stages, which correspond to five partial time steps, which altogether spanned
two-time steps for odd and even cells, too. In Figure (2-b), the number "0" means that this stage is
implemented only once and is not repeated. Also, T must be an even integer because the stages 1–
4 are repeated T/2 times (including the last, halved stage 4). So, finally, we have five different
stages from 0 to 4.
Whereas in the case of the new leapfrog-hopscotch method, the calculation starts with taking a
half-sized time step for the odd nodes using the initial values, Kovács et al., [23]. Then, for the even
and odd nodes, full-time steps are taken strictly alternately until the end of the last timestep (dark
green box in Figure 2-c), which should also be halved for odd nodes to reach exactly the same time
point as the even nodes.
The last of our method is called asymmetric hopscotch (ASH), Fig. (2-d), similar to what was
published in a previous paper, Kovács et al., [24]. This method uses only three stages instead of
four. It means that the calculation starts with taking a half-sized time step for the odd nodes and
full-time step for the even nodes, finally, a half-size time step closed the calculation of the values.
Figure 2. The stencil of the odd-even hopscotch structures for two nodes. (a) The OEH. (b) The
shifted-hopscotch. (c) The leapfrog-hopscotch. (d) The asymmetric hopscotch.
9
EXPLICIT POSITIVITY PRESERVING ALGORITHMS FOR THE HEAT-EQUATION
Here it should be noted that we used only CNe formula with all stages in these structures because
in previous papers, Kovács et al., [22], [23] we showed that among the positivity preserving
combinations the full CNe was the best. In the case of halved time steps, the quantities ri and Ai
must be divided by 2.
As one can see in Figure 2, in case of the SH method, there were five-time steps (five stages)
altogether, instead of four, while in the case of the ASH scheme, there were 3-time steps instead
of two. Therefore, for the sake of correctness, we used the effective time step size as hEFF = 4 5 h
and hEFF = 2 3 h for the SH and the ASH method, respectively, when the errors were plotted as a
value of uin+1 is the convex combination of the old values u nj , thus all of these methods are
FTCS
due to instability. This hMAX threshold time step size is frequently called the CFL limit and valid
for the second order explicit Runge-Kutta (RK) methods as well. We stress again that this
restriction is absolutely not valid for the methods presented here, but these two numbers give
information about the difficulty level of the problem.
10
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
In the first type of our experiments, randomly generated cell capacities and thermal resistances
following a log-uniform distribution
C i = 10(C − C rand ) , R x,i = 10( Rx − Rx rand ) , R z,i = 10( Rz − Rz rand )
of the mesh-cells data have been chosen to construct test problems with various stiffness ratios.
More concretely, we used the parameters shown in Table 1.
Table 1 The parameters used in algorithms
The size of the grid is fixed to N x = 50 and N z = 50 , thus the total cell number is 2500, while
num
The numerical error is calculated by comparing our numerical solutions u j produced by the
ref
examined method with the reference solution u j at final time tfin .The reference solution is given
by the “ode15s” routine of MATLAB with large prescribed accuracy. We use the following three
types of (global) error. The first one is the maximum of the absolute differences:
1
Error(L1 ) =
N
u jref (t fin ) − u jnum (t fin ) . (19)
0 j N
11
EXPLICIT POSITIVITY PRESERVING ALGORITHMS FOR THE HEAT-EQUATION
We call the third one energy error, because it gives the error in terms of energy in case of the heat
equation:
For different algorithms these errors depend on the time step size (and the system parameters)
in different ways. Thus, we first calculated the solution with a large time step size (which was
tfin / 4 ), then repeated the calculation for subsequently halved time step sizes S=15 times until h
reached a small value. Now the aggregated relative error (ARE) quantities for each type of errors
defined above are calculated as an average of these errors. For example, in the case of the L error,
1 S
ARE( L ) = log ( Error( L ) )
S i =1
(21)
Finally, the simple average of the three kinds of errors also can calculated:
1
ARE = ( ARE(L ) + ARE(L1 ) + ARE(Energy ) ) (22)
3
4.2. Comparison between positivity preserving methods for a mildly stiff system
First, we examined the following concrete parameter-combination,
We have plotted the L errors as a function of the effective time step size hEFF and as a function
of the running times for all methods. In Figure 3 we present the L error as a function of the
effective time step size hEFF for the nine positivity preserving methods defined in Section 3,
while in Figure 4 one can see the L errors vs. the total running times.
One can see the LNe3 scheme is the most accurate, but the accuracy of the LH-CNe as well as
the SH-CNe and ASH-CNe methods approach it. However, since the LNe3 is a three-stage method,
it is slightly slower for the same accuracy than the LH-CNe, SH-CNe and ASH-CNe.
12
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
Figure 3. The L errors as a function of the effective time step size ( hEFF ) for the (Mildly Stiff) system,
in the case of the UPFD, CNe, CpC, LNe2, LNe3, the OEH-CNe, the SH-CNe, the LH-CNe and the ASH-
CNe methods.
Figure 4. The L errors as a function of the running times for the (mildly stiff) system, in the case of the
UPFD, CNe, CpC, LNe2, LNe3, the OEH-CNe, the SH-CNe, the LH-CNe and the ASH-CNe methods.
13
EXPLICIT POSITIVITY PRESERVING ALGORITHMS FOR THE HEAT-EQUATION
4.3. Comparison between positivity preserving methods for a large, very stiff
system
We put new values for the α and β parameters for the very stiff system in the second case study:
In Figures 5 and 6, the L error is presented as a function of the effective time step size hEFF
Figure 5. The L errors as a function of the effective time step size ( heff ) for the (very Stiff) system, in
the case of the UPFD, CNe, CpC, LNe2, LNe3, the OEH-CNe, the SH-CNe, the LH-CNe and the ASH-
CNe methods.
14
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
Figure 6. The L errors as a function of the running times for the (very Stiff) system, in the case of the
UPFD, CNe, CpC, LNe2, LNe3, the OEH-CNe, the SH-CNe, the LH-CNe and the ASH-CNe methods.
Table 2. Comparison the UPFD, CNe, CpC, LNe2, LNe3, the OEH-CNe, the SH-CNe, the LH-CNe and
the ASH-CNe methods for the very stiff system of 2500 cells.
Numerical Method Error( L ) Error( L1 ) Energy Error Running Time (sec)
Figure 7. The (ARE) errors as a function of hMAX in the case of the UPFD, CNe, CpC, LNe2, LNe3, the
Figure 8. The (ARE) errors as a function of Stiff Ratio in the case of the UPFD, CNe, CpC, LNe2, LNe3,
the OEH-CNe, the SH-CNe, the LH-CNe and the ASH-CNe methods.
We summarize the ARE error quantities, defined in Equation (22), for both case studies in the
following table:
Table 3. ARE (average relative error) quantities of different explicit stable algorithms.
Numerical Method ARE (Mildly Stiff) ARE (Very Stiff)
where the wave number k is currently fixed to k =1. The simplest zero Dirichlet boundary
conditions are used
u ( x = 0, z, t ) = u ( x = 1, z, t ) = u ( x, z = 0, t ) = u( x, z = 1, t ) = 0 ,
u( x, t ) = sin( x)sin(k z ) e
( )
− 1+ k 2 2t
. (24)
We apply an equidistant grid to discretize the space variables first we take x = 0.02 ,
z = 0.02 .
The number of cells along the axis x and z are set again to N x = 50 and N z = 50 . Thus, we have a
Then we performed systematic experiments by decreasing the dimension of the system as well
as the cells in the z direction to introduce anisotropy into the grid. It means z is subsequently
decreased by a factor of 2, first to ∆𝑧 = 0.5, then to ∆𝑧 = 0.25 , etc. It is convenient to introduce
the following anisotropy coefficient:
x
AC = .
z
Then we examined the aggregated errors as a function of this anisotropy coefficient AC. Of course,
the initial condition function in (23) and the exact solution must be also adjusted with recalculating
the wave number k = 2 AC −1 . In Figure 9, ARE errors are presented as a function of the anisotropy
coefficient AC. We note the relative advantage of LNe3 method increased whereas relative
disadvantage of other methods is also increased. In Table 4, we give hMAX and the stiffness ratio
for some AC values.
18
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
Figure 9. The (ARE) errors as a function of anisotropy coefficient AC in the case of the UPFD, CNe, CpC,
LNe2, LNe3, the OEH-CNe, the SH-CNe, the LH-CNe and the ASH-CNe methods.
method produced the most accurate results for a given time step size, but the LH-CNe method (and
sometimes the SH-CNe method) requires the least CPU time to reach any prescribed accuracy. The
increasing stiffness ratio and the decreasing CFL limit decreased the accuracy of methods, and the
advantage of the best methods compared to the worst are decreased.
We also examined the performance of the method for different levels of spatial anisotropy. We
obtained that if the difference between the horizontal and vertical dimensions of the cells are
increasing, the advantage of the LNe3 method and the disadvantage of the first order methods are
increasing.
We can conclude that if there is a possibility to construct the OEH structure (because the mesh is
rectangular) than the hopscotch-CNe methods, especially the LH-CNe is the most effective among
the positivity preserving methods, except when the anisotropy is strong. However, if an
unstructured mesh is given, the LNe3 method is the most effective. For a very anisotropic system,
for example a thin and wide layer, we also propose the LNe3 method.
CONFLICT OF INTERESTS
The author(s) declare that there is no conflict of interests.
REFERENCES
[1] I.F. Barna, L. Mátyás, General self-similar solutions of diffusion equation and related constructions, (2021).
http://arxiv.org/abs/2104.09128.
[2] N.A. Mbroh, J.B. Munyakazi, A robust numerical scheme for singularly perturbed parabolic reaction-diffusion
problems via the method of lines, Int. J. Computer Math. 99 (2022), 1139–1158.
[3] I. Ali, S. Haq, K.S. Nisar, S.U. Arifeen, Numerical study of 1D and 2D advection-diffusion-reaction equations
[4] A.K. Verma, S. Kayenat, An efficient Mickens’ type NSFD scheme for the generalized Burgers Huxley equation,
[5] S. Pourghanbar, J. Manafian, M. Ranjbar, A. Aliyeva, Y.S. Gasimov, An efficient alternating direction explicit
20
ISSA OMLE, ALI HABEEB ASKAR, ENDRE KOVÁCS
method for solving a nonlinear partial differential equation, Math. Probl. Eng. 2020 (2020), 9647416.
[6] A. Al-Bayati, S. Manaa, A. Al-Rozbayani, Comparison of finite difference solution methods for reaction
diffusion system in two dimensions, AL-Rafidain J. Computer Sci. Math. 8 (2011), 21–36.
[7] A. Costa-Solé, E. Ruiz-Gironés, J. Sarrate, High-order hybridizable discontinuous galerkin formulation for one-
[8] M. H. Holmes, Introduction to perturbation methods, vol. 20. Springer Science \& Business Media, 2012.
[9] B.M. Chen-Charpentier, H.V. Kojouharov, An unconditionally positivity preserving scheme for advection–
[10] A.R. Appadu, Performance of UPFD scheme under some different regimes of advection, diffusion and reaction,
[11] B. Drljača, S. Savović, Unconditionally positive finite difference and standard explicit finite difference schemes
for power flow equation, Univ. Thought Publ. Nat. Sci. 9 (2019), 75–78.
[12] S. Savović, B. Drljača, A. Djordjevich, A comparative study of two different finite difference methods for solving
advection–diffusion reaction equation for modeling exponential traveling wave in heat and mass transfer
[13] M.M. Khalsaraei, F. Khodadosti, Nonstandard finite difference schemes for differential equations, Sahand
[14] H. Burchard, E. Deleersnijder, A. Meister, A high-order conservative Patankar-type discretisation for stiff
[15] D.T. Dimitrov, H.V Kojouharov, Positive and elementary stable nonstandard numerical methods with
[16] E. Kovács, A. Gilicz, New stable method to solve heat conduction problems in extremely large systems, Des.
[17] E. Kovács, New stable, explicit, first order method to solve the heat conduction equation, J. Comput. Appl. Mech.
15 (2020), 3–13.
[18] E. Kovács, A class of new stable, explicit methods to solve the non-stationary heat equation, Numer. Methods
[19] M. Saleh, Á. Nagy, E. Kovács, Construction and investigation of new numerical algorithms for the heat equation:
[20] M. Saleh, Á. Nagy, E. Kovács, Construction and investigation of new numerical algorithms for the heat equation:
[21] M. Saleh, Á. Nagy, E. Kovács, Construction and investigation of new numerical algorithms for the heat equation :
[22] Á. Nagy, M. Saleh, I. Omle, H. Kareem, E. Kovács, New stable, explicit, shifted-hopscotch algorithms for the
[23] Á. Nagy, I. Omle, H. Kareem, E. Kovács, I.F. Barna, G. Bognar, Stable, explicit, Leapfrog-Hopscotch algorithms
[24] O. Issa, New explicit algorithm based on the asymmetric hopscotch structure to solve the heat conduction
[25] E. Kovács, Á. Nagy, M. Saleh, A set of new stable, explicit, second order schemes for the non-stationary heat
[26] M. Saleh, Á. Nagy, E. Kovács, Construction and investigation of new numerical algorithms for the heat equation:
[27] M. Munka, J. Pápay, 4D numerical modeling of petroleum reservoir recovery. Budapest: Akadémiai Kiadó, 2001.