73 
A class called \class{StokesProblemCartesian} in \escript can be used to solve 
A class called \class{StokesProblemCartesian} in \escript can be used to solve 
74 
for velocity and pressure. A more detailed discussion of the class can be 
for velocity and pressure. A more detailed discussion of the class can be 
75 
found in Chapter \ref{MODELS CHAPTER}. 
found in Chapter \ref{MODELS CHAPTER}. 
76 
In order to keep numerical stability and satisfy the Courant condition, the 
In order to keep numerical stability and satisfy the Courant–Friedrichs–Lewy condition (CFL condition) \index{Courant number}\index{CFL condition}, the 
77 
timestep size needs to be kept below a certain value. 
timestep size needs to be kept below a certain value. 
78 
The Courant number is defined as: 
The Courant number \index{Courant number} is defined as: 
79 
% 
% 
80 
\begin{equation} 
\begin{equation} 
81 
C = \frac{v \delta t}{h} 
C = \frac{v \delta t}{h} 
122 
Inside the \code{while} loop, the boundary conditions, viscosity and body 
Inside the \code{while} loop, the boundary conditions, viscosity and body 
123 
force are initialized. 
force are initialized. 
124 
The Stokes equation is then solved for velocity and pressure. 
The Stokes equation is then solved for velocity and pressure. 
125 
The timestep size is calculated based on the Courant condition, to ensure stable solutions. 
The timestep size is calculated based on the Courant–Friedrichs–Lewy condition (CFL condition) \index{Courant number}\index{CFL condition}, to ensure stable solutions. 
126 
The nodes in the mesh are then displaced based on the current velocity and 
The nodes in the mesh are then displaced based on the current velocity and 
127 
timestep size, to move the body of fluid. 
timestep size, to move the body of fluid. 
128 
The output for the simulation of velocity and pressure is then saved to a file 
The output for the simulation of velocity and pressure is then saved to a file 
183 


184 
print("Max velocity =", Lsup(velocity), "m/s") 
print("Max velocity =", Lsup(velocity), "m/s") 
185 


186 
# Courant condition 
# CFL condition 
187 
dt=0.4*h/(Lsup(velocity)) 
dt=0.4*h/(Lsup(velocity)) 
188 
print("dt =", dt) 
print("dt =", dt) 
189 

