physics research summer2009
DESCRIPTION
Testing boundary conditions using MATLABTRANSCRIPT
Advection Non-trivial solutions to the advection equation (right-moving)
x
fv
t
f (1)
give a moving pulse, whose direction is determined by the sign of v. Positive v = right-moving.
f(x)
x
Figure 1
For arbitrary functions f, the solution to the advection equation is f(u), where u = (x - vt).
Proof:
t
uf
x
ufv
vdu
df
t
u
du
df
t
uf
du
df
x
u
du
df
x
uf
)()()(
)()(
)(
This solution works for all cases. yields a right-moving wave, and a left-moving
wave.
Consider Figure 1, where time advances with each graph from left to right. Notice that each
point on the curve is simply being dragged forward. If we mark two x values and their
corresponding f(x) values, the movement of the pulse along characteristic lines (lines along
which the function does not change) becomes apparent. Figure 3 is a contour plot for Figure 2
as it advances with time.
Figure 2 Figure 3
xb xa xb xa
t
x
t
Derivative Approximations
Forward Time Centered Space (FTCS) (Garcia 2000)
Consider a set of grid points with known x and f(x) values. We will say this set of data points
exists at time level t = , and denotes x at the ith place. The distance between points is equal
to Δ , and the duration between time levels is Δ .
What if we want to find information at another time level? (Figure 4)
?
Figure 4 known
We assume this data obeys the advection equation and estimate the function values at time
level t = using a forward time centered space approximation (FTCS).
Recall equation (1).
x
fv
t
f
The partial derivative on the right side of this equation can be approximated as
The partial derivative on the left as
Equating the two with the appropriate constant v yields
Solving for gives
The approximation of the space derivative is second order accurate by virtue of being a
centered derivative approximation. The approximation of the time derivative is only first order
accurate since it is a forward derivative approximation.
The computational molecule, which shows what points are used to approximate the value at
the desired point, for FTCS is
Figure 5
FTCS is unconditionally unstable. If allowed to run for long enough, an FTCS algorithm will
always blow up – infinities will start to show up in later time steps.
In most numerical methods for evolving hyperbolic partial differential equations, the stability of
the system is determined by the Courant factor. The courant factor is , or the ratio of
physical wave speed to the speed at which the algorithm propagates information.
Consider a physical light cone.
Figure 6
Only events within in the light cone can influence or be influenced by an observer at the origin.
For our purposes, the physical light cone of the wave is determined by the physical speed of the
wave. The numerical light cone is determined by the spacing of the grid on which function
x
t
values are known. For example, looking at the computational molecule for FTCS, you can see
that numerical light cone.
Figure 7
Computationally, the only information affecting the approximation of the function value at the
gray point is the information at the three black points. Consider a physical light cone mapped
onto Figure 7.
Figure 8
Here, the physical light cone is smaller than the numerical light cone because . Stable
approximations will have a numerical light cone bigger than a physical light cone, or a Courant
factor . Keeping with the physical light cone analogy (Figure 6), the computational system
can be understood heuristically as taking into account all possible physical influences.
However, recall that FTCS is unconditionally unstable, and will eventually blow up even when
this condition is satisfied.
To get an idea of the problems with FTCS, consider a simple situation such as when a Courant
factor is . Here, we would expect that this algorithm would essentially drag the pulse
along characteristic lines. This is not true for FTCS. Recall equation (2).
For a Courant factor , the algorithm becomes
Since we have provided the algorithm with a very simple system and are looking at a symmetric
situation that it should be able to handle easily, we should expect a rather clean-looking answer
like
In the case of equation (4), the wave is simply pulled along the characteristic line, which is what
should happen computationally when numerical and physical speeds are equal; however, this is
clearly not the case for FTCS. Although this is not a rigorous explanation for the fact that FTCS
is unconditionally unstable, it does show some of the issues with using FTCS, even when solving
very simple systems.
Lax (Garcia 2000)
Instead of using a known data point at and then adding the time derivative multiplied by
, the Lax method uses an average of the two points adjacent to at time level The
lax method uses the average of points to find the point at the next time step.
Figure 11
The Lax method includes a diffusion term, which acts as though it takes energy away from the
wave, preventing it from blowing up to infinity. As is expected, the Lax method becomes
unstable with large Courant factors, but it will also become unstable with very small Courant
factors. In the latter condition, the pulse dissipates rather quickly.
Centered Time Centered Space (Garcia 2000)
The Centered Time Centered Space method uses two initial time levels of data in order to get
centered derivatives that are second-order accurate in both space and time
Figure 9
From before
The derivative approximations are
And
n
Average
Solving equation (5) yields
Note that the computational molecule for CTCS is
Figure 10
If , we can assume within a reasonable uncertainty that = . Therefore, equation
(6) reduces to . This becomes exact if initial data ensures that .
Lax-Wendroff (Garcia 2000)
This method finds second derivatives, which it then uses to get to the next time step. Figure 12
provides a graphical representation of estimating second derivatives. The derivative is being
approximated at the center black point.
Figure 12
Consider a Taylor series expansion
The FTCS effectively truncates the Taylor series estimation at the term with the first-order
partial differential. Lax-Wendroff carries the estimation one term further in the expansion.
An alternative way of using the Lax-Wendroff method takes a lax step to an intermediate time
level and then “leaps” across that intermediate step to the desired value.
Figure 12
For each step in Figure 12:
1.
2.
3.
4.
5.
6.
Lax-Wendroff is essentially FTCS plus a diffusion term. Although the difference between FTCS
and Lax-Wendroff is basically a matter of an additional term, Lax-Wendroff is stable for the
Courant condition and is second-order accurate in both time and space. This method
does suffer from a dissipation problem similar to the Lax method. However, Lax-Wendroff is not
affected as greatly by this issue as Lax is.
1 2
Black dots = initial data
3 4 5
6
Iterated Crank-Nicholson (Teukolsky 2008)
The iterated Crank-Nicholson method makes a guess at the values of the next time step and
then improves the guess by averaging. This method is stable for 4n+2 and 4n+3 iterations
where
n = 0,1,2,3,… However, doing more than two corrections is not really helpful.
Consider the advection equation (1) without the velocity factor.
x
f
t
f
FTCS gives
Backwards differencing (which is unconditionally stable) gives
Crank-Nicholson averages these two methods.
The first iteration of Crank-Nicholson calculates an intermediate variable using FTCS:
Another intermediate variable is found by averaging
Then the time step is made using in an FTCS approximation
A two-step iteration is done the same way. After equations (9) and (10):
The time step is then made as in equation (12).
As shown by Teukolsky, 2008, Crank-Nicholson is stable for courant factors , or .
Upwind Method (Garcia 2000)
This method exploits the directionality of the wave by using only points that would trail the
wave (physically) in the calculations. One benefit of this method is that we need only provide a
boundary condition for the side of the computational domain away from which the wave
travels. The computational molecule for this method is
Figure 13
And its numerical light cone is
Figure 14
The algorithm for a right-moving pulse, obeying the advection equation is
At the left boundary, some known value is provided (e.g., constant at 0) at each time step.
Providing known values as boundaries is known as Drichlet boundary conditions. A right
boundary condition is not necessary as the wave will simply move off the edge of the
computational world – outgoing boundary condition. For a left-moving pulse, we would simply
need to mirror the points used (e.g., becomes the left-most point for a given set rather than
the right-most).
Beam-Warming (Dullemond and Kuiper 2008)
Whereas the upwind method only used two points at the previous time level (Figure 13), the
Beam-Warming method uses three.
Figure 15
The partial differential equation (PDE) for the Beam-Warming method looks something like
The second derivative term is a diffusion term, which acts as if it is taking energy away from the
pulse, preventing it from blowing up. The right-moving algorithm for this method is
Again, these points can simply be mirrored for a left-moving algorithm. Also, note that this
system requires boundary conditions for the two left-most points, whereas upwind only
needed a boundary condition for the one, left-most point.
Box Method
The Box method uses two points at the previous time step and one point on the current time
step in order to approximate a point at the current time step.
Figure 16
The PDE for the Box method is
The algorithm is
Recall that
n-1 i
So, the algorithm can be reduced to
Note the numerical light cone for this system
Figure 17
Because the light cone encompasses all previous points at all previous time levels, this system
should be stable even for very large Courant factors.
Wave Equation The simplest one-dimensional wave equation is
2
22
2
2
x
fv
t
f (19).
This equation has the solution f(u), where u = x + vt or x – vt.
Proof:
Show that f(u) where u = x + vt is a solution to equation 2.
1st partial
2nd partial
1st partial
2nd partial
The proof for u = x – vt is similar. Also, it has already been shown that characteristics have
velocities .
2
2
2
22
2
2
2
2
2
2
2
2
2
2
2
x
f
t
fv
du
fd
x
f
x
u
du
df
du
d
du
df
x
du
df
x
f
du
df
x
f
x
f
xx
f
vdu
fd
t
f
vt
u
du
df
du
d
du
df
t
vdu
df
t
u
du
df
t
f
Crank Nicholson and the Wave Equation
Recall the wave equation (19).
2
22
2
2
x
fv
t
f
In two-variable form, this equation is.
We can discretize this equation using Crank-Nicholson. However, we need two pieces of initial
data. Either and at one time level or at two time levels. For discretization, I will assume
the first situation, with known values at time level t = .
Note that here
Note that here
Boundary Conditions for the Wave Equation
From the section on approximating numerical derivative, the Upwind, Beam-Warming, and Box
methods are particularly useful for establishing boundary conditions.
When a wave is evolved forward in time numerically, the system doing the evolution loses
information at the boundaries of the domain over which the wave is being evolved.
Figure 18
Consider the wave equation (19)
2
22
2
2
x
fv
t
f
This equation has as a solution
The F term is the right-moving part of the wave and the G term is the left-moving part. These
two parts are independently both solutions of the advection equation (1).
Therefore, we can use the aforementioned methods for boundary conditions by forcing the
wave equation to obey the appropriate advection equation (left-moving or right-moving) at the
boundaries.
Numerical Domain
Time advances
Information lost at boundaries
Wave equation in Spherical Coordinates
The three dimensional wave equation in spherical coordinates is
The Laplacian in spherical coordinates is
If f=f(r,t)
The Laplacian reduces to
So
Note that at the origin, the term will be zero, because is 0 at the origin.
Boundary Conditions for the Wave Equation in 3-D
Outgoing Boundary
Recall that solutions to the wave equation (19) have left and right moving parts that obey the
advection equation. See equation (21), copied here.
However, the 3-D wave equation in spherical coordinates (24) has an additional term.
How can we use our out-going boundary conditions (Upwind, Beam-Warming, and Box) with a
3-D wave equation?
Let
That is to say,
Also, let
Where
Recalling that
Find that makes this work.
Now all we have to do is solve the ODE
Now,
Considering the previous boundary conditions, such as the box method, all that needs to
change is .
For example, the Box method algorithm (18) becomes
In short, obeys a simpler wave equation.
Boundary at the Origin
Find
At the origin
Consider the Taylor series
So, we can see that
Exploiting the fact that the wave is symmetric about the origin, the second derivative at the
origin can easily be approximated as
Figure 19
Also, by considering the Laplacian in Cartesian coordinates
Due to the spherical symmetry about the origin (r=0),
Therefore,
Discretizing the Wave Equation
CFL
At r = 0
At outer boundary
Where
Crank-Nicholson
Let
At r = 0
At outer boundary
Where