Poisson Equation 3D

I have to solve the poisson equation in 3D with BC Dirichelet in Matlab. I have a problem with the numeric solution. The fault to the numeric solution is high. Increment is in every direction different.
I want to fill in the BC in to my rigth hand side. The M is the number of points in the grid. hx, hy and hx are the increment. Is their any mistake in my right hand side when i want to fill in BC? I checked my array and their is nothing wrong with it.
for k=1:Mz
for l=1:Mx
IndexT=Mx*(My-1)+l+(k-1)*Mx*My;
IndexB=l+(k-1)*Mx*My;
rhs(IndexT)=rhs(IndexT)-(uT(l*hx,k*hz)*By/(hy^2)); top edge
rhs(IndexB)=rhs(IndexB)-(uB(l*hx,k*hz)*By/(hy^2)); bottom edge
end
for p=1:My
IndexL=1+(p-1)*Mx+(k-1)*Mx*My;
IndexR=Mx+(p-1)*Mx+(k-1)*Mx*My;
rhs(IndexL)=rhs(IndexL)-(uL(p*hy,k*hz)*Ax/(hx^2)); left edge
rhs(IndexR)=rhs(IndexR)-(uR(p*hy,k*hz)*Ax/(hx^2)); right edge
end
end
i=0;
for k=1:My
for l=1:Mx
IndexF=MxMyMz-Mx*My+i+1;
IndexH=i+1;
rhs(IndexF)=rhs(IndexF)-(uF(l*hx,k*hy)*Cz/(hz^2)); front edge
rhs(IndexH)=rhs(IndexH)-(uH(l*hx,k*hy)*Cz/(hz^2)); back edge
i=i+1;
end
end

Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Asked:

on 1 May 2021

Community Treasure Hunt

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

Start Hunting!