Professional Documents
Culture Documents
Report Saikat
Report Saikat
Project 1
Solving two-dimensional Poisson equation
Submitted to
Dr. Ping He
Assistant Professor
Mechanical Engineering
Submitted by
Saikat Sarkar
Lamar ID L20553231
1. Introduction
2. Problem Statement
3. Solution Methodology
4. Result and discussion
5. Conclusion
6. References
7. Appendix
1. Introduction:
CFD (Computational fluid dynamics) is the brunch of fluid mechanics which uses numerical
analysis and data structure for analyzing and solving problems related to fluid flows.
Finite difference method is the simplest method to solve CFD problems. It is a numerical
technique for solving differential equations. It converts ordinary differential equations or partial
differential equations into a system of linear equations which is solved by the matrix algebra
technique.
This report will represent the finite difference method technique to solve the 2D Poisson
equation problem using MATLAB software. The results of the problem will be visualized with a
2D color map.
2. Problem Statement:
Solve the Poisson equation of the following domain with the specified boundary conditions.
𝜕!𝑈 𝜕!𝑈 !
+ = 3𝑥 + 4𝑦!
𝜕𝑥 ! 𝜕𝑦 !
Finite difference method will be used to solve 𝑈 = 𝑈 (𝑥, 𝑦). In the report, present the solution
procedures, and include the plot of 2D color distribution of the solution field. Also include the
MATLAB code in the appendix within the report document.
3. Solution Methodology:
According to the problem statement in this report, a Poisson equation needs to be solved using
finite difference method for the below equation with provided boundary conditions:
𝜕!𝑈 𝜕!𝑈 ! !
+ =3 + 4𝑦 𝐸𝑞. (1)
𝜕𝑥 ! 𝜕𝑦 !
This above Eq. (2) and Eq. (3) are not same
Poisson equation is a part of the fluid flow equation which came from the governing equations of
fluid flow.
𝜕𝜌
𝜕𝑡 = 0
Divergence of the velocity vector means that the sum of mass flows in minus the sum of mass
flows out.
Where,
!(#𝐔)
= change of momentum due to time
&'
∇ ⋅ (𝜌𝐔𝐔) = change of momentum due to flows in and flows out
but,
𝜇
𝜈=
𝜌
Thus,
𝜕 (𝐔) ∇𝑝
+ ∇ ⋅ (𝐔𝐔) = − + 𝜈∇! 𝐔 + 𝑔 𝐸𝑞. (9)
∂𝑡 𝜌
As finite difference method needs to be used for calculation, let’s drive the finite difference
model.
Finite difference method directly models the (partial) differential terms using the finite difference
terms:
We can use the Taylor series to increase the accuracy of finite differential terms:
Eq. (14) + Eq. (15) generates the following second order derivatives:
𝑈-.) − 𝑈-/)
𝑈( = + 𝑂(∆𝑥 ! ) 𝐸𝑞. (17)
-
2∆𝑥
This matrix 𝐴 may be symmetric or non-symmetric, but it must be a square matrix. It means for
this matrix:
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐸𝑞𝑢𝑎𝑡𝑖𝑜𝑛𝑠 = 𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑈𝑛𝑘𝑛𝑜𝑤𝑛𝑠
𝑁# + 1
𝑁#
→
1
1 𝑖→ 𝑁" 𝑁" + 1
Let’s use the nodes (grid points) instead of the cell centers, because in this problem we have only
one unknown field, 𝑈
𝑖 = 1, 2, 3, … … … … … … … , 𝑁" + 1
𝑗 = 1, 2, 3, … … … … … … … , 𝑁# + 1
𝑗 = 2, 3, 4, … … … 𝑁#
For calculating the bulk point according to the given problem, second order derivative will be
used:
𝜕!𝑈
𝜕!𝑈
𝜆w ! + ! x= (𝑥, ) 𝐸𝑞. (20)
𝜕𝑥 𝜕𝑦
∆𝑥 ! ! !) !
𝑈-.),1 − 2𝑈-1 + 𝑈-/),1 + =𝑈-,1/) − 2𝑈-1 + 𝑈-,1/) > = (3𝑥 + 4𝑦 ∆𝑥 𝐸𝑞. (23)
∆𝑦 !
This equation Eq. (23) will be applied for the bulk points.
For the boundary points, all the boundaries will be calculated according to the boundary
conditions.
For left side of the problem domain, the given boundary condition is 34 = 0.
3"
So, for the left side we consider the first order derivative (forward finite differences method)
using the table 2. We get:
𝜕𝑈
= 0 ⇒ 1.5 − 2𝑈 + 0.5 𝑈 = 0 𝐸𝑞. (24)
-5 -/),1 -/!,1
𝜕𝑥
This equation Eq. (24) will be applied for the left side boundary points.
𝑗 = 1, 2, 3, … … … 𝑁# + 1
For the right side of the problem domain, the given boundary condition is 34 = 0.
3"
So, for the right side, we consider the first order derivative (reverse finite differences method).
This equation Eq. (25) will be applied for the right-side boundary points.
𝑖 = 𝑁" + 1
𝑗 = 1, 2, 3, … … … 𝑁# + 1
For the lower side of the problem domain, there are two segments 𝑈 = 3 and 𝑈 = 2.
For 𝑈 = 3:
The right side of the equation is 3.
The coefficient of 𝑈-1 means coefficient of 𝑈 is 1.
For 𝑈 = 2:
The right side of the equation is 2.
The coefficient of 𝑈-1 means coefficient of 𝑈 is 1.
𝑖 = 2, 3, 4, … … … … … . 𝑁"
𝑗 =1
For the upper side of the problem domain, there are two segments 𝑈 = 0 and 𝑈 =
1. For 𝑈 = 0:
The right side of the equation is 0.
The coefficient of 𝑈-1 means coefficient of 𝑈 is 1.
For 𝑈 = 1:
The right side of the equation is 1.
The coefficient of 𝑈-1 means coefficient of 𝑈 is 1.
𝑖 = 2, 3, 4, … … … … … . 𝑁"
𝑗 = 𝑁# + 1
We have considered (𝑖, 𝑗) as the indices for grid points, but for the sparse matrix formation, we
need matrix conversion. Let ‘s consider (𝐼, 𝐽) as matrix points.
From Eq. (19):
[ 𝐴 ] {𝑥} = {𝑏}
In our calculation, vertical counting manner will be used to number all the points from 1 to the
total number of points. Each equation will be for the 𝐼-th row. i,e. (𝑖, 𝑗)-th row. the element of
the matrix will be for the coefficient before 𝑈67:
(𝑎, 𝑏)-th column has the value of the matrix as the coefficient before 𝑈67 .
Using this methodology, the Poisson equation will be solved for the given problem using sparge
matrix system by MATLAB software. Detail codes for this problem are included in the appendix.
4. Result and discussion
The provided partial differential equation has been decomposed to a linear system. The problem
has been solved by matrix algebra method:
[ 𝐴 ] {𝑥} = {𝑏}
The lower side the color map perfectly represents the boundary conditions 𝑈 = 3 and 𝑈 =
2. Also, the upper side the color map satisfies the boundary conditions 𝑈 = 0 and 𝑈 = 1.
Smooth transition also been observed from lower boundary to upper boundary which also reflects
the boundary conations.
There are two abrupt changes to be noted, one in the lower boundary and one in the upper
boundary because no specific boundary condition is defined in that points.
The Poisson equation has been solved using MATLAB software for the provided problem with
defined boundary conditions and the results are represented by a 2D color map.
The given partial differential equation was decomposed to get the linear system. Finally, the
problem has been solved using matrix algebra method.
The 2D color map of the solution field perfectly represents the boundary conditions provided in
the problem.
6. References
1) https://en.wikipedia.org/wiki/Finite_difference_coefficient
7. Appendix
clear
Nx = 1000; % cell # on x
Ny = 500; % cell # on y
Lx = 0.08; % Lx = 0.04+0.04 = 0.08
Ly = 0.04; % Ly = 0.02+0.02 = 0.04
dx = Lx / Nx;
dy = Ly / Ny;
dx2_dy2 = dx*dx / (dy*dy);
lambda = 1.0;
[ X, Y] = meshgrid(-0.04:dx:0.04, -0.02:dy:0.02);
% this above equation tells us the (i,j)th row of the bulk equations
% we have a square matrix, Ntot by Ntot, we need to convert the 2D index
(i,j) into 1D index I
% how to convert (i,j) to I can be varied in different application
% but in every individual case, it has to well defined
% in this case, we use a vertical continuing manner to number all the
% Points from 1 to Ntot
% Each equation will be for the I-th row. i, e. (i,j)th row
% the element of the matrix will be the coefficient before Uab
% (a,b) can be (i-1,j),(i,j),(i+1,j), (i,j-1), (i,j+1)
% (a,b)th column has the value of the matrix as the coefficient before Uab
% Bulk points
for i = 2:Nx
for j = 2:Ny
I = (i-1)*(Ny+1)+j;
% boundary points
i = 1;
for j = 1: Ny+1
I = (i-1)*(Ny+1)+j;
A(I,I) = -1.5;
A(I,I+Ny+1) = 2;
A(I,I+2*Ny+2) = -0.5;
b(I) = 0;
end
i = Nx +1;
for j = 1: Ny+1
I = (i-1)*(Ny+1)+j;
A(I,I) = 1.5;
A(I,I-Ny-1) = -2;
A(I,I-2*Ny-2) = 0.5;
b(I) = 0;
end
j = 1;
for i = 2:Nx
I = (i-1)*(Ny+1)+j;
A(I,I) = 1;
if X(j,i) < 0
b(I) = 3;
else
b(I) = 2;
end
end
j = Ny+1;
for i = 2:Nx
I = (i-1)*(Ny+1)+j;
A(I,I) = 1;
if X(j,i) < 0
b(I) = 0;
else
b(I) = 1;
end
end
A;
spy(A)
b = b';
x = A\b;