Thursday, November 23, 2006

熱傳模組的建立

解數值熱傳,所使用的是有限差分法,其方法如下:


需注意到一件事情,解數值熱傳時矩陣的編號是

有影響次序性的,因此在code中有個V矩陣是作

為編碼用的。


程式碼如下所示:


clf

clear all

format long

M=menu('請選擇熱傳的模式種類',...

'穩態無熱生成,無微分邊界',...

'穩態有熱生成,且有微分邊界',...

'非穩態且適應各種條件');

switch M

case 1

disp('Now we will divide the 2-D plane for FDE')

%too choose the divide element by setting the side

r=input('Please input m row of the matrix you want ==> ');

c=input('Please input n column of the matrix you want ==> ');

zeros(r,c);

for t=1:r*c

v(t)=t;

end

V=reshape(v,r,c);

%set up a matrix to number every element of the matrix

N=r*c;

A=zeros(N);

%after observing the FDE matrix, derive down rule code

for i=1:N

A(i,i)=-4;

if i+r0

A(i,i-r)=1;

end

if i+1> ');

for j=1:c

B((j-1)*r+1,1)=-Tu;

end



%left boundary

Tl=input('Temperature of left boundary>> ');

for k=1:r

B(k,1)=-Tl;

end



%down boundary

Td=input('Temperature of down boundary>> ');

for h=1:c

B(r*h,1)=-Td;

end



%right boundary

Tr=input('Temperature of right boundary>> ');

for p=1:r

B(r*(c-1)+p,1)=-Tr;

end



%four corner's temp need another expression

B(1,1)=-(Tu+Tl);

B(r,1)=-(Td+Tl);

B(r*(c-1)+1,1)=-(Tu+Tr);

B(r*c,1)=-(Td+Tr);



%calculate and plot the distribution of temp

X=inv(A)*B;

Q=reshape(transpose(X),r,c);

mesh(Q);

xlabel('Top boundary')

ylabel('Left boundary')

zlabel('Temperature(℃)')

case 2

disp('施工中')

otherwise

disp('施工中')

end







結果


嘗試著使用有限差分去解數值熱傳,目前來說可作穩態熱傳限於無微分邊界以及熱生成











目前只做到穩態熱傳限於無微分邊界以及熱生成

下圖為作8*8的大小時,給四邊任意溫度的熱傳分佈圖


No comments: