1
1
net/publication/329443187
CITATIONS READS
28 9,298
2 authors, including:
Hassan Khawaja
UiT The Arctic University of Norway
130 PUBLICATIONS 803 CITATIONS
SEE PROFILE
All content following this page was uploaded by Hassan Khawaja on 06 December 2018.
ABSTRACT
This work presents a method for the solution of fundamental governing
equations of computational fluid dynamics (CFD) using the Semi-Implicit
Method for Pressure-Linked Equations (SIMPLE) in MATLAB®. The
fundamental governing equations of fluid mechanics are based on three
laws of conservation, referred to as the law of conservation of mass, the law
of conservation of momentum and the law of conservation of energy. The
continuity equation represents the law of conservation of mass, the Navier-
Stokes equations represent the law of conservation of momentum, and the
energy equation represents the law of conservation of energy. In SIMPLE,
the continuity and Navier-Stokes equations are required to be discretized
and solved in a semi-implicit way. This article presents the discretization and
method of solution applied to the flow around a 2-D square body. Code is
written in MATLAB®. The results show the pressure and velocity fields of the
converged solution.
1. INTRODUCTION
Computational fluid dynamics (CFD) is based on three basic physical principles: conservation
of mass, of momentum and of energy. The governing equations in CFD are based on these
conservation principles. The continuity equation is based on conservation of mass, as shown
in Equation (1),
where 𝜌𝜌 is fluid density, 𝑢𝑢 is fluid velocity in the x-direction, 𝑣𝑣 is fluid velocity in the y-
direction, 𝑤𝑤 is fluid velocity in the z-direction and 𝑡𝑡 is time.
The Navier-Stokes equations based on conservation of momentum are shown in Equation
(2) for the x-direction,
𝜕𝜕(𝜌𝜌𝜌𝜌)
�⃗� = − 𝜕𝜕𝜕𝜕 + 𝜕𝜕𝜏𝜏𝑥𝑥𝑥𝑥 + 𝜕𝜕𝜏𝜏𝑦𝑦𝑦𝑦 + 𝜕𝜕𝜏𝜏𝑧𝑧𝑧𝑧 + 𝜌𝜌𝑓𝑓𝑦𝑦
+ ∇ ∙ �𝜌𝜌𝜌𝜌𝑈𝑈 (3)
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
___________________________________
*Corresponding Author: [email protected]
314 Semi-Implicit Method for Pressure-Linked Equations (SIMPLE) – solution in MATLAB®
�⃗ the velocity vector (𝑢𝑢𝑢𝑢 + 𝑣𝑣𝑣𝑣 + 𝑤𝑤𝑤𝑤), 𝑓𝑓⃗ = 𝑓𝑓𝑥𝑥 𝑖𝑖 + 𝑓𝑓𝑦𝑦 𝑗𝑗 + 𝑓𝑓𝑧𝑧 𝑘𝑘 the
where 𝑝𝑝 represents pressure, 𝑈𝑈
body force vector and 𝜏𝜏 is the shear stress tensor as shown in Equation (5),
where 𝜇𝜇 is the dynamic viscosity, 𝛿𝛿𝑖𝑖𝑖𝑖 is the kronecker delta, and subscripts 𝑖𝑖, 𝑗𝑗 and 𝑘𝑘 refer
to linear dimensions x, y and z.
The equation based on the conservation of total energy is shown in Equation (7),
𝜕𝜕 𝑈𝑈 2 𝑈𝑈 2 𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕 𝜕𝜕𝜕𝜕
�𝜌𝜌 �𝑒𝑒 + �� + ∇ ∙ �𝜌𝜌 �𝑒𝑒 + �⃗� = 𝜌𝜌𝑞𝑞̇ + �𝑘𝑘 � + �𝑘𝑘 � +
� 𝑈𝑈
𝜕𝜕𝜕𝜕 2 2 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕(𝑢𝑢𝑢𝑢) 𝜕𝜕(𝑣𝑣𝑣𝑣) 𝜕𝜕(𝑤𝑤𝑤𝑤) 𝜕𝜕(𝑢𝑢𝑢𝑢𝑥𝑥𝑥𝑥 ) 𝜕𝜕(𝑢𝑢𝜏𝜏𝑦𝑦𝑦𝑦 ) 𝜕𝜕(𝑢𝑢𝜏𝜏𝑧𝑧𝑧𝑧 ) 𝜕𝜕(𝑣𝑣𝑣𝑣𝑥𝑥𝑥𝑥 )
𝜕𝜕𝜕𝜕
�𝑘𝑘 𝜕𝜕𝜕𝜕 � − 𝜕𝜕𝜕𝜕
− 𝜕𝜕𝜕𝜕
− 𝜕𝜕𝜕𝜕
+ 𝜕𝜕𝜕𝜕
+ + + +
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝜕𝜕(𝑣𝑣𝜏𝜏𝑦𝑦𝑦𝑦 ) 𝜕𝜕(𝑣𝑣𝜏𝜏𝑧𝑧𝑧𝑧 ) 𝜕𝜕(𝑤𝑤𝑤𝑤𝑥𝑥𝑥𝑥 ) 𝜕𝜕(𝑤𝑤𝜏𝜏𝑦𝑦𝑦𝑦 ) 𝜕𝜕(𝑤𝑤𝜏𝜏𝑧𝑧𝑧𝑧 )
+ + + + + 𝜌𝜌𝑓𝑓⃗ ∙ 𝑈𝑈
�⃗ (7)
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝜕𝜕(𝜌𝜌𝜌𝜌)
�⃗) = 𝜌𝜌𝑞𝑞̇ + 𝜕𝜕 �𝑘𝑘 𝜕𝜕𝜕𝜕� + 𝜕𝜕 �𝑘𝑘 𝜕𝜕𝜕𝜕 � + 𝜕𝜕 �𝑘𝑘 𝜕𝜕𝜕𝜕� −
+ ∇ ∙ (𝜌𝜌𝜌𝜌𝑈𝑈
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 2 𝜕𝜕𝜕𝜕 2 𝜕𝜕𝜕𝜕 2 𝜕𝜕𝜕𝜕 2
𝑝𝑝 �𝜕𝜕𝜕𝜕 − 𝜕𝜕𝜕𝜕 − 𝜕𝜕𝜕𝜕
� + 𝜆𝜆 �𝜕𝜕𝜕𝜕 − 𝜕𝜕𝜕𝜕 − 𝜕𝜕𝜕𝜕
� + 𝜇𝜇 �2 �𝜕𝜕𝜕𝜕 � + 2 �𝜕𝜕𝜕𝜕� + 2 � 𝜕𝜕𝜕𝜕 � +
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 2 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 2 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 2
�𝜕𝜕𝜕𝜕 + 𝜕𝜕𝜕𝜕� + � 𝜕𝜕𝜕𝜕 + 𝜕𝜕𝜕𝜕
� + �𝜕𝜕𝜕𝜕 + 𝜕𝜕𝜕𝜕 � � (8)
2
where 𝜆𝜆 = − 𝜇𝜇 and 𝜇𝜇 is the coefficient of dynamic viscosity.
3
Int. Jnl. of Multiphysics Volume 12 · Number 4 · 2018 315
This physical behavior of various real-time structures and physical phenomena allows
engineers and mathematicians to assume a realistic 3-D situation to be a 2-D or even a 1-D
problem. The advantage of reducing the dimensions is that it allows complex equations to be
solved much more easily and relatively faster [7].
This paper provides a step by step methodology for SIMPLE, defining the problem, giving
the assumptions, degrees of freedom, discretization, and method of solution. The methodology
also discusses the flow chart of the method written in MATLAB®. The results section of the
paper discusses the pressure and velocity fields obtained from the solution. The paper
concludes by discussing the effectiveness and limitations of the given method.
316 Semi-Implicit Method for Pressure-Linked Equations (SIMPLE) – solution in MATLAB®
2. METHODOLOGY
The methodology is divided into two sections: setting up the SIMPLE and the method of
solution in MATLAB®. Setting up the SIMPLE includes: assumptions, degrees of freedom,
discretization, and pressure and velocity corrections. The method of solution is given in the
form of a flowchart as shown in Fig. 4.
This work assumes the CFD problem to be incompressible. This means that the density
does not change in time and space and, henceforth, can be considered as a constant value. This
assumption is very valid in a range of problems when flow velocities are not too high. In
addition, the given CFD problem does not constitute any thermal effects. This assumption
allows us to simplify the problem to the extent that there is no need to solve the energy
equation.
The domain is defined as 2-D space, as shown in Fig. 2, presenting a 2-D problem of flow
around a square. The variables constituting continuity and Navier-Stokes are pressure, x-
velocity and y-velocity.
constant no-slip
velocity at boundary
inlet condition
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝜕𝜕𝜕𝜕
+ 𝜕𝜕𝜕𝜕 = 0 (9)
where 𝑢𝑢 is the fluid velocity in the x-direction, 𝑣𝑣 is the fluid velocity in the y-direction, 𝑝𝑝
is the fluid pressure, 𝜌𝜌 is the fluid density, 𝜇𝜇 is the coefficient of dynamic viscosity of the
fluid, and 𝑡𝑡 is time.
Int. Jnl. of Multiphysics Volume 12 · Number 4 · 2018 317
In order to apply a numerical scheme such as SIMPLE for the solution of Equations (9) to
(11), each term needs to be discretized. Discretization is the mathematical process of
transforming continuous equations into their discrete counterparts. This process is a first step
toward making equations suitable for a numerical solution and for implementation on digital
machines. In this work, the 2-D domain has been discretized in a staggered grid, as shown in
Fig. 3.
The transient terms from Navier-Stokes equations (Equations (10) and (11)) can be
discretized using the forward difference method as shown in Equations (12) and (13),
while convective terms discretized using the upwind scheme are shown in Equations (18)
to (21),
where ∆𝑥𝑥 and ∆𝑦𝑦 are the values representing the size of space in the discretized domain.
The pressure terms are discretized using the forward difference method, as shown in
Equations (22) and (23),
The diffusion terms are discretized using the central difference method, as shown in
Equations (24) to (27),
The discretized terms can be substituted in Navier-Stokes Equations (10) and (11),
resulting in the following forms, as shown in Equations (28) and (29),
The continuity equation (Equation (9)) is discretized using the forward difference method,
as shown in Equation (30),
where 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟 indicates the extent of convergence. Although its ideal value is zero, a small
number is acceptable for a numerical solution.
It is to be noted that Navier-Stokes equations (Equations (28) and (29)) are discretized in
time domain t. However, the continuity equation (Equation (30)) has been discretized in time
domain t+1. This is because the velocities in the new domain are calculated using Navier-
Stokes discretized equations (Equations (28) and (29)) and checked in the discretized
continuity equation (Equation (30)). The solution is iterated until the residual reduces to a
small number.
Since the solution is calculated via Navier-Stokes discretized equations (Equations (28)
and (29)), it always conforms with the law of conservation of momentum. However, it may
not conform with the law of conservation of mass as defined by the discretized continuity
equation (Equation (30)). In order to obtain convergence for both, laws of conservation of
momentum and mass, corrections need to be applied to velocities and pressure variables, as
shown in Equations (31) to (33),
320 Semi-Implicit Method for Pressure-Linked Equations (SIMPLE) – solution in MATLAB®
𝑢𝑢𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 = 𝑢𝑢𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) + 𝑑𝑑𝑢𝑢𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) (31)
𝑣𝑣 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 = 𝑣𝑣 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) + 𝑑𝑑𝑣𝑣 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) (32)
𝑝𝑝𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 = 𝑝𝑝𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) + 𝑑𝑑𝑝𝑝𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) (33)
where 𝑢𝑢𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 , 𝑣𝑣 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 , and 𝑝𝑝𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 are the corrected values
of velocity 𝑢𝑢, velocity 𝑣𝑣 and pressure 𝑝𝑝 that satisfy both continuity and Navier-Stokes
discretized equations (Equations (28) to (30)). 𝑑𝑑𝑢𝑢𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗), 𝑑𝑑𝑣𝑣 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗), and 𝑑𝑑𝑝𝑝𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) are
the differences between the corrected values and are calculated for velocity 𝑢𝑢, velocity 𝑣𝑣
and pressure 𝑝𝑝, respectively.
Substituting the corrected values in the discretized Navier-Stokes equations (Equations
(28) and (29)) results in Equations (34) and (35),
Substituting Equations (34) and (35) in the discretized continuity equation (Equation (30))
results in Equation (36),
1 1
𝛼𝛼 = 2 �∆𝑥𝑥 2 + ∆𝑦𝑦 2 � (38)
1
𝛽𝛽 = − ∆𝑥𝑥 2 (39)
𝑢𝑢𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 = 𝑢𝑢𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) + 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟_𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓. 𝑑𝑑𝑢𝑢 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) (41)
𝑣𝑣 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 = 𝑣𝑣 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) + 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟_𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓. 𝑑𝑑𝑣𝑣 𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) (42)
𝑝𝑝𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗)𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 = 𝑝𝑝𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) + 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟_𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓. 𝑑𝑑𝑝𝑝𝑡𝑡+1 (𝑖𝑖, 𝑗𝑗) (43)
In addition, for stability and accuracy, it is vital to choose the correct timestep value. In
this work, the Courant–Friedrichs–Lewy (CFL) condition [1, 21] is used to decide the timestep
size. The CFL condition is given in Equation (44),
The given method of solution is solved and post-processed in MATLAB® [22]. The flow
chart of the code, which can be accessed from the Mathworks repository [23], is given in Fig.
4. The results are discussed in the next section.
322 Semi-Implicit Method for Pressure-Linked Equations (SIMPLE) – solution in MATLAB®
Figure 5. Pressure and velocity fields around a square in the 2-D domain.
In the given case, the maximum value of the residual value dropped below 10-4. The
maximum values of residuals from the continuity equation are plotted against the iteration
number, as shown in Fig. 6.
324 Semi-Implicit Method for Pressure-Linked Equations (SIMPLE) – solution in MATLAB®
Figure 6. Convergence plot: the maximum value of the residual is plotted against
the iteration number.
4. CONCLUSION
The presented study demonstrates that flow around a square in a 2-D domain can be
successfully solved using the SIMPLE algorithm. The paper offers an explanation of the
SIMPLE algorithm, detailing assumptions, degrees of freedom, discretization, as well as
pressure and velocity corrections. The method of solution is given in the form of a flowchart
and the code is implemented in MATLAB® and can be accessed from [23].
ACKNOWLEDGMENTS
The author would also like to acknowledge the support of Linda March from The Good
English Company, UK, for proofreading this work.
REFERENCES
[1] S. Patankar. Numerical Heat Transfer and Fluid Flow: Taylor & Francis; 1980.
[2] H. Khawaja. CFD-DEM Simulation of Minimum Fluidisation Velocity in Two Phase
Medium. The International Journal of Multiphysics. 2011;5(2):89-100.
[3] H. Khawaja. CFD-DEM and Experimental Study of Bubbling in a Fluidized Bed. The
Journal of Computational Multiphase Flows. 2015;7(4):227-40.
[4] H. Khawaja, T. Rashid, O. Eiksund, E. Brodal, K. Edvardsen. Multiphysics Simulation
of Infrared Signature of an Ice Cube. The International Journal of Multiphysics.
2016;10(3):291-302.
Int. Jnl. of Multiphysics Volume 12 · Number 4 · 2018 325