Intra Week 3
Intra Week 3
I am combining the work i did in week 3 and 4 into one entry to save me writing as much.
Recall in week to i wrote my first script in C to solve the 1D viscous burgers equation in C.
using the 2nd order Lax Wendorff numerical method for advancing in space and simple first
order Euler time stepping. In week 3 i sought to take a step back and really try to understand
the mathematics behind the numerical schemes and more importantly the physics behind the
actual PDEs themselves. So if we look at burgers equation, what is it? Burger’s equation is a
hyperbolic 2nd order PDE whose physics is described by convection and diffusion. It is
commonly referred to as the convection-diffusion equation. So i sought to explore both of
these separate phenomena by writing separate scripts for both convection and diffusion and
seeing how they behaved.
Before i even get into that we need to look at the class of methods that i am using to solve
these PDEs numerically. I haven’t touched on this in my previous reports so no seems like a
good time. I was using the finite difference method to solve these PDES. The finite difference
method is a class of method that work by using a series of Taylor expansions to approximate
the derivatives in PDEs to define a numerical scheme. If we generate a evenly spaced
numerical grid (can be achieved with a landscape array) with very small spacing (dx)
between the grid elements we can, along with the help of some known initial condition derive
using derivatives various numerical schemes that are discretised approximations of the the
PDE at each node or element in our gird.
The above image is a simple representation of such a finite difference mesh or grid. It has a
few important properties we must understand. Firstly, it is a structured cartesian grid meaning
grid spacing is uniform. Each grid point acts as the axis of a local coordinate system. Grid
lines of the same families do not intersect e.g. ( i ,i )and grid lines of different families intersect
only once e.g (i , j). If we know (i , j) then we can determine every other node using these
finite difference methods. Each node has one unknown value for an algebraic equation that
can be solved and transposed to yield an update equation that can advance the solution in
time and space. This unknown depends on neighbouring nodes.
There are many different schemes we can use to do this some of which are more accurate
than others. Three main schemes we will look at are, backward differencing, forward
differencing and central differencing approximations. These schemes work off of the
definition of a derivative. Recall
∂u
=lim ¿ ¿ ¿ ¿
∂ x n→∞
Derriving these methods depends upon the method we use to estimate the derivative of the
curve or in other words the slope of the tangent to the curve. The difference in the backward,
forward and central difference schemes are shown below with graphs.
As we can see a backward difference scheme use information from the current and previous
points on the curve to calculate the future point. The forward difference scheme uses
information on the current and forward point to calculate the future point and a central
difference uses information on both the forward and previous points to estimate the future
point. Central differencing schemes are much more accurate.
So recall that the finite difference method is based off the definition of a derivative and on
Taylor expansions. So, if we begin by considering a Taylor series expansion u ( x ) near x i
n
∂ u ( x¿ ¿i−x ) ∂u 2 ( x i−x ) ∂n
u ( x )=u ( x i )−( x i−x ) +
∂x 2! ( )∂x 2
+…+
n! ( )
d xn
¿
By replacing ( x) with ( x i−1) or ( x i+1 ) we can derive the forward, backward difference and
central difference schemes
BD:
∂ u ( ui−ui −1 ) ∆ x ∂ 2 u ∆ x 2 ∂3 u
( )
∂x
=
∆x
+ ( )
2 ∂ x2
−
6 ∂ x3 ( )+ …+ H .O . T
FD:
∂ u ( ui+1 −ui ) ∆ x ∂2 u ∆ x 2 ∂3 u
( )
∂x
=
∆x
− ( ) ( )
2 ∂ x2
+
6 ∂ x3
+…+ H . O .T
CD:
∂ u ( ui+1 −ui−1 ) ∆ x 2 ∂3 u
( )
∂x
=
2∆ x
− ( )
6 ∂ x3
+ …+ H . O .T
The power of ( ∆ x ) for which the truncation error tends to zero is called the order o accuracy.
For backward and forward difference schemes the order of accuracy is O( ∆ x ) and for the
central difference scheme the order of accuracy is O(∆ x 2 ). Now that we have an idea of the
finite difference method and various schemes such as forward/backward and central
differencing we can look at both convection and diffusion.
∂u ∂u
+ c =0
∂t ∂x
The above equation is the simple 1D linear convection equation. It is given as the partial
derivative of the quantity (u) which is some transported quantity, over time plus the partial
derivative of u over x times some transport velocity c. In the case of the linear convection
equation c is constant. To solve this equation i used a simple first order backward difference
scheme. The initial and boundary conditions are given below. This equation describes
movement in a gas or liquid in which the warmer parts move up and the cooler parts move
down. The generated by my C program are given below.
We can see that the linear Convection PDE has the effect of transporting our quantity (u)
horizontally where the velocity is defined by (c ) and is constant. In my program the velocity
is given as 1m/s. There is important analysis we can do on this equation such as on the order
of accuracy and the courant number. But that can wait for a few weeks since I had not done
any of that back in week 4. For now, just note that our solution is well behaved but highly
diffused.
The second equation that I looked at in week 4 was the 1D Diffusion equation. The diffusion
equation is slightly more complex than the 1D convection equation but we can learn much
more from it. The equation is given below.
∂u ∂2 u
=v 2
∂t ∂x
Notice now how we are dealing with a second order term namely on the right-hand side of
the equation. To discretise this term, we need to apply everything we’ve learned so far.
Second order derivatives are basically the slopes of the tangent line of the first derivative. We
can approximate dudx at two locations to get the approximation for the second order
derivative. We can discretise the 2nd order partial derivative by combining both backward and
forward difference for the first derivative. Let’s consider the Taylor expansion
∂u ∆ x ∂2 u ∆ x2 ∂3 u
ui−1=u i+ ∆ x ( ) ( )
∂x
+
2 ∂ x2
+
6 ∂ x3 ( )
+ …+ H . O .T
∂u ∆ x ∂2 u ∆ x 2 ∂ 3 u
ui +1=ui−∆ x ( ) ( )
∂x
+
2 ∂ x2
−
6 ∂ x3 ( )+ …+ H .O . T
We now add the above FD and BD Taylor expansions and by doing so all of the odd terms
will cancel out due to the opposing signs. Thus we are left with:
∂2 u ( ui+1−2 ui +ui−1 )
( )
∂x
2
=
2∆x
2
−O( ∆ x)
And this is our second order central difference approximation for the higher order term in the
diffusion equation. Before we talk about the results and plots lets talk a bit about the diffusion
equation some more since its important phenomena. Diffusion is known as the heat equation
and when its applied to temperature, exact solutions are known for constant values of the
parameter ( v) which is the viscosity. We can consider looking for a solution.
u=ú ei ( kx−ωt )
This equation represents a wave of some amplitude ¿, wavenumber (k ) and (ω=2 πf ) where
( f ) is the frequency. If we introduce this on the PDE, we obtain the relation:
iw=v k 2
Which leads to the exact solution of the diffusion equation given by:
2
u=ú ei kx e−v k t
This represents the behaviour of a wave in space which is exponentially damped in time due
to the diffusion coefficient ( v). ( v) must be positive for this to describe physical diffusion, if
it is negative the equation would represent and exponentially growing phenomena. This form
of diffusion can describe the flow of money from the rich to the poor. (concentration of
wealth). So, to recap pure diffusion represents an exponentially damped wave. The physics of
diffusion is isotropic. The finite difference that best represents diffusion is a central
difference approximation.
Finally, the results from my diffusion program are given below. Lets see how it looks
compared to the convection plot above.
We can see that unlike the convection equation this equation does no move along the x
direction. Instead the curve becomes more and more diffused over time. If we let this graph
run for a much longer time the peak of the curve would get lower and lower. Again well
discuss order of accuracy and stability in the coming weeks.
That sums up the work I did in week 3. A lot of numerical analysis more specifically into the
schemes used to solve hyperbolic PDES. Next week well combine these two equations to
solve what’s known as the 1D viscous burgers equation, or the convection diffusion equation