alireza.076
جمعه 08 خرداد 1394, 14:12 عصر
سلام
متسفانه در کد زیر به گفته استاد، خطا وجود دارد اما بنده چیزی پیدا نکردم، لطفا راهنمایی بفرمایید
برای یک صفحه اهن در شرایط steady
clear all clc
lx=input('Enter length of X dimension: ');
while lx<=0
disp('Warning:length of X dimension must be positive.')
lx=input('Enter length of X dimension: ');
end
ly=input('Enter length of Y dimension: ');
while ly<=0
disp('Warning:length of Y dimension must be positive.')
ly=input('Enter length of Y dimension: ');
end
nx=input('Enter number of nod at X dimension: ');
while nx<2
disp('Warning:number of node must be 2 or more than 2.')
nx=input('Enter number of nod at X dimension: ');
end
ny=input('Enter number of nod at y dimension: ');
while ny<2
disp('Warning:number of node must be 2 or more than 2.')
ny=input('Enter number of nod at Y dimension: ');
end
up=input('Enter temperature of up side:');
down=input('Enter temperature of down side: ');
left=input('Enter temperature of left side: ');
right=input('Enter temperature of right side: ');
k=input('Enter thermal conductivity (K): ');
g=input('Enter generation of surface: ');
%calculation parameter
dx=lx/(nx-1); %delta x
dy=ly/(ny-1); %delta y
A=dy/dx; %coefficient of T(i,j)
B=dx/dy; %coefficient of T(i,j)
%temperature distribution of constant temprature zones
T=zeros(ny,nx); %temperature distribution array(nx*ny)
T(1,:)=up; %up side temperature
T(ny,:)=down; %down side temperature
T(:,1)=left; %left side temperature
T(:,nx)=right; %right side temperature
%constant line temperatures
T(1,1)=(up+left)/2;
T(1,nx)=(up+right)/2;
T(ny,1)=(left+down)/2;
T(ny,nx)=(right+down)/2;
%temperature distribution of internal nodes
iteration=1;
eps=0;
R=1;
while R>eps
TT=T;
for i=2:ny-1
for j=2:nx-1
T(i,j)=(A*T(i-1,j)+A*T(i+1,j)+B*T(i,j+1)+B*T(i,j-1)+(g*dx*dy)/k)/(2*A+2*B);
end
end
R=sum(sum(abs(T-TT)));
iteration=iteration+1;
end
%output
iteration
T
surf(T)
colorbar
با تشکر فراوان
متسفانه در کد زیر به گفته استاد، خطا وجود دارد اما بنده چیزی پیدا نکردم، لطفا راهنمایی بفرمایید
برای یک صفحه اهن در شرایط steady
clear all clc
lx=input('Enter length of X dimension: ');
while lx<=0
disp('Warning:length of X dimension must be positive.')
lx=input('Enter length of X dimension: ');
end
ly=input('Enter length of Y dimension: ');
while ly<=0
disp('Warning:length of Y dimension must be positive.')
ly=input('Enter length of Y dimension: ');
end
nx=input('Enter number of nod at X dimension: ');
while nx<2
disp('Warning:number of node must be 2 or more than 2.')
nx=input('Enter number of nod at X dimension: ');
end
ny=input('Enter number of nod at y dimension: ');
while ny<2
disp('Warning:number of node must be 2 or more than 2.')
ny=input('Enter number of nod at Y dimension: ');
end
up=input('Enter temperature of up side:');
down=input('Enter temperature of down side: ');
left=input('Enter temperature of left side: ');
right=input('Enter temperature of right side: ');
k=input('Enter thermal conductivity (K): ');
g=input('Enter generation of surface: ');
%calculation parameter
dx=lx/(nx-1); %delta x
dy=ly/(ny-1); %delta y
A=dy/dx; %coefficient of T(i,j)
B=dx/dy; %coefficient of T(i,j)
%temperature distribution of constant temprature zones
T=zeros(ny,nx); %temperature distribution array(nx*ny)
T(1,:)=up; %up side temperature
T(ny,:)=down; %down side temperature
T(:,1)=left; %left side temperature
T(:,nx)=right; %right side temperature
%constant line temperatures
T(1,1)=(up+left)/2;
T(1,nx)=(up+right)/2;
T(ny,1)=(left+down)/2;
T(ny,nx)=(right+down)/2;
%temperature distribution of internal nodes
iteration=1;
eps=0;
R=1;
while R>eps
TT=T;
for i=2:ny-1
for j=2:nx-1
T(i,j)=(A*T(i-1,j)+A*T(i+1,j)+B*T(i,j+1)+B*T(i,j-1)+(g*dx*dy)/k)/(2*A+2*B);
end
end
R=sum(sum(abs(T-TT)));
iteration=iteration+1;
end
%output
iteration
T
surf(T)
colorbar
با تشکر فراوان