【问题标题】:Coupled Poisson equations and Matlab program耦合泊松方程和 Matlab 程序
【发布时间】:2020-07-03 01:12:05
【问题描述】:

谁能帮我解决?或者帮我解耦方程? :(

$u_{xx}+u_{yy}=au+bw$
$w_{xx}+w_{yy}=cu+dw$

我还必须使用有限差分法来解决这个问题,但是一旦我得到输出,一切都为零。这是我的 Matlab 代码,如果有人可以帮助我的话。 这是我目前的代码

clear; close all; 
n=101; h=1/(n-1);
x=0:h:1.01; y=0:h:1.01;
U=zeros(n+1); W=zeros(n+1);
omega=1.7777777;err=1000;
a1=0.5; a2=5; b1=-1; b2=1; 
tol=1e-6;
for i=1:n+1 %boundary conditions
    U(1,i)=cos(5*pi*y(i)); U(i,1)=cos(5*pi*y(i)); U(n+1,i)=0; U(i,n+1)=0;
    W(1,i)=cos(5*pi*y(i)); W(i,1)=cos(5*pi*y(i)); W(n+1,i)=0; W(i,n+1)=0;
end
figure(1);  
subplot(1,2,1);mesh(x,y,U);view(130,25);grid on; title('boundary conditions U(x,y)'); 
subplot(1,2,2);mesh(x,y,W);view(130,15);grid on; title('boundary conditions W(x,y)');  
u=U; w=W;
while err>tol
   for i=2:n
        for j=2:n
        u(i,j)=(1-omega)*U(i,j)+omega*(((u(i+1,j)+u(i-1,j)+u(i,j+1)+u(i,j-1))/h^2)-b1*W(i,j))/(a1+(4/h^2));
        w(i,j)=(1-omega)*W(i,j)+omega*(((w(i+1,j)+w(i-1,j)+w(i,j+1)+w(i,j-1))/h^2)-a2*U(i,j))/(b2+(4/h^2));
        end
   end 
    W=w; U=u; err=max(max(abs(u-U))); 
end

figure(2);  
subplot(1,2,1);mesh(x,y,U);view(130,25);grid on; title('U(x,y)'); 
subplot(1,2,2);mesh(x,y,W);view(130,15);grid on; title('W(x,y)');    

【问题讨论】:

    标签: matlab poisson decoupling


    【解决方案1】:

    问题出在这一行:

     W=w; U=u; err=max(max(abs(u-U))); 
    

    你正在设置U=u`` first and then looking at the different of uandU```。逆向计算即可。

     err=max(max(abs(u-U))); W=w; U=u; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-09
      • 1970-01-01
      • 2018-08-22
      • 1970-01-01
      • 2012-02-27
      • 2014-11-07
      相关资源
      最近更新 更多