PDE etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
PDE etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

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.

Vibrating string - 1D

In geophysics we always encounter with the waves such as earthquake waves, sound waves, oscilating electric and magnetic field in electromagnetic radiation. Thus we need to understand the nature of the this physical phenomena. "Wave equation" can be derived basic equation of motion and restoring forces of differential equation. This equation describes the waves in time and space. Let's consider an ocean wave and assume that the displacement given by u(x,t), then the wave equation can be written as;


The factor of the V is speed of the wave. Solution of this linear partial differential equation is;

A: amplitude
k: constant
w: circular frequency
'phi'(greek letter): phase

Now if we fixed the boundary conditions there is no displacement at the end points;

u(0,t)=u(L,t)=0

Finally we have the standing wave that has nodes at the location of two endpoints. New solution for this specific problem is;

Implementation this problem to matlab takes two steps, first create a function which calculates nodes, secondly create another function for plotting purpose;

function u=unodes(x,dt,n,w,phase)
u=cos(n*w*dt+phase).*sin(n*pi*x);
end


plotting function is;

function vs1d(xmin,xmax,n,w,phase)

%%%%%%%%%%%%%%%%%%%%
% Author: Mustafa DENIZ                    %
% Contact: mustafdeniz@itu.edu.tr        %
%%%%%%%%%%%%%%%%%%%%%

tmax=2*pi/w; %maximum time

dt=0.05; %timestep

frms=round(tmax/dt); %number of frame

x=xmin:0.01:1; %grid x

for ii=1:frms-1;
   plot(x,unodes(x,ii*dt,n,w,phase));
   axis([xmin xmax -1.5 1.5])
   m(ii)=getframe;
end
movie(m,3)




Subsequently we can change the nodes,phase length of string arbitrarily by typing this command, for example;

>>vs1d(0,1,1,1,2)

if we want see the third node just change value of n variable in command;

>>vs1d(0,1,3,1,2)


REFERENCES: