You are on page 1of 39

Numerical methods for Maxwell’s equations Summer term 2014

Finite-difference method for the wave equation

Tobias Jahnke

Numerical methods for Maxwell’s equations

Summer term 2014

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Model problem
Wave equation on [0, 2π]

∂t2 u(t, x) = c 2 ∂x2 u(t, x) t ≥ 0, x ∈ (0, 2π)


u(0, x) = u0 (x)
∂t u(0, x) = v0 (x)

Periodic boundary conditions: u(t, 0) = u(t, 2π)


Dirichlet boundary conditions: u(t, 0) = a, u(t, 2π) = b

Finite-difference method (plus starting step)

ujn+1 − 2ujn + ujn−1 n − 2u n + u n


uj+1 j j−1
= c2
τ2 h2

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Exact solution for different boundary conditions.

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Exact solution for different boundary condition


Top: periodic boundary conditions
Bottom: homogeneous Dirichlet boundary conditions

1
0.5
0
−0.5
−1
0 1 2 3 4 5 6
x

1
0.5
0
−0.5
−1
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability condition

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n=0
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 10
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 20
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 30
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 40
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 50
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 60
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 70
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 80
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 90
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Stability

n = 100
1 τ c / h = 0.95167

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Same example with slightly larger time-step.

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n=0
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 10
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 20
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 30
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 40
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 50
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 60
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 70
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 80
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 90
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Instability

n = 100
1 τ c / h = 1.0535

0.8

0.6

0.4

0.2

−0.2
0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Accuracy

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Accuracy

If the solution is smooth and τ ≤ hc , then

max |u(tn , xj ) − ujn | ≤ C (τ 2 + h2 ) ≤ C 1


+ 1 h2

max c2
n=0,...,N j=1,...,m

0
10

−1
10
Maximal errors of approx-
10
−2
imations with different
choices of h and τ = r hc
−3
10 with fixed ratio r < 1.
error
−4
order 2
10 −3 −2 −1
10 10 10
h
If (h) = Chp , then log (h) = log(C ) + p log(h)


Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Dispersion

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Dispersion

1.5
t = 0, n = 0

0.5

−0.5

−1

0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Dispersion

1.5
t = 0.1, n = 10

0.5

−0.5

−1

0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Dispersion

1.5
t = 0.2, n = 20

0.5

−0.5

−1

0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Dispersion

1.5
t = 0.3, n = 30

0.5

−0.5

−1

0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Dispersion

1.5
t = 0.4, n = 40

0.5

−0.5

−1

0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Dispersion

1.5
t = 0.5, n = 50

0.5

−0.5

−1

0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Dispersion

1.5
t = 200, n = 20000

0.5

−0.5

−1

0 1 2 3 4 5 6
x

Tobias Jahnke Karlsruhe Institute of Technology


Numerical methods for Maxwell’s equations Summer term 2014

Finite-difference method for the wave equation

Tobias Jahnke

Numerical methods for Maxwell’s equations

Summer term 2014

Tobias Jahnke Karlsruhe Institute of Technology

You might also like