PHYS 307:  Computational Physics Lab (QM)

Winter 2008

Homework #5
(Due:  March 4, 2008)




  1. (Exercise 7.1) Use the explicit differencing scheme discussed in class:

    \begin{displaymath}
u_j^{n+1} = u_j^n + \alpha\,(u_{j+1}^n-2u_j^n+u_{j-1}^n\,,
\end{displaymath}

    where $\alpha = D\Delta t/\Delta x^2$, to solve the diffusion equation. The goal is to reproduce a portion of the fundamental solution. Take the diffusion coefficient to be $D=1$ and work on a uniform grid of 201 points running from $x=-10$ to $x=10$. Start with the fundamental solution at time $t=1$ and integrate the system forward in time to $t=2$ in steps of size $\Delta t$. Plot your solution at $t=2$ for $\Delta t = 0.004, 0.005, 0.0051$, and $0.0052$.

  2. Differencing the diffusion equation

    \begin{displaymath}
\frac{\partial u}{\partial t} = D \frac{\partial^2 u}{\partial
x^2}
\end{displaymath}

    using the Crank-Nicholson scheme leads to the following relation between the new ($u_j^{n+1}$) and old ($u_j^n$) values of $u$ [where $x_j = j\Delta x$, $t_n = n\Delta t$, and $u_j^n\equiv u(x_j, t_n)$]:

    \begin{displaymath}
-{\textstyle\frac12}\alpha u_{j-1}^{n+1} + (1+\alpha)u_j^{n...
...n + (1-\alpha) u_j^n
+ {\textstyle\frac12}\alpha u_{j+1}^n\,,
\end{displaymath}

    where $\alpha = D\Delta t/\Delta x^2$. By considering eigenmodes of the form

    \begin{displaymath}
u_j^n = \xi_k^n e^{ikj\Delta x}\,,
\end{displaymath}

    where $k$ is an integer (and $\xi^n$ means $\xi$ to the $n$-th power!), prove that the scheme is stable, in the sense that $\vert\xi_k\vert <
1$ for all $k$.

  3. (a) Repeat problem 1 using the implicit differencing scheme

    \begin{displaymath}
u_j^{n+1} = u_j^n + \alpha\,(u_{j+1}^{n+1}-2u_j^{n+1}+u_{j-1}^{n+1}\,,
\end{displaymath}

    plotting your solution at $t=5$ for $\Delta t = 0.1, 0.05$, and $0.01$.

    (b) Use the Crank-Nicholson scheme with $J=501$ to solve the diffusion equation with $D=1$, starting from the fundamental solution at time $t = 0.1$ and taking $\Delta t = 0.05$. Plot the numerical and the analytic solutions on the same graph for $-10<x<10$ at times 0.5, 1, and 5.

  4. Now modify your program to include a heat source in $-0.5 < x
< 0.5$ by adding a source term $s(x)$ to the right-hand side of the diffusion equation, where $s(x) = 2$ for $x$ in the above range, and $s(x) = 0$ otherwise.
    1. Start with $u = 0$ everywhere and take $D=1$.
    2. Recompute the difference equation from the modified differential equation to take the additional term into account.
    3. Set the boundary conditions to keep $u = 0$ at the ends of the range.
    4. Set $\Delta t = 0.05$.
    5. Integrate from t = 0 to t = 10.
    6. Plot the numerical solution at $t = 1, 2, 5, 10, 50$.
    7. Can you explain the long-term behavior of your solution?





Steve McMillan 2008-02-19