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

Heat equation order of accuracy (Crank-Nicolson)

  1. Jun 2, 2015 #1
    Hi,

    Let's consider the heat equation as [itex]\frac{\partial T}{\partial t}=\alpha \frac{{{\partial }^{2}}T}{\partial {{x}^{2}}}[/itex]

    In order to have a second accuracy system, one can use the Crank-Nicolson method as [itex]\frac{{{\partial }^{2}}T}{\partial {{x}^{2}}}\approx \frac{1}{2}\left( \frac{T_{i+1}^{k+1}-2T_{i}^{k+1}+T_{i-1}^{k+1}}{\Delta {{x}^{2}}}+\frac{T_{i+1}^{k}-2T_{i}^{k}+T_{i-1}^{k}}{\Delta {{x}^{2}}} \right)+O\left( \Delta {{t}^{2}}+\Delta {{x}^{2}} \right)[/itex]

    However, when the finite difference method is use with respect to time, usually a forward Euler method like [itex] \frac{\partial T}{\partial t}\approx \frac{T_{i}^{k+1}-T_{i}^{k}}{\Delta t}+O\left( \Delta t,\,\,\Delta x \right)[/itex]

    Does it make the entire system an accuracy [itex]O\left( \Delta t,\Delta {{x}} \right)[/itex] ? If so, why don't use a much simpler method like center difference [itex]\frac{\partial T}{\partial x}\approx \frac{T_{i+1}^{k}-T_{i-1}^{k}}{2\Delta x}+O\left( \Delta t,\,\Delta {{x}^{2}} \right)[/itex] instead of Crank-Nicolson ? Furthermore, if one wants to get a full 2nd order system, how could it be possible ?


    Thank you,
    Steven
     
  2. jcsd
  3. Jun 3, 2015 #2
    I use central difference on ##\partial/\partial{t}## but the stability condition stays the same. If you see the factors for ##T##, for ##\Delta{t}## larger than a limit, equation for ##T_{i+1}## give value raising up only.
     
  4. Jun 3, 2015 #3
    You are wrongly attributing aspects of the temporal discretization them to the spatial discretization. And I think this is why you're confused.

    Crank-Nicolson uses the temporal discretization: [itex] \frac{T_i^{n+1}-T_i^n}{\Delta t}=\alpha \frac{1}{2}\left(\frac{\partial^2 T^{n+1}}{\partial x^2}+\frac{\partial^2 T^{n}}{\partial x^2}\right) [/itex]

    This step is determines that the accuracy in [itex] \Delta t [/itex] is second order. There are two things to note. First, we have not yet discretized the spatial derivative. Second, a important part of this temporal discretization is that we average the right side of the equation over the n and the n+1 time step.

    The spatial discritization determines the accuracy in [itex] \Delta x [/itex]. Crank-Nicolson uses center difference, which is second order accurate, to approximate the spatial derivative: [itex]\frac{\partial^2 T}{\partial x^2}\approx \frac{T_{i+1}-2T_i+T_{i-1}}{2\left(\Delta x\right)^2}[/itex].

    Note that time doesn't even enter this approximation.

    As a general rule, changing the temporal discretization alters the accuracy in [itex] \Delta t [/itex], and changing the spatial discretization alters the accuracy in [itex] \Delta x [/itex].
     
  5. Jun 3, 2015 #4
    Ok if I do understand, Crank-Nicolson's order in space depends on how you approximate the spatial derivative and temporal is by definition an order of 2 because it's averaged. In my case it's true to say that C-N is O(Δt^2, Δx^2), but irrelevant to say that the order in the left side of the equation (dT/dt) is dependant of Δx.

    However, there's still some facts that I need to get straight.
    1- Why use C-N method over a simple centered spatial discretisation if center difference is also O(Δx^2)
    2- Is it a good idea to increase the order of accuracy over decreasing the time/space step size ? In my case I would like to have a quadratic order for time and space. How would it affect stability and convergence speed ?

    Thank you,
    Steven
     
  6. Jun 8, 2015 #5
    ...
     
  7. Jun 9, 2015 #6
    The temporal advance is 2nd order because that's what the math shows it to be. It's not a definition. There are multiple ways to "average" the RHS, and they will give you different orders of accuracy. Do you know how to calculate the accuracy of an approximation using Taylor series?


    I'm not sure I understand your point. C-N uses the standard centered difference to approximate the spatial derivative. One of the main advantages of C-N is that it is unconditionally stable.

    Again, I'm don't understand you question. C-N is second order (quadratic) in space and time. It is also unconditionally stable.

    Are you asking about methods that are cubic, quartic, or higher order accurate? There are a number of trade-offs to using higher order methods. Higher order methods can have more restrictive stability limits. The algebraic systems that result are harder to solve. Some problems benifit greatly form using higher order methods, while other problems see little benefit.
     
  8. Jun 9, 2015 #7
    The C-N method is unconditionally stable for the diffusion equation. This means that criterions like ## \Delta t < \Delta x^{2} ## does not have to be obeyed.

    Just to make matters more confusing, as far as wiki goes C-N is only the implicit time discretization. The spatial you are free to choose.
     
  9. Jun 9, 2015 #8
    Ok I get the fact that CN is unconditionally stable, but If i can reword my question to make it as easy as possible, if the left side is

    (1) [itex]\frac{\partial T}{\partial t}\approx \frac{T_{i}^{k+1}-T_{i}^{k}}{\Delta t}+O\left( \Delta t \right)[/itex]
    or
    (2) [itex]\frac{\partial T}{\partial t}\approx \frac{3T_{i}^{k}-4T_{i}^{k-1}+T_{i}^{k-2}}{2\Delta t}+O\left( \Delta {{t}^{2}} \right)[/itex]

    Using the same heat equation with CN method for estimating [itex]\frac{{{\partial }^{2}}T}{\partial {{x}^{2}}}[/itex].

    Will (2) improve the accuracy of the system and the stability ?

    The thing I didn't undestand in the first place was why to use (1) with CN since they have different order of accuracy. In this case, using (2) with CN should be better because we stay with all equation of order Δt^2.
     
  10. Jun 9, 2015 #9
    There are 2 parts to the temporal discretization of CN. The first part is the discretization of the time derivative. The second part is the time discretization of the right side of the equation. The accuracy and stability of the CN method depends on the specific choice of both discretization.
    There is a cancellation that occurs because CN picks a clever discretization of the right side of the equation. This cancelation allows CN to be 2nd accurate in time. You will never see cancellation if you ignore the temporal discretization of the right side of the equation.

    Do you know how to evaluate the accuracy and stability of a finite difference method applied to a particular ODE? I do not know offhand what will happen if you use equation (2) to approximate the time derivate. I suspect that you will not see a significant difference in the accuracy of the two methods. I hesitate to comment on the stability, but there's a chance that the stability is worse using equation (2) than it is using equation (1).
     
  11. Jun 9, 2015 #10
    Does CN is ONLY good with heat equation or it's still reliable for similar equation like
    [itex]
    \frac{\partial T}{\partial t}=\alpha \frac{{{\partial }^{2}}T}{\partial {{x}^{2}}}+\beta \frac{\partial T}{\partial x}
    [/itex]
     
  12. Jun 10, 2015 #11
     
  13. Jun 11, 2015 #12
    Well C-N is just an implicit solution method. I would imagine you could use it on pretty much any equation you like. For linear equations the implementation is fairly simple as well. Here is the wiki page about the solution of that equation
    http://en.wikipedia.org/wiki/Numerical_solution_of_the_convection–diffusion_equation

    Also for a more general framework you could look up operator splitting methods of which C-N is just a specific case.
     
  14. Jun 13, 2015 #13
    If you want bypass linear systems, you can use shooting methods starting from both bounds and ask same value and same 1st derivative on a meeting point. RK4 and Numerov algorithm works fine. For Scrodinger equation I use Numerov with 1% error area. It is faster and simpler than RK4.
    See this result
     
    Last edited: Jun 13, 2015
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Heat equation order of accuracy (Crank-Nicolson)
  1. Crank-Nicolson method (Replies: 14)

Loading...