Solving Heat Transfer problem using Finite Difference

I was working on modelling this question
Modelled it liket this:
I used this formula for finite difference
I wrote the code but how do i obtain equations ..for example solving by hand i got these:
Heres my code: There is an issue if i use syms T1 ....T5
Any help would be appreciated.
clear all
clc
close all
L=0.05; %thickness
n=5; % no of nodes
edot=6e5; % heat generation
k=34; % conductivity
g=edot/k;
dx=L/n; %distance between 2 nodes
alp=1/(dx)^2;
h=60; % heat transfer coefficient
syms T5
T_inf=30; % T on the right hand side
T0=ones(1,n);
T1=ones(1,n);
%T0(5)=T5;
for i=1:n-1
T1(i)=(alp)*(T0(i+1)-2*T0(i)+T0(i-1))+g; % node 1= insulation
end
T0(end)=h*(T_inf-T(5))*k*1/dx+edot*dx/2; % node 5 has heat convection too

4 Comments

You should not use syms, because we the FDM idiscretizes the domain, and the solution is numerical (not symoblic).
Moreover, it is not clear what is the upper boundary condtions!
Mainly, this is solution at all points except the boundardies
for i=2:n-1
T(i)=(alp)*(T(i+1)-2*T(i)+T(i-1))+g;
end
insulated means
T(1) = 0;
what is the value in the upper bound, just put it here
T(n) =
Insulated surely means that there is no heat-flux at that end, not that the absolute temperature is zero (which is a rather unphysical assumption)
In this case, you boundary conditon in Neumann not Dirichlet, meaning that the derivate of the temperature at the end is zero not the temperature itself is zero.
Hi, Thanks for the reply, I am supposed to get equations and solve then as as system. But editing as you said got me
1.0e+11 *
0 0.0000 0.0008 7.6478 0.0001
Im confused as this is the solution by hand and we get different values
Loop 1 only gives the value of (g *alp) how can I involve the T0 nad T1??
T =
1.0e+04 *
1.7647 0 0 0 0
Loop 2 same for here..
T =
1.0e+08 *
0.0002 1.7649 0 0 0
for i=1:n-1
T(i)=(alp)*(T(i+1)-2*T(i)+T(i-1))+g;
end
T(n)=h*(T_inf-T(5))*k*((T(4)-T(5)*1/dx)+edot*dx/2;
disp(T)
T= 1.0e+11 *
0 0.0000 0.0008 7.6478 0.0001

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Asked:

on 16 Jun 2021

Edited:

on 16 Jun 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!