could you please help me with this topic about gauss seidle

3 次查看(过去 30 天)
i can do PGS method with the below code > equation 5-15, code is below
iam trying to develop it to LGS method > equation 5-16, please need your help. the logic forf interior points are attached also.
the number of iteration have to be 308
any other information needed, will be shared.
example solution,
%%% Point Gauss Seidel (PGS)
clear
close all, clc
format short g
%Defining the constants
L=1; % length
H=2; % Height
deltax=0.05
deltay=0.05
Beta=deltax/deltay
Beta2=Beta^2
jn=H/deltay % Maximum number of grid points along y
im=L/deltax % Maximum number of grid points along x
T1=100; T2=0; T3=0; T4=0; % boundary conditions
y=2:-deltay:0;
x=0:deltax:L;
% initialize T_old to the initial guess values
T_old=zeros(jn+1,im+1);
% set boundary conditions
T_old(1,1:im+1)=T1;
T_old(jn+1,1:im+1)=T3;
T_old(2:jn+1,1)=T2;
T_old(2:jn+1,im+1)=T4;
T_new = T_old;
Error = 0.011; % could be any number that is greater than Errormax
Errormax=0.01;
t=0;
while Error > Errormax
t=t+1;
for i=2:jn
for j=2:im
T_new(i,j)=(1/(2*(1+Beta2)))* (T_new(i-1,j)+T_new(i+1,j)+Beta2*(T_new(i,j+1)+T_new(i,j-1)) ) ;
end
end
Error = sum(sum(abs(T_old-T_new),2)) ;
T_old = T_new;
end
% create contour plot
contour(x,fliplr(y),T_new,17,'k')
xlabel('X')
ylabel('Y')
axis equal
  2 个评论
mehmet salihi
mehmet salihi 2021-6-2
编辑:mehmet salihi 2021-6-2
Both give same results.
Point Gauss gives the converge solution in 574 iteration (above code)
whereas, Line Gauss gives in 308 iteration (under developing)
Line gausse method has diagonal matrix, it is implicit method. and we have more than 1 unknown. and it is converge fast than point Guass method.
the code ı shared above is for Point Gauss, but i could not find the idea how to reshape for 5-16 formula.
the grid points above is illustrates the method for Lıne Gauss and for the point Guass method the below is applied.
i am developing 5-16 formulation.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by