Transient Conduction Heat Transfer
Afficher commentaires plus anciens
I am trying to say that the nodes from 2-40 are all initially 19 Celsius and that the first node = 27 Celsius. Then as time progresses through the simulation the nodes from x> to x==n_x should increase in temperature. The whole simulation should run for 180 seconds. I have seemed to fixed the issues I was having however I am now having different errors, wondered if you could help.
%Aluminium Material Properties%
clear all
close all
clc
rho = 2700 ; %kg/m^3 Density
k = 170 ; %
cp = 910 ; %
alpha = k/(rho*cp); %
L_d = 0.0047; %m Diameter
L_x = 0.047; %m Length in x direction
L_r = L_d/2; %m Radius
n_r = 2; % Nodes in r direction
n_x = 40; % Nodes in x direction
del_x = L_x/(n_x-1); %m Spacing of Nodes
T_h = 27; %C Temperature of Hot Side
T_i = 19; %C Initial Temperature
t_2 = 180; %s Simulation Time
t(1) = 0; %s Initial Time
Fo = 0.25; % Fourier Number Stability 0.25 For 3D
del_t = (Fo*del_x^2)/alpha; % Calculate time step using Fourier Number for Stability
h = 5;
%Set Inital Matrices Temp
T(1:n_r,1:n_x+2) = T_i;
Fo = alpha*del_t/(del_x.^2) ; % Fourier Number
Bi = h*del_x/k ; % Biot Number
if Fo > 0.25
fprintf('Fo Number to big, code unstable \n \n')
elseif Fo*(1-Bi) > 0.25
fprintf('Bi Number to big, code unstable')
end
k = 1;
while t<t_2 % Time Loop
for r=1:n_r % Space Loop r direction
for x=1:n_x % Space Loop x direction
if x==1 % Boundary Condition First Node = 27 Celius % Boundary Condition First Node = 27 Celius
T(r,x,k+1) = 27;
elseif x>1 && x==n_x % Middle to End of Material
T(r,x,k+1) = alpha*((T(r,x+1,k)-2*T(r,x,k)+T(r,x-1,k))/del_x.^2)+((T(r+1,x,k)-2*T(r,x,k)+T(r-1,x,k))/del_x.^2) ;
end
end
end
for r = 1:n_x
T(r,1,k+1) = T(r,3,k);
T(r,n_x+2,k+1) = T(r,n_x,k);
end
t(k) = k+del_t;
k = k+1;
end
Temp(1:n_r,1:n_x) = T(1:n_r,1:n_x,k-1);
The error that is occurring now is -----
??? Attempted to access T(0,2,1); index must be a positive integer or logical.
Error in ==> Transient2D at 39
T(r,x,k+1) =
alpha*((T(r,x+1,k)-2*T(r,x,k)+T(r,x-1,k))/del_x.^2)+((T(r+1,x,k)-2*T(r,x,k)+T(r-1,x,k))/del_x.^2)
;
Hopefully someone can help.
Réponses (1)
Azzi Abdelmalek
le 31 Mar 2014
In line 37 you have the expression on the right contains
T(r-1,x,k)
with r beginning at 1, make the index=0
2 commentaires
Luke Cartwright
le 31 Mar 2014
Azzi Abdelmalek
le 31 Mar 2014
Modifié(e) : Azzi Abdelmalek
le 31 Mar 2014
This is it. But what index r=0 means for you? There is no such index in your array T. Maybe you should begin tour r at 2.
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!