Homework due Wednesday 4/14
Please come see me or send me e-mail if you're
having any problems mathematically, computationally, or
otherwise.
Solving the heat equation with non-constant diffusion
Consider the equation on [0,2*pi]
u_t = (a(x) u_x)_x
where a(x) = 1 + eps*sin(x). This is a heat equation with
non-constant diffusion. Consider eps between 0 and 1. Intuitively,
how do you expect the diffusion constant will affect things?
Modify your Crank-Nicolson to code up this equation. Use either the
finite-difference code or the spectral code. Make sure that your code
was working before you modify it. If you need a working code to
cannibalize, get one from Natasha (rojkovsk@math).
If you did
the spectral case, demonstrate that your code is working correctly by
showing that it's O(dt^2) in time. If you did the finite difference
case, demonstrate that your code is working correctly by showing that
it's O(dt^2) in time and O(dx^2) in space. In both cases, check that
it's right for the eps=0 case by comparing your solution to a known
exact solution. You have to check the O(dt^2) and O(dx^2) stuff with
eps not equal to zero. In this case you don't know the exact
solution and you'll have to figure out how to check the convergence
when you don't know the exact solution.
Now that your code is
working, choose various initial data that interest you and run the
code with different values of epsilon. Present evolution plots
demonstrating that it's behaving as you expected.
Solving the Burger's equation
On the web-page, I've provided a leap-frog code for Burger's equation.
Modify this code to include diffusion.
u_t = eps u_xx -(u^2)_x/2 = L(u) + N(u)
where L is linear and N is nonlinear.
Treat the diffusion in a Crank-Nicolson way:
(u_{i,j+1}-u_{i,j-1})/(2 dt) = eps/2 (u_xx)_{i,j+1} + eps/2
(u_xx)_{i,j-1} + N(u)_{i,j}
Now write a separate code
where you compute Burger's equation explicitly:
(u_{i,j+1}-u_{i,j})/(dt) = eps (u_xx)_{i,j} + N(u)_{i,j}
From class, if eps is small then a time step dt and space step dx that
were originally okay may become too large.
Choose initial
data and run the two codes head-to-head. That is, with the same
time-step, the same space-step, the same eps, and the same final time.
Plot their power spectra at different times on the same plot
(crank-nicolson: solid, explicit: dot-dash). Demonstrate that the
explicit code can become unstable. And demonstrate the effect of this
instability on the solution itself.
With my code, do a number of runs with a range of eps to demonstrate
to yourself the effect of eps on the evolution of the power spectrum
and
on the evolution of the solution.