BEP Westervelt
BEP Westervelt
1 Abstract 1
2 Introduction 2
3 Linear Wave Behaviour 3
3.1 1D Wave solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.2 2D Wave Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2.1 Separation of Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2.2 Green’s Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4 Finite Element Method for linear Wave 12
4.1 Weak Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 Space Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3 Time Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.4 Verlet Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.4.1 Verlet for linear wave equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5 Finite Element Method for Non-linear Diusion 15
5.1 Weak Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 Space Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.3 Iteration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6 Finite Element Method for Westervelt 17
6.1 Weak Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.2 Space Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.3 Verlet Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.4 Iteration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7 Implementation 20
7.1 Mesh Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.2 Base Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.3 Element-wise Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.4 Vectorized Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.5 Boundary Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8 Results 25
8.1 One Dimensional Wave Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.1.1 Linear Solution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.1.2 Westervelt Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.2 Circular Symmetric Two Dimensional Wave Example . . . . . . . . . . . . . . . . . . . . . . . 28
8.2.1 Linear Solution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
8.2.2 Westervelt Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
8.3 Non-linear Diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
8.4 Mesh Size vs Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8.5 Time Step vs Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
9 Conclusion 38
10 Discussion 39
Bibliography 41
A Appendix 42
ii
1
Abstract
This essay shows a two dimensional implementation of the finite element method for the Westervelt equa-
tion. To do this the finite element method is first applied to the linear wave equation, then to non-linear
diffusion and finally to the Westervelt equation. Both an element by element and a faster vectorized imple-
mentation are given for the finite element method. To verify the numerical solution two analytical solutions
are used. The first is a one dimensional wave and the second a circularly symmetric wave.
We found that the two-dimensional implementation was successful in computing the Westervelt equa-
tion. The error of the solution has this relation with the mesh element size ϵ ∝ l c 1.7 . It was also found that
the time step used to compute the solution needs to be small enough for the implementation to converge.
1
2
Introduction
For most applications waves can be described by the general linear wave equation. Which can be solved
analytically on simple domains or numerically approximated by using the finite difference method, finite
element method or the integral equation method, when dealing with difficult domains. However, when deal-
ing with high pressure or high frequency waves these approaches are no longer sufficient. This is due to the
non-linear effects caused by the large and fast changes in pressure.
The non-linear effects are caused by both the distortion of the wave profile due to convection and the
difference in compression which results in different propagations speeds [1]. From these two sources the
second one is by far the most influential. There are various different equations that are used to describe
non-linear wave equations. In this thesis we will be focusing on the Westervelt equation [2].
1 ∂2 u β ∂2 u 2
∇2 u − = − (2.1)
c 02 ∂t 2 ρ 0 c 04 ∂t 2
With u the pressure field, c 0 the small signal sound speed, ρ 0 the ambient density of mass and β the
coefficient of non-linearity. The coefficient of non-linearity β is a dimensionless quantity that is inherent to
the material that the wave is propagating through. This value is discussed in depth in both [1] and [2] though
it is most often found empirically.
This equation is equal to the linear wave equation when using β = 0. It can be seen that the non-linear
2 2
term depends on ∂∂tu2 which becomes more influential when the amplitude of u increases or the frequency
of change in u increases. Thus we see that the expected behaviour of this equation agrees with the theory of
non-linear waves.
There are no analytical solutions for the Westervelt equation, thus for solving non-linear wave problems
one must rely on using numerical methods. The finite element method is an incredibly powerful tool to solve
any partial differential equation on difficult domains. The finite element method can be used for a lot of
different applications like calculating the heat diffusion in a chip or the air flow around a building. In the
work of [3] and [4] it has been shown that the finite element method can be extended to solve the Westervelt
equation in one dimension. The goal of this thesis is to further expand on their work to solve the Westervelt
equation in two dimensions.
In Chapter 3 we will discuss two different analytical solutions to the linear wave equation that we will
use to verify the FEM implementation. Then in the next chapter we will first apply the regular finite element
method to solve the linear wave equation. To get familiar with non-linearities we will then use the finite
element method to solve the non-linear diffusion equation in chapter 5. After this we will solve the Westervelt
equation by using a finite element solution. The next chapter will discuss the implementation of the theory
discussed in the previous chapter. We will be using both an element by element implementation and a faster
vectorized implementation. Using these implementations we will show and discuss the results in chapter 8.
Here we will also look at the relation between the error and the time step and element size. In chapter 9 the
conclusion to this thesis can be found. Finally we will discuss the results in Chapter 10.
2
3
Linear Wave Behaviour
In this chapter we will discuss several analytical solutions to the wave equation that we can later use to verify
our FEM implementation. In classical mechanics when trying to describe a simple wave a very powerful
formula is the wave equation:
∂2 u
= c 02 ∇2 u (3.1)
∂t 2
This equation can be used to describe all kind of waves, like light, water and sound waves. the c 0 in this for-
mula is the speed of the wave and u is a function of time and space that shows the wave behaviour. This can
for example be a pressure field or the perturbation of a string in a direction.
To verify our two dimensional FEM implementation from section 4 we will find two analytical solutions
to the linear wave equation. The first is a one dimensional analytical solution with the same boundary and
initial conditions as [4]. We can compare this solution to the FEM solution in a two dimensional channel with
Neumann zero boundaries. Secondly, we will also compute a circular symmetric two dimensional solution
for a Gaussian initial condition on the infinite domain.
Here h(t) is any time dependent function. To solve this problem we will extend it to the infinite domain and
use appropriate initial conditions to simulate the boundary at x = 0. The solution to our problem is then
equal to this solution for all values 0 ≤ x < ∞. This is the definition of the new problem.
∂2 u ∂2 u
= c 02 2
(3.3a)
∂t 2 ∂x
∂u(x, 0)
u(x, 0) = f (x) = g (x) −∞ < x < ∞ (3.3b)
∂t
The functions f (x) and g (x) are the initial conditions. The solution to this problem can be found by using
characteristic coordinates. We now rewrite u as the sum of two new function, one that moves right with speed
c 0 and one that moves left with the same speed.
3
4 3. Linear Wave Behaviour
Using the chain rule we can rewrite 3.5b to the following. After applying the chain rule we evaluate the deriva-
tives at t = 0.
h ∂(x − c t ) ∂F (x − c t ) ∂(x + c t ) ∂G(x + c t ) i¯
0 0 0 0
+ = g (x) (3.6a)
¯
∂t ∂(x − c 0 t ) ∂t ∂(x + c 0 t ) t =0
¯
dF (x) dG(x)
−c 0 + c0 = g (x) (3.6b)
dx dx
Now by rewriting 3.5a and combining that with 3.6b we can find an expression for F (x) and G(x).
df dG dG
g (x) = −c 0 + c0 + c0 (3.7a)
dx dx dx
dG df
2c 0 = c0 +g (3.7b)
dx dx
Z x
1 1
G(x) = f (x) + g (x̃) d x̃ + const (3.7c)
2 2c 0 0
Z x
1 1
F (x) = f (x) − g (x̃) d x̃ − const (3.7d)
2 2c 0 0
By filling in this result in our initial proposition 3.4 we find our solution on an infinite domain, the constants
can be neglected by adding 3.7c and 3.7d with proper shifts. This is the d’Alembert’s Solution to the one
dimensional wave problem.
f (x − c 0 t ) + f (x + c 0 t ) 1
Z x+c 0 t
u(x, t ) = + g (x̃) d x̃ (3.8)
2 2c 0 x−c 0 t
We will now return to the original problem 3.2. Our goal is extend the original problem to the infinite
domain. Our previous derivation still holds for 0 < x < ∞. We can thus apply 3.7c and 3.7d with the initial
conditions 3.2b, in other words f (x) = 0 and g (x) = 0.
We will now solve our problem for two different cases x > c t and x < c t . For the first case, when x > c t > 0 it
follows that x − c t > 0 and x + c t > 0. We can use this in equation 3.4 to find the solution for this case.
This result follows directly from 3.9a and 3.9b. We now move on to the second case where x < c t . We will now
use the boundary condition at x = 0.
We can substitute z ≡ −c 0 t into this equation and rewrite it to F (z). Note that z < 0, since t > 0, so this does
not disagree with 3.9a.
µ ¶
−z
F (z) = h −G(−z) for z < 0 (3.12)
c0
We now again use equation 3.4 to find our solution.
x
µ ¶
u(x, t ) = F (x − c 0 t ) +G(x + c 0 t ) = h t − −G(c 0 t − x) +G(x + c 0 t ) for 0 ≤ x < c 0 t (3.13)
c0
3.2. 2D Wave Solution 5
We restrict our solution here to only x ≥ 0, since that is the only interval we are interested in. From 0 ≤ x < c 0 t
it follows that c 0 t − x > 0 and x + c 0 t > 0 . Using this we can simplify our result and write down our final
solution to problem 3.2.
h t − x
µ ¶
0 ≤x < c 0 t
u(x, t ) = c0 (3.14)
0 x > c0 t
This solution is the boundary condition moving to the right at speed c 0 , which is exactly what one would
expect for this problem.
∂2 u
= c 02 ∇2 u (3.15a)
∂t 2
2
−r
∂u(r, θ, 0)
u(r, θ, 0) = u(r, 0) = Ae 2σ2
=0 (3.15b)
∂t
This is the general linear wave equation with an initial displacement of a Gaussian peak.
Filling this in into the partial differential equation and dividing by c 02 φ(r )h(t ) gives us the separable solution.
As a separation constant we will use −λ.
1 d2 h 1
= −λ = ∇2 φ (3.17)
2 dt 2
c0 h φ
We can split this up into two ordinary differential equations. We can also fill in the Laplacian in polar co-
ordinates. Since φ does not depend on θ, we will also immediately drop the second term of the Laplacian.
d2 h
2
+ λc 02 h = 0 (3.18a)
µdt ¶
1 d dφ
r + λφ = 0 (3.18b)
r dr dr
The solution to the first ode is often seen in separation of variables and is equal to:
p p p
h(t ) = Acos(c λt ) + B si n(c λt ) = Acos(c 0 λt ) (3.19)
which we will set φ(R) = 0. This means that our solution will be valid up to a maximum time t max where
the initial displacement reaches
p the boundary. We will now rewrite the second ordinary differential equation
slightly and substitute in z = λr .
d2 φ dφ
r2 +r + λr 2 φ = 0 ⇒ (3.20a)
dr 2 dr
d2 φ dφ
z2 2 + z + z2φ = 0 (3.20b)
dz dz
6 3. Linear Wave Behaviour
The solution to this ordinary differential equation are the Bessel functions of order 0.
p p
φ(r ) = c 1 J 0 (z) + c 2 Y0 (z) = c 1 J 0 ( λr ) + c 2 Y0 ( λr ) (3.21)
p
Since Y0 ( λr ) is infinite for r = 0, it follows from the first boundary condition that c 2 = 0. From the second
boundary condition we can find the eigenvalues of this problem.
p
J 0 ( λR) = 0 ⇒ (3.22a)
³ z ´2
n
λn = (3.22b)
R
where z n is the nth zero of J 0 . We have now found an infinite set of solutions. We can now use the principle of
superposition and fill in our two solutions to the ordinary differential equations to find the general solution
to our problem (we combine the two arbitrary constants into one constant c n ).
∞ p p
c n J 0 ( λn r )cos(c 0 λn r )
X
u(r, t ) = (3.23)
n=1
The last thing that is left is to compute the constants c n . To do this we need to use the initial solution 3.15b.
From now on it is more convenient to use z n instead of λn .
−r 2
∞ ³z ´
n
Ae 2σ2 =
X
cn J 0 r (3.24)
n=1 R
We can isolate one specific³ c n by using the orthogonality of the Bessel functions with weight r . To do this, we
zn ´
multiply both sides by r J 0 r and integrate from 0 to R.
R
−r 2 ³
RR zn ´
0 Ae 2σ2 J 0 r r dr
cn = R (3.25)
R R ³ z n ´2
0 J0 r r dr
R
The denominator of this fraction can be calculated analytically. In [5] the following result is given (note that
the Bessel functions are indeed orthogonal).
1 δnm
Z
J i (µn x)J i (µm x)x d x = J i +1 (µn )2 (3.26)
0 2
where µn is equal to the nth zero of J i . We can now find our integral by entering i = 0, substituting in r = R x
and using that µn = z n when i = 0.
Z R ³ r ´2 r d r 1
J 0 zn = J 1 (z n )2 ⇒ (3.27a)
0 R R R 2
R2
Z R ³
z n ´2
J0 r r dr = J 1 (z n )2 (3.27b)
0 R 2
Using this result we can write down our final solution for our problem.
−r 2 ³
∞ 2
Z R z ´ ³z ´ ³ z ´
X 2σ2 n n n
u(r, t ) = Ae J0 r r d r J0 r cos c 0 r (3.28)
2 2
n=1 R J 1 (z n ) 0 R R R
We will use a numerical approximation to compute this integral and choose a large enough N to approximate
the sum.
3.2. 2D Wave Solution 7
Z tÏ
u(⃗
x, t ) = G(⃗ x 0 , t 0 ) d 2 x⃗0 d t 0
x , t ; x⃗0 , t 0 )Q(⃗
0
∂u ∂G
Ï · ¸
+ x 0 , 0)G(⃗
(⃗ x , t ; x⃗0 , 0) − u(⃗ x 0 , 0) x , t ; x⃗0 , 0) d 2 x⃗0
(⃗ (3.29)
∂t 0 ∂t 0
Z t ·I ¸
− c 02 x , t ; x⃗0 , t 0 ) −G(⃗ x , t ; x⃗0 , t 0 )∇x⃗0 u(⃗
¡ ¢
u(⃗ x 0 , t 0 )∇x⃗0 G(⃗ x 0 , t 0 ) · n̂ d l d t 0
0
∂u(r,θ,0)
This equation can be simplified for our problem. Using Q(⃗
x , t ) = 0, ∂t = 0 and the fact that we are using
the infinite domain we can reduce the equation to just:
∂G
Ï
u(⃗
x, t ) = − u(⃗
x 0 , 0) x , t ; x⃗0 , 0) d 2 x 0
(⃗ (3.30)
∂t 0
From [6] we know that the Green’s function for a 2D wave is given by (with r = |x − x 0 |):
0
r > c 0 (t − t 0 )
x , t ; x⃗0 , t 0 ) = G(r, t ; t 0 ) =
G(⃗ 1 1 (3.31)
q r < c 0 (t − t 0 )
2πc 0 c 2 (t − t )2 − r 2
0 0
∂G
Using properties of the Green’s function we can show that ∂t 0 = − ∂G
∂t from which we find:
1 ∂ 1
Ï
u(⃗
x, t ) = u(⃗
x 0 , 0) d 2 x⃗0 (3.32)
∂t
q
2πc 0 x −x⃗0 |<c 0 t
|⃗
x − x⃗0 |2
c 02 t 2 − |⃗
1 ∂ 1
Ï
u(⃗
x, t ) = u(⃗
x 1 +⃗
x , 0) q d 2 x⃗1 (3.33)
2πc 0 |x⃗1 |<c0 t ∂t
x 1 |2
c 02 t 2 − |⃗
1 1 1
G(r 1 , t ) = = Q(ξ) (3.35)
2πc 0 c 2 t 2 − r 2 2πc 0 r 1
q
0 1
c0 t
where ξ = and where:
r1
1
Q(ξ) = p (3.36)
ξ2 − 1
Using Q we find the following result using the chain rule:
∂Q dQ ∂ξ c 0 t dQ dQ r 2 ∂Q
= =− 2 ⇒ =− 1 (3.37)
∂r 1 dξ ∂r 1 r 1 dξ dξ c 0 t ∂r 1
From this we can rewrite the integral from a time derivative to a derivative in r 1 .
∂G 1 ∂Q 1 dQ ∂ξ 1 dQ 1 ∂Q
= = = =− (3.38)
∂t 2πc 0 r 1 ∂t 2πc 0 r 1 dξ ∂t 2πr 12 dξ 2πc 0 t ∂r 1
8 3. Linear Wave Behaviour
We can now enter this result in our integral to find the following equation.
1 2π Z c 0 t ∂ 1
Z q
u(r, θ, t ) = − u( r 12 + r 2 + 2r 1 r cos(θ1 − θ), 0)r 1 d r 1 d θ1 (3.39)
∂r 1 µ c t ¶2
s
2πc 0 t 0 0
0
−1
r1
q
q ∂u( r 12 +r 2 +2r 1 r cos(θ1 −θ),0)
1
Z 2π Z c 0 t u( r 12 + r 2 + 2r 1 r cos(θ1 − θ), 0) + r 1 ∂r 1
u(r, θ, t ) = sµ d r 1 d θ1 (3.40)
2πc 0 t 0 0 c0 t 2
¶
−1
r1
! −r 12 − r 2 − 2r 1 r cos(θ1 − θ)
r 12
Ã
r 1 r cos(θ1 − θ)
1− 2 − e 2σ2
1
Z 2π Z c 0 t σ σ2
u(r, θ, t ) = sµ d r 1 d θ1 (3.41)
2πc 0 t 0 0 c0 t 2
¶
−1
r1
r1r r1r
r 12
à !
− cos(θ1 −θ) r1r − cos(θ1 −θ)
1− e σ 2
− 2 cos(θ1 − θ)e σ2
σ2 σ
Z
1
Z c0 t 2π
u(r, θ, t ) = d θ1 d r 1 (3.42)
r 12 + r 2 sµ
2πc 0 t 0 0 ¶2
c0 t
e 2σ2 −1
r1
From [5] we know that the following holds for the modified Bessel function:
1
Z π si n(απ)
Z ∞
I α (x) = e xcos(θ) cos(αθ) d θ − e −xcosh(t −αt ) d t (3.43)
π 0 π 0
1
Z π
I 0 (x) = e xcos(θ) d θ (3.44a)
π 0
1
Z π
I 1 (x) = cos(θ)e xcos(θ) d θ (3.44b)
π 0
By substituting in θ = θ ′ + π and using cos(θ + π) = −cos(θ) we can find the following result. We also use that
I 0 (x) is an even function and I 1 (x) is odd.
Z 2π Z π Z 2π
e xcos(θ) d θ = e xcos(θ) d θ + e xcos(θ) d θ
0 0 π
Z π (3.45a)
′
= πI 0 (x) + e −xcos(θ ) d θ ′ = πI 0 (x) + πI 0 (−x) = 2πI 0 (x)
0
Z 2π Z π Z 2π
xcos(θ) xcos(θ)
cos(θ)e dθ = cos(θ)e dθ + cos(θ)e xcos(θ) d θ
0 0 π
Z π (3.45b)
′
= πI 1 (x) + −cos(θ ′ )e −xcos(θ ) d θ ′ = πI 1 (x) − πI 1 (−x) = 2πI 1 (x)
0
3.2. 2D Wave Solution 9
r 12
à !
r1r r1r r1r
Z c0 t 1 − σ2 I 0 ( σ2 ) + σ2 I 1 ( σ2 )
1
u(r, θ, t ) = d r1 (3.47)
c0 t 0 r 12 + r 2 sµ ¶2
c0 t
e 2σ2 −1
r1
Figure 3.1: 2D plot of the finite element solution to the 1-dimensional problem. For more information on the parameters of the plot see
table 8.1.
3.2. 2D Wave Solution 11
Figure 3.2: 2D plot of the finite element solution to the 2-dimensional circularly symmetric problem. For more information on the
parameters of the plot see table 8.2.
4
Finite Element Method for linear Wave
In this chapter we will use the Galerkin’s finite element method to solve the linear wave equation with the
following boundary and initial conditions in 2 dimensions.
1 ∂2 u
∇2 u − 2 2 = f on Ω
(4.1a)
c 0 ∂t
∂u(x, y, 0)
u(x, y, 0) = g (x, y) = h(x, y) (4.1b)
∂t
∂u(x, y, t )
u(x, y, t ) = 0 ∀t on ∂ΩD n = 0 ∀t on ∂ΩN
= ∇u(x, y, t ) ·⃗ (4.1c)
∂n
Furthermore it is given that ∂ΩD ∪ ∂ΩN = ∂Ω and ∂ΩD ∩ ∂ΩN = ;. Furthermore f is an arbitrary source
function that can depend on x, y and t .
1 ∂2 u
Ï Ï Ï
v∇2 u d x d y − v dx dy = v f dx dy (4.2)
Ω c 02 Ω ∂t 2 Ω
For 4.2 and 4.1a to be equivalent we need to have 2 conditions on our test functions v, namely that the test
functions need to be smooth and that v(x, y, t ) = 0 on ∂ΩD .
To simplify the equation 4.2 we will make use of Green’s first identity, which is based on the divergence
theorem and ∇ (v∇u) = v∇2 u + ∇v∇u.
∂u
Ï Z
¡ 2 ¢
v∇ u + ∇v∇u d x d y = v ds (4.3)
Ω ∂Ω ∂n
1 ∂2 u
Ï Ï Ï
− ∇v∇u d x d y − v dx dy = v f dx dy (4.4)
Ω c 02 Ω ∂t 2 Ω
12
4.3. Time Differentiation 13
Pη
Using these base functions we can approximate our solution u by u h (x, y, t ) = i =1 c i (t )φi (x, y) and let
our test functions equal the basis functions. By entering u ≈ u h and v = φ j into equation 4.4 we find the
following equation:
η η ·Ï ¸ 2
∂ ci
·Ï ¸
1 X
Ï
φi φ j d x d y φj f d x d y
X
− ∇φi ∇φ j d x d y c i − 2 = ∀j (4.5)
i =1 Ω c 0 i =1 Ω ∂t 2 Ω
1 ∂2
− S⃗
c (t ) − M c (t ) = ⃗
⃗ f (t ) (4.6)
2
c0 ∂t 2
c and ⃗
⃗ f are η × 1 vectors, since j goes from 1 to η. And S and M are η × η matrices, since i also ranges from 1 to
η.
∂2
c (t ) − c 02 ⃗
³ ´
c (t ) = M −1 −c 02 S⃗
⃗ f (t ) (4.8)
∂t 2
This equation can be solved using a multitude of solvers for second order system of ordinary differential
equations. It is also possible to solve this system by using the following system of first order equations, created
∂
using ∂t ⃗
c = σ:
∂⃗
c
Mσ = M (4.9a)
∂t
∂σ
c − c 02 ⃗
³ ´
= M −1 −c 02 S⃗ f (4.9b)
∂t
In this project we will directly solve the second order system by using Verlet integration.
∂2⃗ x
=p⃗(⃗x (t ), t ) (4.10a)
∂t 2
⃗
x (t 0 ) = ⃗
x0 (4.10b)
∂⃗
x
(t 0 ) = ⃗
v0 (4.10c)
∂t
One can now integrate over time by choosing a step size ∆t . The smaller the step size chosen, the smaller the
error and the longer the computation time. We will use the following notation in the future:
14 4. Finite Element Method for linear Wave
t ℓ = t 0 + ℓ ∗ ∆t (4.11a)
xℓ = ⃗
⃗ x (t ℓ ) (4.11b)
Using this notation we can write down the formula for Verlet integration.
x0 = ⃗
⃗ x0 (4.12a)
1
x1 = ⃗
⃗ v 0 + ∆t 2 p
x 0 + ∆t⃗ ⃗(⃗ x0 , t0 ) (4.12b)
2
x ℓ = 2⃗
⃗ x ℓ−1 −⃗x ℓ−2 + ∆t 2 p x ℓ−1 , t ℓ−1 )
⃗(⃗ (4.12c)
⃗
c i (0) = u(x i , y i , 0) = g (x i , y i ) ∀i (4.13a)
∂ ∂
⃗
c i (0) = u(x i , y i , 0) = h(x i , y i ) ∀i (4.13b)
∂t ∂t
cℓ = ⃗
We now find the finite element solution to the linear wave equation (using ⃗ c (t ℓ )) by using these initial
conditions and using equation 4.8.
c0 = ⃗
⃗ c (0) (4.14a)
∂ 1
c (0) − c 02 ⃗
³ ´
c1 = ⃗
⃗ c (0) + ∆t ⃗ c (0) + ∆t 2 M −1 −c 02 S⃗ f (t 0 ) (4.14b)
∂t 2
c ℓ−1 − c 02 ⃗
³ ´
ℓ ℓ−1 ℓ−2
⃗
c = 2⃗ c c
−⃗ + ∆t M2 −1
−c 02 S⃗ f (t ℓ−1 ) (4.14c)
Finite Element Method for Non-linear
5
Diffusion
Before solving the Westervelt equation we will solve the Non-linear Diffusion equation as an intermediate
step. In this chapter we will use an iteration procedure combined with the finite element method to solve the
non-linear diffusion equation in 2 dimensions:
∇2 u + αu 2 = f on Ω (5.1a)
u(x, y) = 0 on ∂ΩD (5.1b)
∂u(x, y)
n = 0 on ∂ΩN
= ∇u(x, y) ·⃗ (5.1c)
∂n
Here α is the constant of non-linearity. It is given that ∂ΩD ∪ ∂ΩN = ∂Ω and ∂ΩD ∩ ∂ΩN = ;. Furthermore f
is an arbitrary source function that can depend on both x and y.
For the weak form to be equivalent to equation 5.1a we need the same conditions on the test functions as
the previous section. To find the final weak form we again use the Green’s first identity 4.3.
Ï Ï Ï
− ∇v∇u d x d y + vαu 2 d x d y = v f dx dy (5.3)
Ω Ω Ω
c + α⃗
− S⃗ c) = ⃗
b(⃗ f (5.5)
c and ⃗
The vectors ⃗ f and matrix S are identical to equation 4.7. We define the η × 1 vector ⃗
b as (η denotes the
number of nodes): Ï
⃗b(⃗
c)j = φ j [u h (x, y)]2 d x d y ∀j (5.6)
Ω
15
16 5. Finite Element Method for Non-linear Diffusion
5.3. Iteration
We now want to solve this non-linear problem by iterating to a better and better solution. We will use the
Pη
index n to denote the current iteration. Filling in ⃗
c n and u n = i =1 ⃗
c in φi (x, y) into equation 5.5 gives us this:
c n + α⃗
−S⃗ cn) = ⃗
b(⃗ f (5.7)
with
Ï
⃗ cn)j =
b(⃗ φ j [u n ]2 d x d y (5.8)
Ω
By using the approximation [u n ]2 ≈ u n u n−1 we can rewrite the vector ⃗ c n ) to the following matrix vector
b(⃗
product:
⃗ c n ) ≈ N (⃗
b(⃗ c n−1 )⃗
cn (5.9)
with
Ï
c n )i , j
N (⃗ = φi φ j u n d x d y (5.10)
Ω
c 0 = −S −1 f
⃗ (5.12a)
c tnemp
⃗ = (−S + αN (⃗
c n−1 −1
)) f (5.12b)
n n−1
⃗
c =⃗
c c tnemp
+ ω(⃗ c
−⃗ n−1
) (5.12c)
The iteration will continue until either a maximum number of iterations is reached or the difference between
⃗
c n and ⃗
c n−1 is below a certain minimum difference.
6
Finite Element Method for Westervelt
In this chapter we will use the finite element method, the iteration from the previous section and Verlet inte-
gration to solve the Westervelt equation in 2 dimensions.
1 ∂2 u β ∂2 u 2
∇2 u − 2 2 +
= f on Ω (6.1a)
c 0 ∂t ρ 0 c 04 ∂t 2
u(x, y, t ) = 0 on ∂ΩD , ∀t
(6.1b)
∂u(x, y, t )
= ∇u(x, y, t ) ·⃗n = 0 on ∂ΩN , ∀t (6.1c)
∂n
u(x, y, 0) = g (x, y) on Ω (6.1d)
∂u(x, y, 0)
= h(x, y) on Ω
(6.1e)
∂t
Here β is the constant of non-linearity and ρ 0 is the material ambient density. It is again given that ∂ΩD ∪
∂ΩN = ∂Ω and ∂ΩD ∩ ∂ΩN = 0. Furthermore f is again an arbitrary source function that can depend on x, y
and t .
Again this is only equivalent to equation 5.1a when the test functions v(x, y) are sufficiently smooth and
v(x, y) = 0 on ∂ΩD . Now we can use Green’s Identity and our boundary conditions on u and v to write down
the weak form. " #
∂2 β 1
Ï Ï Ï
2
− ∇v∇u d x d y + v 2 u − u d x d y = v f dx dy (6.3)
Ω Ω ∂t ρ 0 c 04 c 02 Ω
c and ⃗
We can rewrite this again into an equation with matrices and vectors. Matrix S and vectors ⃗ f are iden-
tical to equation 4.7.
∂2
c (t ) + 2 ⃗ c (t ))¯t = ⃗
¯
− S⃗ q (⃗ f (t ) (6.5)
∂t
17
18 6. Finite Element Method for Westervelt
The vector ⃗
q can be calculated using this formula and is of size η × 1.
à !
β 1
Ï
h 2 h
⃗
q (⃗
c (t )) j = φj [u (x, y, t )] − u (x, y, t ) d x d y ∀j (6.6)
Ω ρ 0 c 04 c 02
β 1
qℓ = c ℓ )⃗
N (⃗ cℓ − cℓ
M⃗ (6.9)
ρ 0 c 04 c 02
Using equation 6.5 we can write down the Verlet integration step by filling in equation 4.12c.
q ℓ = 2⃗
⃗ q ℓ−1 − ⃗ c ℓ−1 + ∆t 2 ⃗
q ℓ−2 + ∆t 2 S⃗ f (t ℓ−1 ) (6.10)
We now wish to rewrite this into an equation for ⃗ c ℓ , since those are the function values we are looking for. To
ℓ
be able to do this we need to approximate ⃗ q . We will do this using a very similar approximation to section
5.3, but instead of the solution of the previous iteration step we will use the solution of the previous time step.
Using this result we can write down our Verlet integration by filling in our equations for ⃗ q into equation 6.10
and rewriting to ⃗c ℓ . For the initial ⃗
c 0 and ⃗
c 1 we will use the same equations 4.14a and 4.14b from the linear
wave equation.
à !−1 " #
β 1 2β 2 β 1
c ℓ−1 + ⃗
³ ´
ℓ ℓ−1
⃗
c = N (⃗
c )− M ∆t S⃗ 2
f (t ℓ−1 ) + c ℓ−1 )⃗
N (⃗ c ℓ−1 − 2 M⃗
c ℓ−1 − c ℓ−2 )⃗
N (⃗ c ℓ−2 + 2 M⃗c ℓ−2
ρ 0 c 04 c 02 ρ 0 c 04 c0 ρ 0 c 04 c0
(6.13)
6.4. Iteration
To reduce the influence of the approximation 6.11 we will use an iteration similar to section 5.3. The second
c ℓ,n denotes the nth iteration of the solution ⃗
index will be used to denote this iteration, so ⃗ c at time t ℓ . Using
ℓ
this notation our new approximation for ⃗ q becomes:
β 1
q ℓ,n ≈
⃗ c ℓ,n−1 )⃗
N (⃗ c ℓ,n − c ℓ,n
M⃗ (6.14)
ρ 0 c 04 c 02
6.4. Iteration 19
This iteration will continue until either a maximum number of iterations is reached or the difference between
c ℓ,n and ⃗
⃗ c ℓ,n−1 is below a certain minimum difference. When iteration is stopped we set ⃗ cℓ = ⃗
c ℓ,n and can
move to the next time step.
Thus our time Differentiation to the Westervelt equation consists of using equation 6.13 to compute the
next time step. Then iterating using equation 6.15 to refine the solution for this time step. Then we move to
the next time step and again iterate to refine the solution. This process is repeated until we have reached our
end time.
7
Implementation
This chapter will cover all information regarding the implementation of the previously discussed theory into
Python. We will first discuss how the mesh and its base functions were calculated and then go over and
element-wise approach to compute all the necessary matrices and vectors. This is then further improved into
a vectorized implementation. In the last section the implementation of the different boundary conditions is
discussed.
• A boolean list of equal size to the number of vertices. A "1" in the list on position i indicates that there
is a Neumann boundary condition between vertex i and i + 1. A "0" in the list indicates a Dirichlet
boundary condition.
• A float l c value that defines the target element size for the mesh.
The mesh is created by drawing a line from vertex through vertex in the order of the first list. Finally the path
is closed by going from the last vertex in the list to the first vertex. The space inside this line path is then used
to create the two dimensional mesh. The mesh is defined by these output variables.
• A coor matrix of size n_nod es × 2 with on each row the coordinates of the nodes.
• An elems matrix of size n_el ems × 3 with on each row the indexes of the three corner nodes of the
element.
• An i_bnd_dir list filled with the indices of the nodes on the Dirichlet boundary.
• An i_bnd_neu list filled with the indices of the nodes on the Neumann boundary.
By using these output variables we can compute all the necessary matrices and vectors for the FEM imple-
mentation.
• Each base functions should equal 1 in its corresponding node and should equal 0 in all other nodes.
20
7.3. Element-wise Computation 21
Since we want our base functions to be linear on each element we can describe our base function j on a
specific element as:
φj = a j x + b j y + c j (7.1)
Say we have an element e i , with its three corresponding nodes x⃗1 = (x 1 , y 1 ), x⃗2 = (x 2 , y 2 ) and x⃗3 = (x 3 , y 3 ). We
can then find the value of the three non-zero base functions on this element by solving this matrix product.
x1 y1 1 a1 a2 a3 1 0 0
x 2 y2 1 b 1 b2 b 3 = 0 1 0 (7.2)
x3 y3 1 c1 c2 c3 0 0 1
From this we find that the base functions on the element e i equal:
y2 − y3 x3 − x2 x2 y 3 − x3 y 2
φ1 = x+ y+ (7.3a)
∆ ∆ ∆
y3 − y1 x1 − x3 x3 y 1 − x1 y 3
φ2 = x+ y+ (7.3b)
∆ ∆ ∆
y1 − y2 x2 − x1 x1 y 2 − x2 y 1
φ3 = x+ y+ (7.3c)
∆ ∆ ∆
with ∆ = x 1 y 2 + x 2 y 3 + x 3 y 1 − x 1 y 3 − x 2 y 1 − x 3 y 2 (7.3d)
φ1 , φ2 and φ3 are the base functions corresponding to the nodes x⃗1 , x⃗2 and x⃗3 respectively. All other base
functions are equal to zero on this element.
∆
element is equal to 2. The values of the gradient can trivially be found from equations 7.3.
Î Î Î
∇φ1 ∇φ1 d x d y ∇φ1 ∇φ2 d x d y ∇φ1 ∇φ3 d x d y
Î e i Îe i Îe i
S e i = Îe i ∇φ2 ∇φ1 d x d y Îe i ∇φ2 ∇φ2 d x d y
Îe i
∇φ2 ∇φ3 d x d y
e i ∇φ3 ∇φ1 d x d y e i ∇φ3 ∇φ2 d x d y e i ∇φ3 ∇φ3 d x d y
(y 2 − y 3 ) + (x 3 − x 2 )2
2
(y 2 − y 3 )(y 3 − y 1 ) + (x 3 − x 2 )(x 1 − x 3 ) (y 2 − y 3 )(y 1 − y 2 ) + (x 3 − x 2 )(x 2 − x 1 )
1
= (y 2 − y 3 )(y 3 − y 1 ) + (x 3 − x 2 )(x 1 − x 3 ) (y 3 − y 1 )2 + (x 1 − x 3 )2 (y 3 − y 1 )(y 1 − y 2 ) + (x 1 − x 3 )(x 2 − x 1 )
2∆
(y 2 − y 3 )(y 1 − y 2 ) + (x 3 − x 2 )(x 2 − x 1 ) (y 3 − y 1 )(y 1 − y 2 ) + (x 1 − x 3 )(x 2 − x 1 ) (y 1 − y 2 )2 + (x 2 − x 1 )2
To calculate the element mass matrix and element N matrix we can use this approximation from [7] (page 16,
formula (39)).
n!m!p!
Ï
p
φni φm
j φk d x d y ≈ |∆| (7.4)
ei (n + m + p + 2)!
Where φi , φ j and φk are non-zero first order base functions on the element e i . Using equation 7.4 we can
directly compute the element mass matrix by setting p = 0 and using the correct values for n and m.
φ φ dx dy φ φ dx dy φ φ dx dy
Î Î Î
Îe i 1 1 Îe i 1 2 Îe i 1 3 2 1 1
|∆|
M e i = Îe i φ2 φ1 d x d y Îe i φ2 φ2 d x d y Îe i φ2 φ3 d x d y = 1 2 1 (7.5)
24
ei φ3 φ1 d x d y ei φ3 φ2 d x d y ei φ3 φ3 d x d y 1 1 2
To compute the element N matrix we need to use equation 5.10. This equation gives us this element
matrix Ne i .
φ φ un d x d y φ φ un d x d y φ φ un d x d y
Î Î Î
n
Îe i 1 1 n Îe i 1 2 n Îe i 1 3 n
c ) = Îe i φ2 φ1 u d x d y
Ne i (⃗ φ φ u dx dy
Îe i 2 2 n
φ φ u d x d y
Îe i 2 3 n (7.6)
n
e i φ3 φ1 u d x d y e i 3 φ2 u d x d y
φ e i φ3 φ3 u d x d y
To compute this element matrix we need to simplify u n . Since on element e i all base functions equal zero
except for the three base functions corresponding to the three nodes of that element, we can reduce u n to
c 1n φ1 + c 2n φ2 + c 3n φ3 . Here c 1n , c 2n and c 3n are equal to the values of ⃗
c n corresponding to the nodes x⃗1 , x⃗2 and
x⃗3 respectively. Using this we can compute the element matrix Ne i by summing over the following matrices.
c n ) = c 1n N1 + c 2n N2 + c 3n N3
Ne i (⃗ (7.7)
These three matrices can be computed using the quadrature approximation given in equation 7.4.
φ φ φ dx dy φ φ φ dx dy φ φ φ dx dy
Î Î Î
Îe i 1 1 1 Îe i 1 1 2 Îe i 1 1 3 6 2 2
|∆|
N1 = Îe i φ1 φ2 φ1 d x d y Îe i φ1 φ2 φ2 d x d y Îe i φ1 φ2 φ3 d x d y = 2 2 1 (7.8a)
120
e i φ1 φ3 φ1 d x d y e i φ1 φ3 φ2 d x d y e i φ1 φ3 φ3 d x d y 2 1 2
φ φ φ dx dy φ φ φ dx dy φ φ φ dx dy
Î Î Î
Îe i 2 1 1 Îe i 2 1 2 Îe i 2 1 3 2 2 1
|∆|
N2 = Îe i φ2 φ2 φ1 d x d y Îe i φ2 φ2 φ2 d x d y Îe i φ2 φ2 φ3 d x d y = 2 6 2 (7.8b)
120
e i φ2 φ3 φ1 d x d y e i φ2 φ3 φ2 d x d y e i φ2 φ3 φ3 d x d y 1 2 2
φ φ φ dx dy φ φ φ dx dy φ φ φ dx dy
Î Î Î
Îe i 3 1 1 Îe i 3 1 2 Îe i 3 1 3 2 1 2
|∆|
N3 = Îe i φ3 φ2 φ1 d x d y Îe i φ3 φ2 φ2 d x d y Îe i φ3 φ2 φ3 d x d y = 1 2 2 (7.8c)
120
φ φ
ei 3 3 1 φ d x d y φ φ
ei 3 3 2 φ d x d y φ
ei 3 3 3φ φ d x d y 2 2 6
Finally, we compute the element vector ⃗ f by first applying a Newton-Cotes rule and then approximating the
integral again using equation 7.4.
φ f (⃗ x 1 , t ) e i φ1 d x d y
Î Î
x1 , t ) d x d y f (⃗
Îe i 1 f (⃗
x1 , t )
|∆|
f e i (t ) = Îe i φ2 f (⃗ x 2 , t ) e i φ2 d x d y ≈
Î
x 2 , t ) d x d y ≈ f (⃗ f (⃗
x 2 , t ) (7.9)
6
φ φ
Î
ei 3 f x
(⃗ 3 , t ) d x d y f x
(⃗ 3 , t ) ei 3 d x d y f x
(⃗ 3 , t )
Secondly, cumulatively building up a sparse matrix by going element matrix by element matrix is a computa-
tionally intensive operation.
In this section we will instead attempt to compute all the matrices and vector through a vectorized im-
plementation. In the vectorized implementation we can use the fast linear algebra in the python package
Numpy.This approach is based on [8]. The goal is to compute a list of data d at a and two list of indices i and
j in such a way that S i [k], j [k] = d at a[k] for all k. Duplicate combinations of i and j are allowed and will be
added together in the python sparse matrix implementation. This allows us to create the full sparse matrices
on initialization.
Listing 7.1: Example of how the stiffness matrix is computed from the lists i , j and d at a.
In [8] it is shown how to compute the lists i , j and d at a to create the stiffness matrix. The list d at a
contains contains the values of the first element stiffness matrix from top left to bottom right followed by the
values of the second element stiffness matrix etc. This list is created in an efficient vectorized manner. The
lists i and j contain the correct indices corresponding to going over the element matrices one by one in this
manner. In these computations we will also use the list ar ea that contains the value of ∆ for each element.
The list ar ea is computed by taking a cross product.
ind_i = [ ]
ind_j = [ ]
for ind1 in range ( 3 ) :
for ind2 in range ( 3 ) :
ind_i . append ( ind1 )
ind_j . append ( ind2 )
c1 = coor [ elems [ : , 0 ] , : ]
d21 = coor [ elems [ : , 1 ] , : ] − c1
d31 = coor [ elems [ : , 2 ] , : ] − c1
area = np . cross ( d21 , d31 )
Listing 7.4: Computation of the list d at a for the stiffness matrix as was done in [8].
To efficiently compute the mass matrix we will use the same list of indices i and j . To get the list with the
data we will take the Kronecker product of the flattened indices of M e i and the ar ea list and divide the result
by 24. This directly gives us the correct d at a list to compute the mass matrix.
The largest bottleneck in the computation time is the computation of the sparse N matrix, since this needs to
be done for each iteration in each time step. Therefore the goal was to make this as efficient as possible. The
goal is to calculate the index lists i and j beforehand together with a matrix Nd at a that contains all constant
values of N1 , N2 and N3 for each element. The final data list could then be computed by simply multiplying
⃗
c n and Nd at a .
Listing 7.6: Computation of the list d at a for the N matrix from the vector ⃗
c and Nd at a .
For this to work the matrix Nd at a needs to be 3 dimensional. The first dimension denotes the position in
Nk from top left to bottom right. The second dimension denotes which element Nk is calculated. The last
dimension denotes which of the three Nk from 7.8 is used. In total Nd at a is of size 9 × n el ems × 3. This matrix
is computed by taking the matrix product of the indices of the three Nk and the ar ea list.
Listing 7.7: Computation of the Nd at a . The np.newaxis makes sure that the dimensions match up with what was described.
The index lists i and j for the N matrix can be computed by concatenating the i and j that were computed in
Listing 7.2 three times.
For each of these vectorized calculations it has been verified that the result is equal to the matrix found
by using the element-wise approach. By implementing these vectorized ways of computing the matrices the
computation time was greatly decreased. Previously the calculation time of the sparse matrices was the main
bottleneck of the finite element method. Now this only takes up around three percent of the total compu-
tation time. The current bottleneck is the solving of the sparse linear system that needs to be done at every
iteration. This takes up around 95 percent of the computation time for a fine mesh.
t − Td 2
· µ ¶ ¸
£ ¤
h(t ) = P 0 sin 2π f 0 (t − Td ) exp − (8.1)
T w /2
We will use the constants in table 8.1 in our calculation. They are similar to what was used in [3].
Using these values we can make a plot of the time dependent boundary condition. This function is a sinus
that oscillates with a frequency of f 0 . A Gaussian envelop is placed over the sinus to only have a pulse of
about six periods. This boundary condition is chosen because of the rapid oscillation from low pressure to
high pressure. The pulse that this creates is also very similar to ones used in practical ultrasound imaging for
medical applications.
25
26 8. Results
L
Figure 8.1: Plot of the mesh with a significantly larger element size (l c = 0.03m) and larger L y = 10x so single elements are visible. Interior
nodes are denoted by a black dot. The nodes on the Neumann boundary are red and the nodes on the Dirichlet boundary are blue.
Figure 8.2: Plot of the Time dependant boundary condition using the parameters given in table 8.1.
would be seeing multiple different pressure values for the same x-value in figure 8.3. To better compare the
finite element solution to the analytical solution we zoom in on the wave and plot the analytical solution over
it.
Figure 8.4 shows that the finite element solution is almost identical to the analytical solution. The finite
element solution seems to have a slight shift to the right. To take a better look at this error we can look at the
following plot.
Figure 8.5 shows how the error changes over time. We can see here that the error increases with the time
as was also seen in [3]. The increase in error can also partially be caused by reflections due to the wave getting
closer to the right boundary.
8.1. One Dimensional Wave Example 27
Table 8.1: Values for parameters used in finite element method for the one dimensional wave equation.
Figure 8.3: Plot of the finite element solution for four different time values.
Figure 8.4: Plot of the finite element solution and the analytical solution zoomed in on the wave.
Figure 8.5: Plot of the error between the fem solution and analytical solution for four different time values.
−r 2
· ¸
u(r, 0) = P 0 exp (8.2)
2σ2
For our parameters we will use values similar to what we used in the last section. All parameters that were
8.2. Circular Symmetric Two Dimensional Wave Example 29
Figure 8.6: Plot of the Westervelt finite element solution for four different time values.
Figure 8.7: Plot of the Westervelt finite element solution and the analytical solution zoomed in on the wave.
Figure 8.8: Plot of the difference between the fem solution and analytical solution for four different time values.
Figure 8.9: Plot of the mesh with a significantly larger element size (l c = 0.03m)so single elements are visible. Interior nodes are denoted
by a black dot. The nodes on the Neumann boundary are red.
seem to slightly increase with time. The error here is significantly smaller than in the one dimensional exam-
ple. In the plot we see that the error increases when the rate of change of the solution increases.
Table 8.2: Values for parameters used in finite element method for the circular symmetric wave equation.
Figure 8.10: 2D Plot of the initial condition using the parameters given in table 8.2.
Figure 8.11: Plot of the finite element solution for four different time values.
Figure 8.12: Plot of the error between the fem solution and analytical solution for four different time values.
6
u(x) = (8.3a)
(1 + x)2
3
u(0) = 6
u(1) = (8.3b)
2
As in section 8.1 we will use a rectangular domain to simulate a one dimensional wave. The mesh that was
used is almost identical to the mesh plotted in figure 8.1. The only difference is that both the left and right
side of the rectangle have Dirichlet boundary conditions. The parameters that were used for the Non-linear
Diffusion solution can be found in table .
In figure 8.15 the result of the finite element method is shown. The initial iteration step is a straight line
2
between the two boundary conditions. This is to be expected, since it is the trivial solution to ∂∂xu2 = 0. For
each iteration after the initial condition the solution is slowly moved to the correct analytical solution. In the
8.4. Mesh Size vs Error 33
Figure 8.13: Plot of the Westervelt finite element solution and the linear analytical solution for four different time values.
Figure 8.14: Plot of the difference between the fem solution and analytical solution for four different time values.
difference plot in figure 8.16 the decrease in the difference over the iterations can be seen.
ϵ = max(|⃗
c i − u ana (⃗
x i , t )|) (8.4)
i
Table 8.3: Values for parameters used in finite element method for the Non-linear Diffusion equation.
Figure 8.15: Plot of the finite element solution and the analytical solution to the Non-linear diffusion equation. Iteration 0 denotes the
c0.
initial solution ⃗
solutions. For the calculations we will use the same parameters as were used in tables 8.1 and 8.2. We will
only change the value of l c for both problems. We will solve the problem with the values of l c in the tables
multiplied by a scaling of between 100 and 1. These scaling values are spaced on a logarithmic scale. After
solving the problem we compute the error and plot the l c versus error ϵ on a logarithmic scale to find the
relation between them. For the finite element method we expect this to be a relation of the form ϵ ∝ l c 2 .
As can be seen in the figure there were a lot of points that show weird behaviour for the resulting error
of larger mesh sizes, especially for the one dimensional problem. In the 1-dimensional case the solutions
would become inaccurate for larger mesh sizes due to the oscillations in the wave happening faster then the
distance between nodes in the mesh. This causes some strange behaviour in the solution that leads to a kind
of averaging of the wave over the interval. Due to this behaviour the error decreases even though the solution
is not accurate. For this reason we choose to eliminate a large number of data points for the one dimensional
problem. For the two dimensional problem this behaviour takes longer to take shape since the Gaussian
curve is easier to approximate using linear elements. For larger values of l c this effect again occurs, but it is
less present than for the one-dimensional case.
From these two fits we found a relation of ϵ ∝ l c 1.56 and ϵ ∝ l c 1.66 from the 1-dimensional and 2-dimensional
cases respectively. These two relations are similar, which is what we would expect. However both of them are
lower than the quadratic relation that we expected. This is especially the case for the 1-dimensional channel
problem. It would be good to better estimate the one dimensional error fit by having more data points for
lower l c values. Unfortunately this was not possible, due to an error in the GMSH API.
My best guess for the cause of this error is that in the one dimensional case the mesh is very long and
thin, which causes the triangular elements to become very stretched out, especially as the element size de-
creases. When lowering the l c value too much the elements become so stretched out that GMSH can no
8.4. Mesh Size vs Error 35
Figure 8.16: Plot of the difference between the finite element solution and the analytical solution to the Non-linear diffusion equation
c 0 . The difference on the Dirichlet boundary nodes is not
with a log scale on the y-axis. Iteration 0 again denotes the initial solution ⃗
included in the plots since the difference is always zero.
Figure 8.17: Plot of the lc versus the error on a logarithmic scale. The red markers were used to designate points that were not included
in fitting the line. The plot includes two linear fits for the relation between the error and the mesh size.
longer differentiate between the two elements and an error occurs in GMSH.
The same procedure was used to analyse the relationship between the error and the element size for the
non-linear diffusion. The parameters were kept equal to the ones given in table 8.3. The l c is again scaled by
values between 100 and 1 on a logarithmic scale. This resulting logarithmic plot of the error can be found in
figure 8.18.
For this problem all the data points seem to follow the linear fit, although there is some more inaccuracy
for the higher element sizes. This is probably because the non-linear diffusion problem does not have an
initial or boundary condition that is hard to approximate with linear elements. From the linear fit we find
a relation of ϵ ∝ l c 1.98 , which agrees much better with our expectation of ϵ ∝ l c 2 . This leads me to believe
that the different relations that we found for the time dependant problems are related to the Verlet Time
36 8. Results
Figure 8.18: Plot of the lc versus the error on a logarithmic scale. The plot includes a linear fit for the relation between the error and the
mesh size.
Integration.
Figure 8.19: Plot of the time step versus the error on a logarithmic scale. For the solutions where the solution would become N aN , the
error has been plotted as the value 10250 .
8.5. Time Step vs Error 37
In figure 8.19 we see that the error explodes when the time step is too large. For the two dimensional
problem the implementation gives a solution which is incredibly large and thus the error is very large. For
the one dimensional channel the solution consists of N aN values. This is because the solution blows up
so much that the values pass the maximum float limit of python of 1.7976931348623157 × 10308 . When this
happens python returns "Not a Number"(N aN ). To still include these data points in the error plot they have
been plotted as the value 10250 . From this figure we can conclude that the convergence of the finite element
method depends on the time step used.
We will now plot only the values for which the solution converges and zoom in on the two error values for
the two different solutions.
Figure 8.20: Plot of the time step versus the error on a logarithmic scale. This plot includes only the values for which the solution
converges and has been split in two subplots for each solution.
The figure 8.20 shows that both solutions show the same relation between the time step and the error.
Unlike for the mesh size the logarithmic plot does not show a straight line. From this we can conclude that
the time step does not follow a relation of the form ϵ ∝ d t k to the error. The error decreases with the time step
until it plateaus, the error can then not decrease further unless decreasing the mesh size. This is because the
error caused by approximating the domain with a mesh can not be decreased by decreasing the time step.
9
Conclusion
In this thesis we found a way to compute the two dimensional Westervelt equation with the finite element
method. To do this we first had to solve the linear wave equation and the non-linear diffusion equation using
the finite element method. We found a way to iterate on each time step that allows us to approximate the
non-linearity in the Westervelt equation.
We were able to verify this finite element implementation by comparing it to the one dimensional work
of [3]. After which we also compared it to a two dimensional linear circularly symmetric solution. From this
we conclude that the finite element method can be used to solve the Westervelt equation in two dimensions.
The non-linear diffusion finite element solution was also verified by comparing it to the work done in [9]. We
have also shown that a faster vectorized implementation can be used instead of the element-by-element one.
The relation between the error and the mesh size was also analysed. For the time-dependant finite ele-
ment implementation the error was found to scale with around ϵ ∝ l c 1.7 . This value is below our expected
relation of ϵ ∝ l c 2 . For the non-linear diffusion equation the relation between the mesh size and error agrees
with our estimate, because it equals ϵ ∝ l c 1.98 .
When investigating the relation between the time step and the error we found that the convergence of the
finite element method depends on the time step used. Unlike the mesh size, the time step does not follow a
relation to the error of the form ϵ ∝ d t k . This is because the error stops decreasing when the time step gets
very small.
38
10
Discussion
In this research we focused on implementing the finite element method for two dimensional domains. All the
theory that was discussed in this thesis can be extended to three dimensional domains. This would make the
results more applicable to real life situations. The main work that would need to be done would be in chapter
7, where most of the calculations of the integrals would have to be changed.
The finite element implementation could be further improved by adding adaptive mesh refinement for
areas of large change in the solution values. This could greatly improve both the accuracy of the program
as well as the computation time. For example in the current implementation a large amount of computation
time is spend on the area of the domain the wave has not reached yet that is equal to zero. Another feature that
could be added is to add the option of non-zero Neumann boundary conditions to the code implementation.
For two dimensional finite element method it was verified that the results of the vectorized implementa-
tion gave equal results to the element-wise implementation. To quantify the improvement that this change
in implementation gave it would be good to do a more quantitative research of these changes on the compu-
tation time for different mesh sizes and time steps.
When looking at figure 8.4 we can see that the difference between the analytical and the numerical FEM
solution seem to be a slight shift to the right. This might be caused by one of the approximations we did when
applying the finite element method. It is also possible that the root of this shift is an error somewhere in our
theory or implementation that can be fixed. Further investigation would be required to figure this out. The
shift might be related to the way that the time dependent Dirichlet boundary is implemented, since it does
not seem to appear in figure 8.11.
In section 8.2 the differences between the analytical linear and finite element Westervelt solution are very
small. The value for the non-linearity constant that was used in this section β = 10 was the same one as used
in the section before it. In that section it did give very noticeable results. The reason that the non-linear
phenomena in this section were less noticeable is firstly because the wave oscillates less compared to the one
dimensional wave. The second reason is that the amplitude of the wave quickly decreases. It would be good
to increase the non-linearity constant in this section to better show the effects of the Westervelt equation on
the circularly symmetric problem.
When verifying the finite element implementation we mostly made use of linear reference solutions es-
pecially when calculating the errors. It would be good to further verify the non-linear finite element solutions
by comparing them to a non-linear reference solution. Unfortunately there are no analytical solutions to the
Westervelt Equation. Thus we would have to rely on a previously verified numerical solution from another
source to verify the implementation for non-linear problems. This would help to further proof that the theory
in this paper is correct.
The analysis of the mesh size vs error could be best improved by getting more data points for the 1-
dimensional problem. To do this the problem would need to be solved with smaller values of l c, which cur-
rently result in errors. By fixing the error one would be able to better approximate the relation by making a
better fit. The error could also be fixed by increasing the width of the channel, though this would also greatly
increase computation time. Another way to improve this section would be by getting more different reference
solutions to better confirm the relation between the error and mesh size.
Further research should be done into how the convergence of the finite element method relates to the
time step used. For this we would have to investigate the time step for which convergence stops for different
39
40 10. Discussion
[2] Hamilton, M. F. and Morfey, C.L., 1998. Model Equations in Nonlinear Acoustics edited by Hamilton, M. F.
and Blackstock, D. T., Chap. 3, p. 41-63, Academic Press.
[3] Zijta, M., 2017. Solving The Westervelt Equation With Losses Using First And Second Order Finite Element
Method, Delft University of Technology, Faculty of Applied Sciences & Faculty of Electrical Engineering,
Mathematics and Computer Science.
[4] Dirkse, B., 2014. Finite Element Method Appliet to the One-dimensionel Westervelt Equation, Delft Uni-
versity of Technology, Faculty of Applied Sciences & Faculty of Electrical Engineering, Mathematics and
Computer Science.
[5] Churchill, R.V., 1972. Operational Mathematics, 3rd edition, McGraw-Hill Book Company.
[6] Haberman, R., 2014. Applied Partial Differential Equations with Fourier Series and Boundary Value Prob-
lems, 5th edition, Pearson Education Limited.
[7] Segal, A., 2017. Finite element methods for the incompressible Navier-Stokes equations, Delft University of
Technology, Faculty of Applied Sciences & Faculty of Electrical Engineering, Mathematics and Computer
Science.
[8] Funken, S., Praetorius, D. and Wissgott, P., 2011. Efficient Implementation of Adaptive P1-FEM in Matlab
in Computational Methods in Applied Mathematics, Vol. 11., No. 4, pp. 460-490.
[9] Plaquevent-Jourdain, B., 2019. Méthodes d’analyse numérique pour la résolution d’équations différen-
tielles et aux dérivées partielles non-linéaires, Delft University of Technology, Faculty of Applied Sciences
& Faculty of Electrical Engineering, Mathematics and Computer Science.
41
A
Appendix
All code related to this project can be found in the GitLab repository at https://gitlab.com/leo.hendriks/
bep-fem/.
42