Analytic/Numerical Solution of Elliptic PDE (Poisson Equation) with MATLAB

Поделиться
HTML-код
  • Опубликовано: 3 окт 2024
  • Analytic and numerical Solutions of an elliptic PDE (Poisson equation) are obtained by using MATLAB.

Комментарии • 1

  • @WonYYang
    @WonYYang  22 дня назад

    @WonYYang
    44분 전(수정됨)
    %em07e01.m
    f=@(x,y)0; g=@(x,y)0; % Eq.(E7.1.1) w.r.t. Eq.(7.1.1)
    % (Rectangular) Domain and BC types
    x0=0; xf=pi; y0=0; yf=pi; D=[x0 xf y0 yf];
    % BCs
    bx0=@(y)0; bxf=@(y)0; by0=@(x)sin(2*x); byf=@(x)0; % Eq.(E7.1.2a,b,c,d)
    % Numerical approach
    % Numbers of grid points along x-/y-axes, Error tolerance,
    Mx=50; My=50; tol=1e-5; MaxIter=600;
    [un,xx,yy]=pde_poisson_D(f,g,bx0,bxf,by0,byf,D,Mx,My,tol,MaxIter);
    % Analytical approach
    K=10; [ua,A]=pde_Laplace_ana(xf,yf,bx0,bxf,by0,byf,Mx,My,K);
    A, Discrepancy=norm(un-ua)/norm(ua)
    mesh(xx,yy,un) % Plot the solution graph
    xlabel('x'), ylabel('y')
    function [u,A,xx,yy]=pde_Laplace_ana(xf,yf,bx0,bxf,by0,byf,Mx,My,N)
    % To solve u_xx +u_yy = 0
    % over the region D=[0,xf,0,yf]={(x,y)|0