Steady state heat equation:-((∂^2 T)/(∂x^2 )+(∂^2 T)/(∂y^2 )=-Q(x,y)

Click For Summary
SUMMARY

The discussion focuses on solving the steady state heat equation using the Finite Difference Method in MATLAB. The user successfully implemented a program but encountered performance issues as the grid size increased. The primary challenge is the computational time required for larger values of 'n', which represents the number of grid points. The user seeks assistance in optimizing their MATLAB code to enhance execution speed while maintaining accuracy in solving the equation.

PREREQUISITES
  • Understanding of the Finite Difference Method for numerical solutions
  • Familiarity with MATLAB programming and its syntax
  • Knowledge of steady state heat equations and boundary conditions
  • Basic concepts of numerical stability and convergence in iterative methods
NEXT STEPS
  • Optimize MATLAB code for performance, focusing on vectorization techniques
  • Explore parallel computing options in MATLAB to speed up calculations
  • Investigate alternative numerical methods for solving partial differential equations
  • Learn about adaptive mesh refinement to improve efficiency in grid-based simulations
USEFUL FOR

Researchers, engineers, and students in computational physics or engineering fields who are working on heat transfer simulations and seeking to improve the performance of numerical algorithms in MATLAB.

range.rover
Messages
15
Reaction score
0
Hi friends i am trying to solve heat equation for a single time domain,with Finite Difference Method. I wrote a program in MATLAB,it sucessfully worked, but as i increse the number of points, my program is taking lots of time to give out result.

Can anybody help me in increasing the speed of my Program:-clear;
close all;
clc;
n = 5;% n grids and has n - 2 interior points per dimension

x = linspace(0,1,n);% line in x direction of 0 to 1 and divided into n parts

dx = x(2)-x(1); % distance between grids

y = x;

dy = dx;

k=1; %thermal conductivity

Q=300 ; % heat source
m=(n-2)^2;

%Right hand side matrix

B=zeros(m,1);

if (mod(m,2)==0)
B(m/2,1)=Q;
else
B((m+1)/2,1)=Q;
end

%Main Matrix

Tsol = zeros(n);
%boundary conditions
Tsol(1,1:n) = 0; %TOP
Tsol(n,1:n) = 0; %BOTTOM
Tsol(1:n,1) = 0; %LEFT
Tsol(1:n,n) = 0; %RIGHT

tic
error = 1; z = 0;
while error > 0.000001
z = z+1;
c=1;
Torg = Tsol;
for i = 2:n-1
for j = 2:n-1
Tsol(i,j) =abs(((dx^2*B(c,1))+((Torg(i+1,j)+Torg(i-1,j)+Torg(i,j+1)+Torg(i,j-1))*k))/(4*k));
c=c+1;
end
end

error = max(max(abs(Torg-Tsol)));
endtoc

%% plotting

figure, contour(x,y,Tsol),
title('Temperature (Steady State)'),xlabel('x'),ylabel('y'),colorbar
figure,pcolor(x,y,Tsol),shading interp,
title('Temperature (Steady State)'),xlabel('x'),ylabel('y'),colorbar
 
Physics news on Phys.org
I'm sorry you are not generating any responses at the moment. Is there any additional information you can share with us? Any new findings?
 
Are you sure it even works at it stands now? What I think you might be trying to do is to solve the heat equation with a source term in the middle of a 2d system and with zero dirichlet boundary condition. Is that correct? Because that is not what I see when I change n.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
923
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 0 ·
Replies
0
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 0 ·
Replies
0
Views
3K
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
4K