Need help with loop for a heat transfer question
Show older comments
Hello, I worked on a code to calculate the temperature of the slab from a given initial temperature and a given slab thickness after some time t. Now lets say that the slab thickness wasn't given, and the question is asking to calculate the minimum thickness of a slab to satisfy a final temperature after some time t, how can i adjust my code so that it calculates the minimum thickness? im new to matlab so any help would be appreciated. Please let me know if theres something that is not clear about the code, thanks in advance for your help.
%this code calculates the temperature of the slab surface after time t
clear
clc
close
L=0.2; %slab thickness
Ti=600; %initial surface temp
Tinf=22; %surrounding temp
h=240; %convection coefficient
k=80.2; %thermal conductivity
alpha=3.31e-5;
dx=0.01;
dt=1.5;
Fo=(alpha*dt)/dx^2; %forier number
Bii=(h*dx)/k;
Bio=(h*dx)/k;
t=1800;
x=[0:dx:L];
n=length(x);
t=[0:dt:t];
T = zeros(numel(t), numel(x)); %temperature of the slab at time t (rows) and position x (columns)
T(1, :) = Ti; %temperature at t = t0;
for k = 2:numel(t)
T(k, 1) = T(k-1, 1)*(1-2*Fo-2*Bio*Fo)+2*Fo*T(k-1, 2)+2*Bio*Fo*Tinf; %node1
for i = 2:numel(x)-1
T(k, i) = T(k-1, i)*(1-2*Fo)+Fo*(T(k-1, i+1)+T(k-1, i-1)); %interior nodes
end
T(k, n) = T(k-1, n)*(1-2*Fo-2*Bii*Fo)+2*Fo*T(k-1, n-1)+2*Bii*Fo*Tinf; %exterior node
end
T(k,n)
%plot temperature for all t at a different x
plot(t, T(:, end));
3 Comments
KALYAN ACHARJYA
on 20 Jul 2018
Edited: KALYAN ACHARJYA
on 20 Jul 2018
Which term represents the final temp, is this t?
t=1800;
And your question is find L, when t reaches 1800?
Guillaume
on 20 Jul 2018
KALYAN ACHARJYA
on 20 Jul 2018
Oh
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!