0% found this document useful (0 votes)
39 views

%Name-Nitesh Kumar Jha %roll No.-173612 % Solution of 2D Equation by Explicit Method

This document contains code to solve a 2D heat equation using an explicit finite difference method. It defines parameters like the number of grid points, time step size, and spatial step sizes. It initializes the temperature matrix with boundary conditions and then iterates through time steps calculating the new temperature at interior points using values from the previous time step. It stores the results in a new matrix and updates the old matrix, repeating until the specified time is reached. Finally, it generates a surface plot of the final temperature matrix.

Uploaded by

NITESH JHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

%Name-Nitesh Kumar Jha %roll No.-173612 % Solution of 2D Equation by Explicit Method

This document contains code to solve a 2D heat equation using an explicit finite difference method. It defines parameters like the number of grid points, time step size, and spatial step sizes. It initializes the temperature matrix with boundary conditions and then iterates through time steps calculating the new temperature at interior points using values from the previous time step. It stores the results in a new matrix and updates the old matrix, repeating until the specified time is reached. Finally, it generates a surface plot of the final temperature matrix.

Uploaded by

NITESH JHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

%Name-Nitesh Kumar Jha

%Roll no.-173612
% solution of 2D equation by explicit method
clear all
clc
N=100

M=100;

L=100;

H=100;

Dx=.25;

Dy=.25;
prompt7='enter the alue of alpha=';
alpha=input(prompt7);
%calculation of deltax
deltaX=L/(N-1);
%calculation of deltaY
deltaY=H/(M-1);
%calculation of deltaTx
deltaTx=Dx*square(deltaX)/alpha;
%calculation of deltaTy
deltaTy=Dy*square(deltaY)/alpha;
prompt8='enter the alue of time';
T=input(prompt8);
%calution of no. of iteration
K=T/deltaTx;
%lets start calculation the matrix
Told=zeros(N,M);
Tnew=zeros(N,M);
Told(1:N,1)=100;
Told(1:N,M)=0;
Told(1,1:M)=100;
Told(N,1:M)=0;
Tnew(1:N,1)=100;
Tnew(1:N,M)=0;
Tnew(1,1:M)=100;
Tnew(N,1:M)=0;
p=1:100;
o=1:100;
for i=1:100
for j=2:M-1
for k=2:N-1
Tnew(j,k)=Told(j,k)+deltaX*(Told(j-1,k)-
2*Told(j,k)+Told(j+1,k))+deltaY*(Told(j,k-1)-2*Told(j,k)+Told(j,k+1));
end
end
Told=Tnew;
end
surf(o,p,Tnew)

You might also like