Posts

Showing posts with the label Numerical solution of Poisson's equation in rectangular domain.

Solve Poissons Equation using 5-Point Stencil with SOR method

Image
Solution Poisson's Equation In a Rectangular Domain Using 5-Point Stencil Poisson's equation in a square domain $0 \leq x,y \leq 1$ with source term given by $q(x)=100*\sin(\pi x)*\sin(\pi y)$. The boundaries of the domain are maintained at $u=0$. Determine the solution using finite difference method. Solution: Discretizing domain uniformly with step size h and k along x and y direction. Using five point stencil, equation at each node is given by $$\frac{u_{i+1,j}-2u_{i,j}+u_{i-1,j}}{h^{2}}+\frac{u_{i,j+1}-2u{i,j}+u{i,j-1}}{k^{2}}=-q(i,j)$$ $$u_{i,j}=\frac{1}{\frac{2}{h^{2}}+\frac{2}{k^{2}}}(\frac{u_{i+1,j}+u_{i-1,j}}{h^{2}}+\frac{u_{i,j+1}+u{i,j-1}}{k^{2}}+q(i,j))$$ where $q(i,j)=100*\sin(\pi x_{i})*\sin(\pi y_{j})$ Here a MATLAB code is given below. Choosen $m=n=11$ grid to solve the problem using SOR (successive overrelaxation). Mathematica Code: In this algo

Solving Poisson's Equation Using 5-Point Stencil In A Rectangular Domain

Image
Solving Poisson's Equation Using 5-Point Stencil: Example: Consider the Poisson's equation on a unit square domain with the source term given by $q(x)=100*\sin(\pi x)*\sin(\pi y)$. The boundaries of the domain are maintained at $u=0$. Reactangular region: $0 \leq x,y \leq 1$. Determine the solution using finite difference method. Solution: 5-point stencil and Gauss-Seidel methods are used to solve Poisso's equations. Here a Mathematica code is give to sove this following program. dx = 0.1; x = Range[0, 1, dx]; y = x; n = Length[x];m = Length[y]; xy = Transpose[Join[{x}, {y}]]; (*Print["xy: ",xy//MatrixForm];*) xMeshgrid = ConstantArray[10, {n, n}]; yMeshgrid = ConstantArray[10, {m, m}]; o[Do[xMeshgrid[[i, j]] = x[[i]]; yMeshgrid[[j, i]] = y[[i]], {j, 1, m}], {i, 1, n}]; (*Print["xMeshgrid: ",xMeshgrid//MatrixForm]; Print["yMeshgrid: ",yMeshgrid//MatrixForm];*) X = T