Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Nonlinear parabolic equations: finite difference method

  1. Jan 3, 2009 #1
    To the moderator: please move this to the section on differential equations if you think it would be better there.

    I'm looking at a reaction-diffusion equation of the form

    [tex]\frac{\partial u}{\partial t} = \frac{\partial^2 u}{\partial x^2} + f(u),[/tex]

    where, e.g., [tex]f(u) = u(1-u)[/tex] for the Fisher-Kolmogorov eqation, and I'm assuming the spatial domain is the unit interval with Neumann boundary conditions:

    [tex]\frac{\partial u}{\partial x}(0, t) = 0, \; \frac{\partial u}{\partial x}(1, t) = 0, \; t\geq 0.[/tex]

    To keep things totally simple, I'm using the backward Euler method. When the original equation is just the heat equation, i.e., [tex]f = 0[/tex], this method just involves solving a simple matrix equation,

    [tex]BU^{n+1} = U^n,[/tex]

    for evolving the solution from time step n to n+1. The matrix of course depends on the boundary conditions. The nonlinear version of Euler's method involves a nonlinear multi-variable equation:

    [tex]BU^{n+1} + F(U^{n+1}) = U^n,[/tex]

    which can be solved for each time step using Newton's method.

    Where I'm getting confused is: exactly how do I incorporate the boundary conditions when deriving the system of nonlinear equations? My reasoning tells me that they should be the same as for the linear equation, i.e., the matrices B are the same for both the linear and nonlinear systems.

    My solver works perfectly for the heat equation with Neumann conditions, but gives only garbage for the Fisher-Kolmogorov equation after the first time step (if it converges at all). I'm convinced that the problem is not a bug in programming Newton's method. Anyway I'm using a library for that, and I've checked the functions I've supplied a thousand times already. Anyone here have experience with nonlinear parabolic equations? They're not the kind of thing that's typically covered in basic numerical analysis texts.
  2. jcsd
  3. Jan 3, 2009 #2
    Can you show your equations you used for the boundary nodes?Also for inner nodes?i can check them for you.
    How i do it is, use central diff to discretize bc's. You solve for the imaginary nodes (for 0, its one right outside say 0-, for 1 its 1+). Then you write the discrete form of the PDE then plug in the values for 1+ in terms of 1- and 0- in terms of 0+ (they are equal for your bcs). I used central diff because its 2nd order accurate in x, like the discrete form for the second derivative.I don't know if f(u) creates some weirdness but i dont think so, its a pretty well behaved function.
    Also i use the link below, they have analytical solutions for many types of pde's. You can use that to verify your calculations.

  4. Jan 4, 2009 #3
    I'm using FD equations at the boundary nodes exactly like you describe: "central difference" because it's 2nd order accurate. The discretization matrix looks like:

    [tex]A =
    -2 & 2 & 0 & \ldots \\
    1 & -2 & 1 & 0 & \ldots \\
    0 & 1 & -2 & 1 &\ldots
    \end{pmatrix}, [/tex]

    and I assume you know the rest. Writing [tex]U^n = (U_0^n,\ldots,U_m^n)^T[/tex] for the approximation at the n-time step, the backward Euler method for the heat equation is:

    [tex]\frac{U^{n+1} - U^n}{k} = h^{-2}AU^{n+1},[/tex]

    which becomes

    [tex](I - (k/h^2)A)U^{n+1} = U^n.[/tex]

    The matrix [tex]I - (k/h^2)A[/tex] is what I'm calling [tex]B[/tex]. According to my reasoning, the nonlinear equation involves a function [tex]F:\mathbf{R}^{m+1}\to \mathbf{R}^{m+1}[/tex] yielding a nonlinear backward Euler method:

    [tex]\frac{U^{n+1} - U^n}{k} = h^{-2}AU^{n+1} + F(U^{n+1}).[/tex]

    In the case of the Fisher-Kolmogorov eqn., [tex]F_i(U) = U_i(1-U_i)[/tex] in each coordinate. Again, I haven't found this in any books, but it's the most obvious thing to do. The system of equations I have to solve in each time step is:

    [tex]BU^{n+1} -kF(U^{n+1}) - U^n = 0;[/tex]

    sorry for changing my notation from my first post a little. I have to supply the left hand side together with its Jacobian to the nonlinear solver. Here the "current" time step [tex]U^n[/tex] is treated as a constant. The Jacobian of the LHS is [tex]B - kF'[/tex], where the Jacobian [tex]F'[/tex] is the obvious diagonal matrix.

    So far so good?

    For Newton's method I'm using the multi-root solver in the GNU Scientific Library http://www.gnu.org/software/gsl/. For my initial condition I'm using a Gaussian,

    [tex] u_0(r) = \exp(-(r-0.5)^2/\sigma^2),[/tex]

    with [tex]\sigma[/tex] chosen so that the function is basically flat at the endpoints [tex]x_0 = 0[/tex] and [tex]x_m = 1.[/tex] The solution I'm getting for the first time step clearly violates the boundary conditions, and taking this [tex]U^1[/tex] as a starting point, the solver doesn't even converge for the second time step.

    The logical explanation is that I've done something wrong with the nonlinear solver, and I'll be embarrassed for wasting everyone's time if that turns out to be the case. But I've reexamined that code so often by now, I'm starting to entertain the idea that I've missed something subtle with the boundary conditions for the FD equations.

    Thanks for your help in this matter!

  5. Jan 4, 2009 #4
    It seems fine to me. one issue with newton's method is you should be close enough to the root, otherwise it might not converge. maybe you might change the IC, if its ok, to something that satisfies the BC's also. then the guess values(the prev values) might be closer to the solution.
  6. Jan 4, 2009 #5
    Ah one more thing.first, you can evaluate the nonlinear terms in the current time step, solve the system with regular gauss elimination. Then use those values as the initial guess for the solution of the original equations where the nonlinear terms are evald in the forward time.
  7. Jan 5, 2009 #6
    Hi Emreth,

    I said in my last post that the initial condition u_0 is "basically flat at the endpoints." Thinking that that may be the problem, I modified it to satisfy the Neumann BC's exactly: to no avail. The same problem persists.

    My starting guess for finding [tex]U^{n+1}[/tex] with Newton's method is (the logical choice) [tex]U^n[/tex] itself. The time step [tex]k[/tex] I'm using is so small that the evolution should be tame. I know how solutions of the Fisher-Kolmogorov equation behave, and behavior of my numerical solution on the interior of the domain agrees with that. The problem is just at the boundary, most notably at [tex]x_0 = 0.[/tex]

    Thanks too for the tip on solving the linear part of the system forward in time to get a better initial guess for the nonlinear equations. I'll take a look at that later and get back to you.

  8. Jan 5, 2009 #7
    problem evidently resolved

    It looks like I've found the problem, indeed a bug: a typo among variable names in initializing the system. Ludicrous how something like that can "emulate" a numerical error, especially ludicrous when considering how much time I spent looking for it! Thanks anyway to everyone who at least skimmed through the thread or thought about the problem.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook