GS_flow - % T = zeros(20,20); T T(20,:) = 20 * ones(1,20);...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Heat distribution on rectangular metal plate with constant % % temperature upper and lower boundaries (Dirichlet B.C.) and % % constant flows through the metal plate (Neumann B.C. on right % % and left) with Qx=32 and h=1. % % % 60 % % T(1,1)--T(1,2)--T(1,3)--T(1,4)--T(1,5) % | | % T(2,1) T(2,2) T(2,3) T(2,4) T(2,5) % | | % 32 -> T(3,1) T(3,2) T(3,3) T(3,4) T(3,5) -> 32 % | | % T(4,1) T(4,2) T(4,3) T(4,4) T(4,5) % | | % T(5,1)--T(5,2)--T(5,3)--T(5,4)--T(5,5) % % 20 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % function GS_flow f % create grid with boundary
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % T = zeros(20,20); T T(20,:) = 20 * ones(1,20); T(1,:) = 60 * ones(1,20); % main iteration for n=1:200 T_old(2:19,1:20)=T(2:19,1:20); for i=2:19 for j=2:19 T(i,j) = ( T(i+1,j) + T(i-1,j) + T(i,j+1) + T(i,j-1) )/4; end T(i,1) = ( T(i+1,1) + T(i-1,1) + 2 * T(i,2) + 64 )/4; T(i,20) = ( T(i+1,20) + T(i-1,20) + 2 * T(i,19) - 64 )/4; end error = max(max( abs(T(2:19,1:20) - T_old(2:19,1:20)) )); end e error e figure; % plot temperature distribution surf( T ); view(130,15) title('Temperature distribution'); t figure; % plot isothermal lines contour(T') title('Isothermal lines') t...
View Full Document

Ask a homework question - tutors are online