23 Haziran 2011 Perşembe

Heat diffusion on a Plate (2D finite difference)

Heat transfer, heat flux, diffusion this phyical phenomenas occurs with magma rising to surface or in geothermal areas. In order to model this we again have to solve heat equation. In this time I will try to implement another mathematical method for another phycial phenomena. In two dimensional domain heat equation is described as;


k: Thermal diffusivity
t: Time
x,y: space parameters
f(x,y,t): Heat source (external effect)


Let's set up problem like below. Plate has size 99x99 and there is place in the middle of the plate with size 10*10. Plate has seperated midpoint of the x axis. Both sides has made by different materials that so both sides have different thermal diffusivity. Let assume that the edges are insulated perfectly and there is no temprature change at the edges. It means;



Since the partial differential equation is linear then the linear approximation could satisfy the solution.  Finite difference heat equation is for the explicit solution;

Implementation to matlab is pretty complicated here the script for this specific problem;

close all
clear all
clc
%%%%%%%%%%%%%%%%%%%%
% Author: Mustafa DENIZ                    %
% Contact: mustafdeniz@itu.edu.tr        %
%%%%%%%%%%%%%%%%%%%%%

dx=1; dy=1; dt=.1;
x=0:dx:99; y=0:dy:99; lx=length(x); ly=length(y);

u=zeros(lx,ly);
un=zeros(lx,ly);
u(45:55,45:55)=2000;

u=u';
imagesc(u)
set(gca,'ydir','normal')

for tt=1:600; %timestep
    for ii=2:ly-1;
        for jj=2:lx-1;
            if ii>=50
                k=0.5;
            else
                k=0.05;
            end
            u(jj,ii)=u(jj,ii)+k*(dt/dx^2)*(u(jj+1,ii)+u(jj-1,ii)+u(jj,ii+1)+u(jj,ii-1)-4*u(jj,ii));
        end
        un=u;
    end

    imagesc(un)
    set(gca,'ydir','normal')
    colorbar
    pause(eps)
    hold off
    drawnow
end

 After ten minutes:

After 1 hour;
References:



Tomas, J. W., 1995, Numerical Partial Differential Equations: Finite Difference Methods, Springer, New York.

Hiç yorum yok:

Yorum Gönder