# Numerical method for a heat diffusion problem

• loukoumas
In summary: There seems to be a mistake in your code. You are using a too short time step, which is leading to NaNs. A longer time step may help you converge to the right solution, but you don't need to use a different programming language.
loukoumas
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 process 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 process, 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!

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.

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??

## What is a numerical method for a heat diffusion problem?

A numerical method for a heat diffusion problem is a mathematical technique used to approximate the solution of a heat diffusion equation. It involves dividing the problem into smaller, simpler parts and using numerical algorithms to solve for the temperature distribution over time.

## What are the advantages of using a numerical method for a heat diffusion problem?

Using a numerical method allows for complex heat diffusion problems to be solved with greater accuracy and efficiency compared to traditional analytical methods. It also allows for the modeling of more realistic and complex boundary conditions.

## What are the limitations of using a numerical method for a heat diffusion problem?

One limitation is that the accuracy of the solution depends on the size of the time and space intervals used in the numerical algorithm. This can result in a trade-off between accuracy and computational time. Additionally, numerical methods can be affected by errors such as round-off and truncation errors.

## What are some common numerical methods used for solving heat diffusion problems?

Some commonly used numerical methods for heat diffusion problems include the finite difference method, finite element method, and spectral methods. Each method has its own advantages and limitations, and the most appropriate method depends on the specific problem being solved.

## How can one assess the accuracy of a numerical method for a heat diffusion problem?

The accuracy of a numerical method can be assessed by comparing the solution obtained with the numerical algorithm to known analytical solutions or experimental data. Additionally, the convergence of the numerical solution as the time and space intervals are decreased can also indicate the accuracy of the method.

• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
41
Views
8K
• Materials and Chemical Engineering
Replies
20
Views
692
• Calculus and Beyond Homework Help
Replies
0
Views
510
• Other Physics Topics
Replies
0
Views
534
• Thermodynamics
Replies
3
Views
979
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
• Quantum Physics
Replies
1
Views
668
• Calculus and Beyond Homework Help
Replies
4
Views
758