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

Numerical method for a heat diffusion problem

  1. May 11, 2012 #1
    Hello everyone!

    I hope you may be able to shed light on a recent problem that i have to deal with.

    I keep working on a numerical solution on a heat diffusion problem. It is a numerical solution for the PDE
    θT/θt=a*(θ^2T/θx^2 + θ^2Τ/θy^2),

    that describes the heat diffusion on a two dimensional problem. The numerical method is Crank-Nicolson and says that every point's temperature of the mesh, is given by the temperature of the four points surrounding it and by the temperature of these points on the previous time point. ( i guess you are familiar with all these, but i'm writing them just in case...)
    So i use a dx,dy mesh and i also use a time step as a dt, to describe a heat diffusion proccess on an aluminium plate. The problem started when i tried to use shorter dx,dy spatial divisions!The results in matlab's workspace were "NaN". The solution was to use a shorter time step. When the time step was short enough my results became the expected! The algorithm was written in MATLab.
    Here are my questions and my problem!
    My professor at the university, that i am working these algorithms for, claims that he can have results, from an algorithm written in FORTRAN, by not depending on the time step. In fact he did never mentioned anything about the dependence of the time step. And he really sent me some results, close enough to my results, that were calculated with a time step longer than mine(0.01 against 0.008 which is the longer i can use).How can this be possible?
    I found and sent him a page on wikipedia about the "CFL condition". The answer was that it refers on hyperbolic PDEs while our equation is parabolic.
    But there is something more important for me. Here is my real problem. While i get the mesh larger by using shorter dx,dy i use shorter time step "dt". That means more calculations because i use more points. And also much more calculations to go further on the diffusion proccess, due to the short time step (i need 100000 iterations to get results for the 800th second with dt=0.008s). My matlab algorithm takes about half an hour for 2000 iterations!!! Pretty disapointing! Again my professor says that he needs about a minute for most of the calculations. My computer is a notebook Toshiba, 1GB RAM and 1,66GH processor. (my algorithm is about 120 lines, pretty simple i believe!). Whould it be much better if i wrote my code in FORTRAN? I am not familiar enough with this language.

    Thanks a lot for your time!!
  2. jcsd
  3. May 11, 2012 #2


    User Avatar
    Science Advisor
    Homework Helper

    It doesn't matter what programming language you use. There mustbe a mistake in either your algorithm or your code. The Crank-Nicholson method should be unconditionally stable, so you shouldn't be getting NaNs for any time step.
  4. May 12, 2012 #3
    You are right AlephZero! It is not Crank-Nicolson 's matter.

    The problem is on the iterative Gauss-Seidel process.
    The type Crank-Nicolson uses the four surrounding points' temperatures to calculate the i,j point. Some of these surrounding points may not be known(in example T(i+1,j) and T(i,j+1)). Gauss-Seidel method says that you can use an arbitrary value for the uknown temperatures, make the calculations for each i,j point and by repeating this process, T(i,j) values are converging to the right value. This iterating process is not working for any time step! Can this be a matter of programming language?? Can i do something to use a longer time step??
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook