How can i perform an ADI method on 2d heat equation

์กฐํšŒ ์ˆ˜: 7 (์ตœ๊ทผ 30์ผ)
Mohammad Adeeb
Mohammad Adeeb 2021๋…„ 4์›” 28์ผ
๋Œ“๊ธ€: Mohammad Adeeb 2021๋…„ 4์›” 28์ผ
im trying to slve this equation : ๐œ•๐‘‡ ๐œ•๐‘ก = ๐œ• 2๐‘‡ ๐œ•๐‘ฅ 2 + ๐œ• 2๐‘‡ ๐œ•๐‘ฆ 2
๐‘‡(๐‘ฅ, ๐‘ฆ, 0) = 0
๐‘‡(0, ๐‘ฆ,๐‘ก) = 0
๐‘‡(1, ๐‘ฆ,๐‘ก) = 0
๐‘‡(๐‘ฅ, 0,๐‘ก) = 0
(๐‘ฅ, 1,๐‘ก) = 100 sin ๐œ‹x
so for the first part which is in x direction i did the following :
c
lose all;
clc;
dt = 0.001; %time step
dx = 0.1; %step in x direction
t = 0:dt:15; %time interval (changable due to your desighn)
x = 0:dx:1; %x-axis interval (changable due to your desighn)
lamda=dt/(2*dx^2);
a=(1+2*lamda)*ones(1,13);%define matrix A
A=diag(a); %make matrix a diagonal one
N = length(x)+2; %interval (changable due to your desighn)
for i=1:N-1
A(i+1,i)=-lamda;
A(i,i+1)=-lamda;
end
A(1,1)=1+2*lamda;
A(1,2)=-lamda;
A(13,12)=-lamda;
A(13,13)=1+2*lamda;
T=[]; %Dynamic size array
a2=lamda*ones(1,13);
A2=diag(a);
for j=1:N-3
A2(j+3,j)=(1-2*lamda);
A2(j,j+3)=(1-2*lamda);
end
T(:,:,:) = zeros(length(t),length(y)+2,length(x)+2); %define initial condition
Tstar=zeros(length(x),length(y));
Tall=zeros(length(x),length(y));
for k=2:length(t)
for j=2:length(x)-1
fx=(l-2*lamda)*T(:,j,k-1)+lamda*T(:,j-1,k-1)+lamda*T(:,j+1,k-1);
fx(1)=0;
fx(end)=0;
Tstar(j,:)=(A\fx)';
end
for i=2:length(y)-1
fy=(1-2*lamda)*Tstar(i,:)+lamda*Tstar(i-1,:)+lamda*Tstar(i+1,:);
fy(:,1)=0;
fy(:,end)=100*sin(pi*x(i));
end
Tall(:,j)=A\fy;
T(:,:,k)=Tall(:,:);
end
i've used imaginary node to solve the proplem , also i did the following analysis for the code :
.
  ๋Œ“๊ธ€ ์ˆ˜: 3
Mohammad Adeeb
Mohammad Adeeb 2021๋…„ 4์›” 28์ผ
.
Mohammad Adeeb
Mohammad Adeeb 2021๋…„ 4์›” 28์ผ
.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Mathematics and Optimization์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์ œํ’ˆ


๋ฆด๋ฆฌ์Šค

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by