I have tried to solve 1-D Conduction Steady state heat transfer problems in Matlab (see below).

Here is the 1-D model:

T''[x] == 0, T[0] == 100, T'[100] == 0

Analytical Solution:

T[x] = 100 for x: [0, 100]

I am so suprised that so many iterations (2,500,000) are required for a correct solution (here:T=100 for every node)...

Is it true that we need so many iterations for such a very simple ODEs using FD? Or?


@ConvexHull: the numerical solution is equal to the analytical solution if k = 2,500,000 is used. (Just run it )

The 1-D Conduction Steady state heat transfer in Matlab code looks like:

clear all


T = zeros(N,1);
Tb = 100; % initial temperature

k = 1500000;

for j=1:k
    for i=2:N-1
    T(N,1) = T(N-1,1);


 xx= 0:dx:L;
 ylim([0 100])
  • $\begingroup$ I can't see in your code any division with the time step $k$ $\endgroup$
    – andereBen
    Aug 11, 2020 at 13:01
  • 1
    $\begingroup$ Also, what is in mathematical terms, the equation ( +bc) that you have to solve? $\endgroup$
    – andereBen
    Aug 11, 2020 at 13:01
  • $\begingroup$ The updating of T seems suspicious as you overwrite the previous iterate and read from the next iterate's value. That is, T is always in an inconsistent state and you probably want a buffer to store the next state. The finite difference stencil, treatment of boundary conditions, and choice of iterative method are also suspicious. Without the equations provided, though, it's hard to provide a proper answer. $\endgroup$ Aug 11, 2020 at 13:53
  • $\begingroup$ According to your code, your problem appears to have Dirichlet BC at the left and Neumann BC at the right, but I would suggest that you add the equation and BC in mathematical form. Also, you are using Jacobi iteration to solve the problem and this method might present slow convergence. $\endgroup$
    – nicoguaro
    Aug 11, 2020 at 15:19
  • $\begingroup$ On a second look, it looks like Gauss–Seidel is being used as the linear solver so the inconsistent updating of T is probably ok $\endgroup$ Aug 11, 2020 at 15:40


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.