BSc Thesis Applied Mathematics
An analysis of Galerkin
methods for solving transport
problems
Maik Overmars
Supervisor: Matthias Schlottbom
June, 2019
Preface
An analysis of Galerkin methods for solving transport
problems
Maik Overmars
June, 2019
Abstract
An analysis is performed of Galerkin methods for solving a one-dimensinal trans-port problem. In particular, a discontinuous Galerkin and continuous Petrov-Galerkin method are analyzed and compared. The methods both find a piecewise polynomial as a solution with polynomials of order k. For both methods it is shown that they are strongly A-stable. Furthermore, an error analysis is done in which it was obtained that the error in each method is of order O(hmin(k+1,p))withpas the order of a
nu-merical quadrature. Finally, a nunu-merical analysis is done to compare the results of the analysis to numerical results.
Keywords: Galerkin, DG, Petrov-Galerkin, CPG, Differential equation, ODE,
Trans-port problem
1
Introduction
The radiative transfer equation is a differential equation which describes the propagation of radiation trough a domain. The radiation is affected by absorption, emission and scat-tering, of which the effects are included in the differential equation. Furthermore, the solution to the equation is a function of position and direction. In this article we look at a reduced problem where the direction is fixed and only the spatial discretization is taken into account. In addition, the terms responsible for absorption, emission and scattering will be combined into a function f. These terms are non-linear in general, so f can also depend on the solution. Thus, the transport problem for fixed directions and function f that will be analysed is defined on a domainΩand is given by
s· ∇u=f onΩ (1)
u=g on ∂inΩ,
withgdefined on∂inΩ, the part of the boundary for whichspoints inwards. In this paper,
Figure 1: The transport problem along direction s
Now, if we were to fix the point(x, y), we can trace back along fixed directions= (µ, ν) to the point at(x0, y0)on the inflow boundary, as also depicted in figure 1. Along this line we essentially have a one-dimensional problem, since for any point along this line we have (x, y) = (x0+tµ, y0+tν) for t∈[0, T]. Let’s now define the function φas:
φ(t) :=u(x, y, µ, ν) =u(x0+tµ, y0+tν, µ, ν), (2)
which only depends ont. This function φcan be manipulated to obtain
dφ
dt =uxµ+uyν =s· ∇u and,
f(x, y, µ, ν, u) =f(x0+tµ, y0+tν, µ, ν, φ(t)) =f(t, φ(t)).
We recognize the first equation as the directional derivative. Also note thatf is non-linear here, in this articlef will be non-linear for the one-dimensional methods. Combining these, we observe that equation (1) changes to φ0(t) = f(t, φ(t)), which is an ODE of a single variable. As for the initial condition, this is just φ(0) = u(x0, y0, µ, ν) = g(x0, y0). Thus when looking along a single line in a two-dimensional domain, we obtain an ODE.
Similarly, when our domain is one-dimensional, so an interval, we also get such an ODE. In one dimension there are only 2 directions, to the left and to the right. If we take the direction to the right (or upwind), thens= +1and the gradient reduces to a derivative of x. Since the inward boundary is only 1 point, we get initial condition u(x0) = g(x0). Thus the one dimensional problem described in this paper will be over an interval[x0, xN]
for the equation:
u0(x) =f(x, u(x)) (3)
u(x0) =u0.
For this problem, it is assumed that f(x, w)∈Cr in [x0, xN]×R withr ≥1 such that f
is Lipschitz continuous. This also means thatu(x)∈Cr+1[x0, xN].
methods, multi-step methods and more. Hairer and Wanner [5] detailed some of these methods.
In this paper, Galerkin methods will be analysed for solving (3). In previous work Hulme [7] and Lesaint/Raviart [8] developed continuous and discontinuous Galerkin methods re-spectively to solve this transport problem in one dimension. This article will analyse and compare some of these Galerkin methods. For the extension to the second dimension, Demkowizch [3] developed a discontinuous Petrov-Galerkin method. There is still on-going development on these types of Galerkin methods, recently Bause and Köcher [2] developed a method with post-processing to improve the Galerkin approximation.
2
Methods
The goal in Galerkin methods is to find an approximate solution to the weak form of the differential equation. Such a weak form is obtained by multiplying the differential equation by a test function and integrating over the domain. In this is done in the one-dimensional case as described by equation (3), we obtain:
Z xN
x0
u0(x)v(x)dx= Z xN
x0
f(x, u(x))v(x)dx
R(u, v) = Z xN
x0
(u0−f(x, u(x)))v(x) = 0 for all v∈V. (4)
The solution u ∈ U should satisfy R(u, v) = 0 for all v ∈ V with V the space of test functions. In Galerkin methods we choose subspaces Uh ⊂U and Vh ⊂V and look for a
solution uh ∈ Uh, which holds for all vh ∈ Vh. For example, since the actual solution is
continuous, we can chooseUh to be a polynomial space.
In this paper, we will seek solutions to a modified weak form. First, we define a uniform meshxn=x0+nh, 0≤n≤N and subsequently we introduce a mesh dependent weak
form.
Rh(u, v) = N−1
X
n=0
(u(xn+)−u(xn−))v(xn) +
Z xn+1
xn
[u0(x)−f(x, u(x))]v(x)dx (5)
Where we letu(x0−) =u0. This weak form allows discontinuous solutions with(u(xn+)−
u(xn−)) denoting the jump term. Using this weak form, a solution can be found per
in-terval. For each method, we will approximate the solution by a polynomial of degree k on each interval which we will denote as In = [xn, xn+1]. This polynomial
approxima-tion means that an error is introduced between the actual soluapproxima-tion and the approximate solution, since we only construct a solution in the finite-dimensional spacePk, while the
actual solution exists as a continuous function on In. For basis functions φn,j of Pk the
approximate solution satisfies
y(x) =
k+1 X
j=1
bjφn,j(x) 0≤n≤N −1, x∈In. (6)
is the same as the test space. Meanwhile, in Petrov-Galerkin methods it is the case that U 6=V. An advantage of Petrov-Galerkin is that we have more flexibility in the method, since both the test space and trial space can be modified to yield better stability and smaller errors. In Galerkin methods it is an advantage that bothuandvcan be expanded as basis from the same space. In continuous methods we require that the approximate solutionuhis
continuous, while in discontinuous methods the final solution can have discontinuities. The continuous method places restrictions on the solutions on the subdomains, such that the overall solution is continuous. This means that discontinuous methods have more degrees of freedom.
2.1 Discontinuous Galerkin Method
First a discontinuous method will be given for solving the problem given by equation (3). In such a discontinuous method, the approximate solution can have discontinuities at the grid points of the mesh. The solution is approximated by a polynomial as given in (6). Since we don’t require continuity, the approximate solution is a piecewise polynomial function. The test functions will also be piecewise polynomial functions, so our method is a Galerkin method. Then, using the weak form as defined by (5), we require that the solution in this method needs to satisfy the following equation on each interval.
(y(xn−)−y(xn+))v(xn) +
Z xn+1
xn
(y0(x)−f(x, y(x)))v(x)dx= 0 for all v∈Pk (7)
This is a consistent method, since if we take y = u, then the jump term vanishes and y will be a solution to the initial weak form given by (4). The integral can’t be calculated exactly in general, so an interpolatory quadrature formula is used.
Z xn+1
xn
q(x)dx=h
k+1 X
i=1
wiq(xn,i) +O(hp+1) (8)
xn,i=xn+ξih 1≤i≤k+ 1
Herewi andξiare the weigths and abscissae associated with the quadrature. The function
q(x) should be sufficiently smooth for the quadrature to provide a good approximation. Since there arek+1nodes, we have error orderk+1≤p≤2k+1depending on quadrature. This only holds if r ≥ 2k + 2, since then the integrand in (7) is sufficiently smooth. Furthermore, the quadrature is exact for polynomials up to degree p. The introduction of this quadrature rule has the consequence that the method is no longer consistent. To see this, let’s first fill in the quadrature rule into (7).
(y(xn−)−y(xn+))v(xn)+h k+1 X
i=1
wi(y0(xn,i)−f(xn,i, y(xn,i)))v(xn,i) = 0 for allv∈Pk. (9)
It is clear that for y = u, we don’t obtain the same weak form as in (4). Instead, the quadrature rule introduces a consistency error of orderp.
The solutiony(x) can be found per interval by filling in (6) and lettingv be the basis functionsφn,i, 1 ≤i ≤k+ 1 of Pk, since equation (7) will hold for any function in Pk
[8] showed that the discontinuous Galerkin method as described in this section is equal to an implicit Runge-Kutta scheme. If we define xn− = xn and xn+ = xn,1, the following scheme is obtained
yn,i=yn+h k+1 X
j=1
aijf(xn,j, yn,j) 1≤i≤k+ 1
yn+1 =yn+h k+1 X
j=1
wjf(xn,j, yn,j) where
ai1 =w1 1≤i≤k+ 1 (10)
aij =
Z ξi
0
lj(x)dx−w1lj(ξ1) 1≤i≤k+ 1, 2≤j≤k+ 1
lj(x) = k+1 Y
i=2,i6=j
x−ξi
ξj−ξi
, 2≤j≤k+ 1.
By calculating the matrix A in (10), we obtain a non-linear system on each interval In,
which can be solved to obtain to obtain values at the points yn,i. The solution y(x) on
this interval will be the polynomial interpolation of the pointsyn,i. Of course, we wish to
know how accurate and stable this approximate solution is, so the following sections will describe a stability and error analysis.
2.1.1 Stability analysis
Since the Runge-Kutta scheme of (10) is a one-step method, we can determine the stability of the discontinuous Galerkin method by analyzing if the one-step method is stable. In this section we will prove that the one-step method is strongly A-stable.
Definition 1. A one-step method is A-stable if all it’s solutions tend to 0 as as N → ∞, when the method is applied with fixed step size h to the differential equation u0 =λu with Re(λ)<0.
When a one-step method is applied to the differential equation u0 = λu, it can be rewritten in the formyn+1=E(λh)yn for 0≤n≤N, where E(λh)is a rational function.
Instead of showing A-stability, we will show that the one-step method is strongly A-stable. The definition for strong A-stability depends on constraints for the functionE(λh).
Definition 2. A one-step method is strongly A-stable if yn+1 =E(λh)yn, |E(λh)|<1for
Re(λh)<0 and|E(λh)| →0 for Re(λh)→ −∞.
This function E(λh) approximates exp(λh). Lesaint and Raviart [8] showed that the one-step method has accuracy of order p = 2k+ 1 if we choose Gauss-Radau weigths and abscissae. Then, because E(λh) is of order 2k+ 1 and is a rational approximation to exp(λh), it must be equal to Pk+1,k(λh), the Padé rational approximation of exp(λh).
This Padé approximant is a rational function, with the numerator being a polynomial of degree kand the denominator being a polynomial of degree k+ 1. It is the best rational approximation to a function. Axelsson [1] showed thatPk+1,k(λh) satisfies the conditions
2.1.2 Error bounds
In the discontinuous method two error terms arose, namely an error term for the polynomial approximation and for the quadrature. In this section error bounds will be given for the approximate solution found by (10). First, the following theorem will hold.
Theorem 1. Assumef(x, y(x))is Lipschitz continuous in [x0, xN]×R and denote L the
the Lipschitz constant for f in that region. Given our solution by the discontinuous Galerkin method as described by (10) and the actual solution to the problem given in (4), then the following bound holds: |un−yn| ≤Khp.
Proof. The truncation error τn on each interval equals
τn=un+1−un−h k+1 X
i=1
wif(xn,i, y(xn,i)) =
Z xn+1
xn
f(s, u(s))ds−h
k+1 X
i=1
wif(xn,i, y(xn,i)),
(11)
where we used the one-step method of (10). Now using our quadrature rule this implies
|τn| ≤Bhp+1. Henrici [6] proved that this implies that|un−yn| ≤Khp and the theorem
is proven.
The following theorem will give a general error bound for the approximate solution y(x).
Theorem 2. Assume the assumptions of theorem 1 hold. Then the following error bound is obtained: maxx0≤x≤xN|u(x)−y(x)| ≤Ch
min(p,k+1).
Proof. First of all, we takex∈Inand introduce the polynomial interpolation ofu(x)using
the quadrature points.
uh(x) = k+1 X
i=1
lj(x)u(xn,i) (12)
For this approximation we know that |uh(x)−u(x)| ≤ O(hk+1). Now using the triangle
inequality we obtainmaxx|u(x)−y(x)| ≤maxx|u(x)−uh(x)|+ maxx|uh(x)−y(x)|. The
polynomial approximationy(x)is also just the interpolating polynomial through the points yn,ias given by (10). Thus we obtain
max
x |uh(x)−y(x)|= maxx | k+1 X
i=1
li(x)(un,i−yn,i)| ≤max x
k+1 X
i=1
|li(x)||un,i−yn,i| (13)
Now using (10) and the Lipschitz continuity off(x, u(x))
|un,i−yn,i| ≤ |un−yn|+h| k+1 X
j=1
aij[f(xn,i, u(xn,i))−f(xn,i, y(xn,i))]| (14)
≤ |un+yn|+hL|u(x)−y(x)| k+1 X
j=1
|aij| ≤ |un+yn|+hLB|u(x)−y(x)|.
Here we chooseB such thatmaxiPkj=1+1aij ≤B. This is filled into (13) to get
max
x |uh(x)−y(x)| ≤(|un+yn|+hLB|u(x)−y(x)|) maxx k+1 X
i=1
|li(x)| ≤F|un−yn|+hLBFmax
(15)
whereF is defined such thatF ≥maxxPki=1+1|li(x)|. Using the triangle equality, (15), and
theorem 1 the final result is obtained.
max
x |u(x)−y(x)| ≤O(h
k+1) +F|u
n−yn|+hLBFmax
x |u(x)−y(x)| (16)
max
x |u(x)−y(x)| ≤
F
1−hLBF|un−yn|+O(h
k+1)≤Chmin(k+1,p)
For the step size it is required that h ≤ (LBF)−1. Since this holds for any interval this will also hold on the whole domain.
2.2 Continuous Petrov-Galerkin Method
Following the discontinuous method given in the previous sections, a continuous method will now be given. Again, just like in the discontinuous method,y(x)will be approximated on each interval In by a polynomial of degree k as given by (6). However, now we also
require that the approximate solution is continuous over the whole domain. Thus, we have a continuity requirement at the grid points.
y(x0+) =u0 (17)
y(xn+) =y(xn−) 1≤n≤N −1
In this continuous method we use the weak form as given by (5) and because of the continuity the jump terms vanish. Thus, we require the solution to satisfy the following equation
Z xn+1
xn
(y0(x)−f(x, y(x)))v(x)dx= 0 for all v∈Pk. (18)
This method is consistent, since the solutionuto the initial problem of (4) is also a solution of equation (18). The test functions v are polynomials of degree k on each interval, but don’t need to be continuous. So the test functons are piecewise polynomial functions. The solutiony does need to be continuous, and equals a polynomial of degree k on each inter-val. As a result, the test and trial space are different and the method is a Petrov-Galerkin method.
To find an approximate solutiony(x) to equation (18) we create a system of equations by filling in equation (6) into equation (18) and letting v be the first k basis function to obtain a system of equations.
Z xn+1
xn
k+1 X
j=1
bjφ0n,j(x)φn,i(x)dx=
Z xn+1
xn
f(x,
k+1 X
j=1
bjφn,j(x))φn,i(x)dx 1≤i≤k, 0≤n≤N −1
(19)
k+1 X
i=j
bj
Z xn+1
xn
φ0n,j(x)φn,i(x)dx=
Z xn+1
xn
f(x,
k+1 X
j=1
bjφn,j(x))φn,i(x)dx 1≤i≤k, 0≤n≤N −1
This is a system ofkequations withk+ 1unknowns. For the final equation we fill in (6) into continuity requirement (17) to obtain
k+1 X
i=1
Finally, an interpolatory quadrature formula is introduced to approximate the integral on the right hand side of (19). The integral on the left contains only polynomials and can thus be calculated exactly and thus we don’t need the quadrature there.
Z xn+1
xn
q(x)dx=h
k
X
i=1
wiq(xn,i) +O(hp+1)
xn,i=xn+ξih 1≤i≤k
Note that this time there are k nodes, instead of k+1 in the discontinuous method. We requireq(x) to be 2k times differentiable for the quadrature to have errorO(hp+1), so we should have that r ≥ 2k. In this case, k ≤ p ≤ 2k−1 depending on quadrature and for polynomials up to degree p the quadrature is exact. Again this quadrature means a consistency error of order p is introduced. Combining this quadrature rule with (19) and (20) we obtain the following system on each intervalIn.
A(n)b=c(n)(b) with
A(1n,j)=φn,j(xn) 1≤j≤k+ 1
A(i,jn)= Z xn+1
xn
φ0n,j(x)φn,i−1(x)dx 2≤i≤k+ 1, 1≤j ≤k+ 1 (21)
c(1n)(b) =yn
c(in)(b) =h
k
X
m=1 wmf
xn,m,
k+1 X
j=1
bjφn,j(xn,j)
φn,i−1(x) 2≤i≤k+ 1
In this form it is required to calculate a matrix A(n) on each interval. However, for ap-propriate choice of basis it will be shown that only one matrix needs to be calculated for this method. This is done via integration over the reference elementK = [0,1]. Let’s first define a basisφˆi on this element. Then for each interval In, let φn,ibe the shifted version
of φi. If we introduce the change of variable xˆ = xnx+1−x−nxn, then we have
ˆ
φi(ˆx) = φn,i(x).
Furthermore,dˆx=dx/(xn+1−xn) =dx/h such that the matrix of equation (21) becomes
A(1n,j) =φn,j(xn) = ˆφj(0) 1≤j≤k+ 1
A(i,jn) = Z xn+1
xn
φ0n,j(x)φn,i−1(x)dx=h
Z 1
0 ˆ φj
0
(ˆx) ˆφi−1(ˆx)dˆx (22)
2≤i≤k+ 1, 1≤j≤k+ 1, 0≤n≤N−1.
Since the matrix doesn’t depend on the interval, it is the same on each interval so we only have to calculate it once. Combing (21), (22), we get the following system of equations:
A1,j= ˆφj(0) 1≤j≤k+ 1 (23)
Ai,j =h
Z 1
0 ˆ φj
0
(x) ˆφi−1(x)dx 2≤i≤k+ 1, 1≤j≤k+ 1
c(1n)(b) =yn
c(in)(b) =h
k
X
m=1 wmf
xn,i,
k+1 X
j=1
bjφn,j(x)
φn,i−1(x) 2≤i≤k+ 1 0≤n≤N −1.
So we get the non-linear system Ab = c(n)(b) on each interval In. By solving for b we
2.2.1 Stability analysis
In this section we will prove that the method as described in the previous section is strongly A-stable. However, if we wish to have a similar analysis as for the discontinuous method, our solution needs to be described as a one-step method. Hulme [7] showed that this Galerkin method produces the same solution as a collocation and interpolatory quadrature method, under the restriction that the step size h is sufficiently small. In this case, the Galerkin solution satisfies
hy0(xn,i) =hf(xn,i, y(xn,i)) 1≤i≤k, 0≤n≤N−1, (24)
which is the requirement for the solution to collocate at the points xn,i. Combined with
the continuity requirement (17), we obtain that solution must satisfy:
y(x) =yn+
Z x
xn
y0(s)ds=yn+
Z x
xn
k
X
i=1
li(s)f(xn,i, y(xn,i))ds (25)
=yn+ k
X
i=1 Z x
xn
li(s)dsf(xn,i, y(xn,i)) xn≤x≤xn+1,
li(s) = k
Y
j=1,i6=j
x−xnj
xn,i−xn,j
.
The first equality follows from the continuity, while the second equality is true sincey0(s) is a polynomial of degree k-1 which passes through k collocation points and thus can be interpolated by lagrange polynomials. Then (24) is used and we obtain the result. Using this, it is clear that we acquire a one-step method by takingx=xn+1.
yn+1 =yn+h k
X
i=1
wif(xn,i, y(xn,i)) with (26)
wi =h−1
Z xn+1
xn
li(s)ds
Subsequently, let’s show that this one-step method is strongly A-stable. Again, for the problem of u0 = λu we may write the approximate solution as yn+1 = E(λh)yn,
where E(λh) is a rational function. For strong A-stability, definition 2 is used. In the obtained method, the quadrature can still be chosen freely. We choose to use the Gauss-Legendre quadrature, since this is the most accurate quadrature and is of order O(h2k). Ehle [4] has proven that for this quadrature,E(λh) =Pn,n(λh), wherePn,n(λh) is the nth
diagonal Padé approximation toexp(λh). Furthermore, he showed thatPn,n(λh) satisfies
the conditions of strong A-stability in definition 2. Thus, given one-step method (26) and Gauss-Legendre quadrature, the continuous Petrov-Galerkin method is strongly A-stable.
2.2.2 Error bounds
In this section error bounds will be derived for the approximate solution that was found using this Petrov-Galerkin method. We note that errors arise in the method from two sources, namely a consistency error from the quadrature and an error since we approximate with a polynomial. First of all we repeat theorem 1 of section 2.1.2, but in this case with the one-step method of equation (26). With similar analysis it can be shown that
Theorem 3. Assumef(x, y(x))is Lipschitz continuous in [x0, xN]×R and denote L the
the Lipschitz constant for f in that region. Let h be sufficiently small such that equations (26) and (25) hold. Given the solution y(x) of the Petrov-Galerkin method described by (25)and the actual solutionu(x)to the problem given in (5), then the following error bound holds: maxx0≤x≤xN|u(x)−y(x)| ≤Ch
min(p,k+1).
Proof. First of all we letx∈Inand we defineuh(x), thekpoint polynomial approximation
tou(x).
uh(x) =un+ k
X
i=1
f(xn,i, u(xn,i))
Z x
xn
li(s)ds (27)
This is defined similarly to (25) and again holds since u satisfies the differential equation and is continuous at the grid points. Now the triangle equality is used to split up the error into two parts.
max
x |u(x)−y(x)| ≤maxx |u(x)−uh(x)|+ maxx |uh(x)−y(x)| (28)
The first part is just the polynomial interpolation error for which we have|u(x)−uh(x)| ≤
O(hk+1). For the second part, we usey(x) as defined in (25) to get
max
x |uh(x)−y(x)| ≤ |un−yn|+ maxx | k
X
i=1 Z x
xn
li(s)dsf(xn,i, u(xn,i))−f(xn,i, y(xn,i))|
≤ |un−yn|+Lmax
x |u(x)−y(x)| k
X
i=1 max
x |
Z x
xn
li(s)ds| (29)
≤ |un−yn|+hBLmax
x |u(x)−y(x)|
Here the Lipschitz continuity of f with Lipschitz constant L was used. Furthermore, we letmaxx|
Rx
xnli(s)ds| ≤hB. Now combining (28) and (29) we obtain
max
x |u(x)−y(x)| ≤O(h
k+1) +|u
n−yn|+hBLmax
x |u(x)−y(x)|
max
x |u(x)−y(x)| ≤O(h
k+1) + 1
1−hBL|un−yn|, (30)
where we require that h ≤ (BL)−1. From theorem 1 we know that |un−yn| ≤ Khp to
finally obtain
max
x |u(x)−y(x)| ≤Ch
min(p,k+1). (31)
Since this holds on every interval, it holds on the whole domain and the result is proven.
3
Numerical studies
3.1 Implementation
freedom more than the continuous Petrov-Galerkin method, since with the quadrature we get to choosek+ 1nodes instead ofk. However, the systems are of similar size, since both require calculating a matrix of sizek+1. This is because in the continuous Petrov-Galerkin method, we have an equation dedicated to the continuity requirement. Also, both methods require solving a non-linear system on each interval.
Additionally, it was shown that the discontinuous method equals an implicit Runge-Kutta scheme given by (10). This means that in each iteration we only need to re-evaluate the functionf and do a matrix multiplication. In the continuous Petrov-Galerkin method the function that has to be iterated involves more variables and takes longer to evaluate. Thus, for the schemes given in this article, the discontinuous method actually is more efficient. When the step size decreases and/or the polynomial order increases, this becomes quite noticeable.
3.2 Numerical error analysis
In this section a comparison is made between the errors found in the theory and the errors found in the numerical schemes. To do this we choose functions f(x, u(x)) for which an analytic solution to the differential equation is known. The problem we will consider is
u0(x) = 2u, u(0) = 1 0≤x≤1. (32)
For this differential equation we know that the solution is given byu(x) = exp(2x). Now we apply both the discontinuous Galerkin method (10) and the continuous Petrov-Galerkin method (23). We chooseh= 1/N whereN = 2,4,8,16,32 and k= 1,· · · ,6. Just like in the error analysis, the maximum norm is used. For the discontinuous method, thek+ 1 point Gauss-Radau weights and abscissae are used. The basis functions don’t need to be specified since we implement the method as a Runge-Kutta scheme.
Figure 2: First few basis functionsφˆi
Now for these quadrature rules and basis choices the numerical experiments are done. The numerical errors can be seen in tables 1 and 2.
Table 1: Numerical errors for the discontinuous Galerkin method.
h\k 1 2 3 4 5 6
1/2 1.7 2.6e-1 2.2e-2 1.4e-3 7.5e-5 3.4e-6 1/4 6.0e-1 3.9e-2 1.7e-3 5.5e-5 1.5e-6 8.3e-8 1/8 1.7e-1 5.3e-3 1.2e-4 1.9e-6 1.7e-8 4.1e-8 1/16 4.5e-2 7.0e-4 7.6e-6 6.5e-8 5.2e-9 3.0e-9 1/32 1.2e-2 9.0e-5 4.8e-7 8.6e-9 1.3e-8 1.2e-8
Table 2: Numerical errors for the continuous Petrov-Galerkin method.
h\k 1 2 3 4 5 6
1/2 1.8 4.9e-2 2.2e-3 1.1e-4 4.7e-6 2.0e-7 1/4 4.3e-1 7.0e-3 1.9e-4 4.5e-6 1.2e-7 7.6e-8 1/8 1.2e-1 9.1e-4 1.1e-5 1.2e-7 4.9e-8 1.7e-7 1/16 3.1e-2 1.1e-4 8.2e-7 1.1e-7 3.8e-7 3.0e-7 1/32 8.1e-3 1.3e-2 2.4e-7 2.9e-7 2.4e-7 3.3e-7
As can be seen in the tables there is convergence in both step size h and polynomial degreek. In general this seems to obey the error boundChk+1 as found in both methods. However, we see for higher orders ofkwhen the step size decreases that the error actually seems to increase again slightly. This is mostly present in the continuous Petrov-Galerkin method, however it can also be seen a bit in the discontinuous Galerkin method. For this method it however seemed that ifh decreases even more that the error decreases again so the problem is minor here.
perform better. In hindsight it would have been better to test with different solvers like for example Newton’s method. Also initial conditions could have been considered more since they can influence if the solver reaches a good solution. Since fsolve was used in both methods, this can explain some of the behaviour of both methds.
Secondly, the choice of basis functions can have an influence. Since our discontinuous method was implemented via an implicit Runge-Kutta scheme, this can’t really be the problem there. For the continuous method we did choose the basis as described earlier this section. To see how this influencs the solution, we introduce the condition number. For a linear problemAx=b the condition number is defined as
κ(A) =kAkkA−1k. (33)
The condition number influences the sensitivity of the solution. In problems with high condition number small errors can greatly be increased. In our case, if we takef(x, u(x)) to be linear, then we also get a linear system where the matrixAcontains integrals of the polynomial basis functions. Thus for inappropriate choice of basis the condition number can become large and as a result some accuracy is lost. For our choice of basis and k= 6, a quick numerical test shows that κ(A) = 4.7·105. This is quite large and it can explain the weird behaviour, which especially happens for higherk. This problem can be resolved by choosing a different basis, for example bases of Legendre polynomials for their orthogonality.
4
Conclusion
In this paper both a discontinuous Galerkin method and a continuous Petrov-Galerkin method were analyzed and compared. They are very similar in approximating the solution on each interval by a polynomial of certain degree k. There are a few differences for each method. First of all, quite obviously, the continuous method yield a continuous solution. This can be desirable, since the actual solution u is also continuous given our constraints of continuity on f. In the discontinuous method, we have a modified weak form which allows discontinuities. This also means that there is more freedom in finding the solution and the discontinuities allow us to choose the approximate solution to fit better.
The implementation of both methods is also a bit different. In the discontinuous method, it was shown that the Galerkin method equals a implicit Runge-Kutta scheme. For the continuous method a non-linear system was by more regular Galerkin means. The implicit Runge-Kutta scheme had simpler function evaluations and thus the discontinuous method was more efficient.
For both methods we have shown that they are strongly A-stable, so in that regard there is no difference. However, the discontinuous method had a quadrature of orderp= 2k+ 1, while the continuous method had order p = 2k. This is due to the fact that the Petrov-Galerkin method had to satisfy a continuity requirement. This requirement also results in the discontinuous method having a degree of freedom more.
Furthermore, we have shown the error bound maxx|u(x)−y(x)| ≤ Chmin(p,k+1) for the
continuous Petrov-Galerkin method. For the discontinuous method the following error bounds were obtainedmaxx|u(x)−y(x)| ≤Chmin(p,k+1). Due to the order of the methods,
of this is not that high.
To conclude, the continuity constraint ensures that the solution in the continuous method is continuous, but at the cost of an order of accuracy. Also the discontinuous method was more efficient in implementation.
For further research more methods could be analyzed such that a broader comparison can be made. This was the initial idea, but due to time constraints it was not achieved. Furthermore, the methods can be extended to the second dimension and then a comparison can also be made between the one and two dimensions.
References
[1] Owe Axelsson. A class ofa-stable methods.BIT Numerical Mathematics, 9(3):185–199, 1969.
[2] Markus Bause, Uwe Köcher, Florin A Radu, and Friedhelm Schieweck. Post-processed galerkin approximation of improved order for wave equations. arXiv preprint arXiv:1803.03005, 2018.
[3] Leszek Demkowicz and Jayadeep Gopalakrishnan. A class of discontinuous petrov– galerkin methods. part i: The transport equation. Computer Methods in Applied Me-chanics and Engineering, 199(23-24):1558–1572, 2010.
[4] Byron L Ehle. High order a-stable methods for the numerical solution of systems of de’s. BIT Numerical Mathematics, 8(4):276–278, 1968.
[5] Ernst Hairer, Syvert P Nørsett, and Gerhard Wanner. Solving ordinary differential equations. 1, Nonstiff problems. Springer-Vlg, 1991.
[6] Peter Henrici. Discrete variable methods in ordinary differential equations. 1962.
[7] Bernie L Hulme. Discrete galerkin and related one-step methods for ordinary differential equations. Mathematics of Computation, 26(120):881–891, 1972.
A
Matlab impementation of the methods
A.1 Matlab code discontinuous Galerkin method
1 %p i e c e w i s e l i n e a r ! !
2 c l e a r a l l 3 % s u b i n t e r v a l s 4 a = 0 ; b = 1 ;
5 N = 4 ;
6 h = ( b−a ) /N; 7
8 % g r i d p o i n t s
9 x = l i n s p a c e( a , b ,N+1) ; 10 u = z e r o s(N+1 ,1) ;
11 % i n i t i a l c o n d i t i o n 12 u ( 1 ) = 1 ;
13
14 k = 6 ;
15 A = z e r o s( k+1 ,k+1) ; 16
17 % Gauss−L e g e n d r e q u a d r a t u r e 18 syms q
19 k s i = d o u b l e ( v p a s o l v e ( l e g e n d r e P ( k , q ) == 0 , q ) ) ;
20 b = z e r o s( k , 1 ) ; 21 f o r i =1: k
22 b ( i ) = (2∗(1−k s i ( i ) ^2) ) / ( ( k+1)^2∗l e g e n d r e P ( k+1 , k s i ( i ) ) ^2) ; 23 end
24 k s i = 0 . 5∗( k s i +1) ; 25 b = 0 . 5∗b ;
26
27 syms xx 28
29 % b a s i s
30 Mphi = [1−xx , xx , xx .∗(1−xx ) , xx .∗(1−xx ) .∗( 0 . 5−xx ) , xx .∗(1−xx )
.∗( 0 . 3 3−xx ) .∗( 0 . 6 7−xx ) , xx .∗(1−xx ) .∗( 0 . 2 5−xx ) .∗( 0 . 5−xx ) .∗( 0 . 7 5−
xx ) , xx .∗(1−xx ) .∗( 0 . 2−xx ) .∗( 0 . 4−xx ) .∗( 0 . 6−xx ) .∗( 0 . 8−xx ) ] ; 31 Mphi = Mphi ( 1 : k+1) ;
32
33 % c r e a t i o n m a t r i x A
34 f o r i =1: k+1
35 f o r j =1: k+1
36 i f i == 1
37 A( i , j ) = s u b s ( Mphi ( j ) , xx , 0 ) ; 38 e l s e
39 A( i , j ) = h∗i n t ( Mphi ( i−1)∗d i f f( Mphi ( j ) ) , 0 , 1 ) ;
40 end
41 end 42 end
43
45 c = z e r o s( k +1 ,1) ; 46 c o e f = z e r o s(N, k+1) ; 47 f o r n=1:N
48 %s o l v e
49 xc = x ( n ) + k s i∗h ; 50 u i n i = u ( n ) ;
51 f u n = @( c o e f ) A∗c o e f − f c ( xc , x ( n ) , x ( n+1) , u i n i , k , Mphi , b , c o e f , h ) ;
52 c o e f ( n , : ) = f s o l v e ( fun , o n e s ( k +1 ,1) ) ;
53 u ( n+1) = c o e f ( n , 2 ) ; 54 end
55
56 % p l o t s o l u t i o n u a s c o m b i n a t i o n o f b a s i s f u n c t i n o s on e a c h
domain
57 h o l d on
58 t i t l e( ’ N u m e r i c a l s o l u t i o n CPG ’) 59 x l a b e l(’ x ’)
60 y l a b e l(’ y ( x ) ’)
61 d i f f = z e r o s(N, 1 ) ; 62 f o r n=1:N
63 xp = l i n s p a c e( x ( n ) , x ( n+1) , 1 0 0 ) ;
64 yp = 0 ;
65 f o r i =1: k+1
66 yp = yp+c o e f ( n , i )∗s u b s ( Mphi ( i ) , xx , ( xp − x ( n ) ) / ( x ( n+1)−x ( n ) ) ) ;
67 end
68 yp2 = exp( 2∗xp ) ;
69 d i f f( n ) = max(abs( yp −yp2 ) ) ; 70 p l o t( xp , yp ) ;
71 end 72 h o l d o f f
73 max(d i f f) 74
75 % f u n c t i o n f o r c a l c u l a t i n g r i g h t hand s i d e o f system e q u a t i o n s
76 f u n c t i o n y2 = f c ( xc , x1 , x2 , u i n i , k , Mphi , w, c o e f , h ) 77 syms xx
78 y2 = z e r o s( k +1 ,1) ;
79 y2 ( 1 ) = u i n i ; 80 f o r i = 1 : k
81 sumg = 0 ;
82 f o r m = 1 : k
83 xnm = ( xc (m) − x1 ) / ( x2 − x1 ) ;
84 sumg = sumg+w(m)∗f ( xc (m) , d o u b l e ( s u b s (d ot( c o e f , Mphi ) , xx , xnm) ) )∗d o u b l e ( s u b s ( Mphi ( i ) , xx , xnm) ) ;
85 end
86 y2 ( i +1) = h^2∗sumg ; 87 end
90 %f u n c t i o n f i n u ’ = f ( x , u ) 91 f u n c t i o n y = f ( x , u )
92 y = 2∗u ; 93 end
A.2 Matlab code continuous Petrov-Galerkin method
1 c l e a r a l l
2 % s u b i n t e r v a l s 3 a = 0 ; b = 1 ; 4 N = 4 ;
5 h = ( b−a ) /N;
6 xb = l i n s p a c e( a , b ,N+1) ; 7 ub = z e r o s(N+1 ,1) ;
8 %i n i t a l c o n d i t i o n 9 ub ( 1 ) = 1 ;
10
11 %n u m e r i c a l i n t e g r a t i o n , o r d e r p o l y n o m i a l and w e i g h t s and
a b s c i s s a e
12 k = 1 ;
13
14 % Gauss−Radau w e i g h t s and a b s c i s s a e 15 syms q
16 k s i = d o u b l e ( v p a s o l v e ( ( l e g e n d r e P ( k , q )+l e g e n d r e P ( k+1 ,q ) ) /(1+q ) == 0 , q ) ) ;
17 b = z e r o s( k +1 ,1) ;
18 b ( 1 ) = 2 / ( k+1) ^ 2 ; 19 f o r i =2: k+1
20 b ( i ) = (1−k s i ( i ) ) / ( ( k+1)^2 ∗ l e g e n d r e P ( k , k s i ( i ) ) ^2) ; 21 end
22 k s i = 0 . 5∗( k s i +1) ; 23 b = 0 . 5∗b ;
24
25 % Gauss−L e g e n d r e 26 % syms q
27 % k s i = d o u b l e ( v p a s o l v e ( l e g e n d r e P ( k+1 ,q ) == 0 , q ) ) ; 28 % b = z e r o s ( k +1 ,1) ;
29 % f o r i =1: k+1
30 % b ( i ) = (2∗(1−k s i ( i ) ^2) ) / ( ( k+2)^2∗l e g e n d r e P ( k+2 , k s i ( i ) ) ^2) ; 31 % end
32 % k s i = 0 . 5∗( k s i +1) ; 33 % b = 0 . 5∗b ;
34
35 u = z e r o s(N, k+1) ; 36 x = z e r o s(N, k+1) ;
37
38 A = z e r o s( k+1 ,k+1) ; 39 A ( : , 1 ) = b ( 1 ) ;
40
42 f o r j =2: k+1
43 l a g r = @( xx ) 1 ;
44 f o r i =2: k+1
45 i f i ~= j
46 g = @( xx ) ( xx − k s i ( i ) ) / ( k s i ( j )−k s i ( i ) ) ; 47 l a g r = @( xx ) l a g r ( xx ) .∗g ( xx ) ;
48 end
49 end
50 f o r i = 1 : k+1
51 i f k==1
52 A( i , j ) = k s i ( i ) − b ( 1 )∗l a g r ( k s i ( 1 ) ) ; 53 e l s e
54 A( i , j ) = i n t e g r a l ( l a g r , 0 , k s i ( i ) ) − b ( 1 )∗l a g r ( k s i ( 1 ) ) ;
55 end
56 end
57 end 58
59 f o r n=1:N
60 x ( n , : ) = xb ( n )+k s i ’∗h ; 61 % s o l v e n o n l i n e a r e q u a t i o n 62 unew = ub ( n )∗o n e s ( k +1 ,1) ;
63 f u n = @( un ) ub ( n ) + h∗A∗f ( x ( n , : ) . ’ , un ) − un ; 64 unew = f s o l v e ( fun , unew ) ;
65
66 % update boundary p o i n t s and u v e c t o r
67 ub ( n+1) = ub ( n ) + h∗do t( b , f ( x ( n , : ) . ’ , unew ) ) ; 68 u ( n , : ) = unew ;
69 end 70
71 % p l o t s o l u t i o n 72 h o l d on
73 t i t l e( ’ N u m e r i c a l s o l u t i o n DG ’) 74 x l a b e l(’ x ’)
75 y l a b e l(’ y ( x ) ’)
76 d i f f = z e r o s(N+1 ,1) ; 77 f o r i = 1 :N
78 xx = l i n s p a c e( xb ( i ) , xb ( i +1) , 1 0 0 ) ;
79 yy = l a g r a n g e ( xx , x ( i , : ) , u ( i , : ) ) ; 80 p l o t( xx , yy )
81 yp2 = exp( 2∗xx ) ;
82 d i f f( n ) = max(abs( yy −yp2 ) ) ; 83 end
84 h o l d o f f
85 max(d i f f) 86
87 % f u n c t i o n f i n u ’ = f ( x , u )
88 f u n c t i o n y = f ( x , u ) 89 y = 2∗u ;