how can i make code for implicit method for CFD application?

2 次查看(过去 30 天)
in fact, I have already created code for implicit method, but i have alots of issue on it, so please im looking for help and support for this point quick. My code
clear all
clc
format short
wallLegnth = 1;
dy = 0.05;
toataltime = 0.5;
dt = 0.01;
alpha = 0.1;
dis=0:dy:1;
yn = (wallLegnth/dy)+1;
tn = (toataltime/dt)+1;
alpha=0.1;
z=alpha*dt/(dy^2);
a=-z;
b=(2*z+1);
c=-z;
TRI=full(gallery('tridiag',yn-2,a,b,c));
TRII=inv(TRI);
% Initial condition
for j=2:1:yn-1;
LM(1,j)=100;
end
%Boundary condition
for j=1:1:tn;
LM(j,1)=300;
LM(j,yn)=300;
end
%solveing
for i=1:1:yn;
for j=1;tn-1;
if i==1;
D(i,j)= LM(i+1,j)+a*LM(i,j+1);
elseif 1<i<tn-2
D(i+1,j)=LM(i+1,j);
if i==tn-2
D(i-1,j)= LM(i+1,j)+a*LM(i+2,j+1);
end
end
end
end
for i=1:1:tn;
for j=2:1:yn-1;
LM(i,j)=D'*TRII;
end
end

回答(1 个)

Susmit Kumar Mishra
ig this LM(i,j)=D'*TRII;
should be LM(i,j)=TRII*D';

类别

Help CenterFile Exchange 中查找有关 Computational Fluid Dynamics (CFD) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by