Question: NEED HELP TO DEBUG THE FOLLOWING CODE: LID DRIVEN CAVITY USING SIMPLE APPROACH. REFER CFD BOOK BY JOHN D ANDERSON FOR THE ALGORITHM & THE
NEED HELP TO DEBUG THE FOLLOWING CODE: LID DRIVEN CAVITY USING SIMPLE APPROACH. REFER CFD BOOK BY JOHN D ANDERSON FOR THE ALGORITHM & THE STAGGERED GRID
Twodimensional Flow Solver with Pressure Correction Method
clc;
clear all;
close all;
GEOMETRY CONSTANTS
L ; length of domain, m
H ; height of domain, m
Nxp ; # of points in x direction at which pressure is resolved No of columns
Nyp ; # of points in y direction at which pressure is resolved No of rows
Nxu Nxp ; # of points in x direction at which u velocity is resolved
Nyu Nyp; # of points in y direction at which u velocity is resolved
Nxv Nxp ; # of points in x direction at which v velocity is resolved
Nyv Nyp ; # of points in y direction at which v velocity is resolved
dx LNxp; in x direction
dy HNyp; in y direction
dt e; time resolution, seconds
alphap ; underrelaxation factor for pressure
alphau ; underrelaxation factor for u velocity
alphav ; underrelaxation factor for v velocity
FLUID CONSTANTS
rho ; density, kgm
mu ; dynamic viscosity, kgm s
Reynolds Number, Re
INITIAL CONDITIONS
pstar onesNypNxp;
pstar onesNypNxp;
ustar zerosNyuNxu;
vstar zerosNyvNxv;
rhoustar rho.ustar;
rhovstar rho.vstar;
pprime zerosNypNxp;
pprime zerosNypNxp;
uprime zerosNyuNxu;
vprime zerosNyvNxv;
A zerosNyuNxu;
B zerosNyvNxv;
BOUNDARY CONDITIONS
ustar:;
v vstar;
u ustar; horizontal velocity, fts
Set boundary conditions for corners
uNyu; Bottomleft corner
uNyuNxu; Bottomright corner
v; Topleft corner
vNyv; Bottomleft corner
vNxv; Topright corner
vNyvNxv; Bottomright corner
Convergence criterion
tolerance e;
PRESSURE CORRECTION METHOD
b dtdx;
c dtdy;
a b c;
d zerosNypNxp; mass flow term in continuity equation
for iter :
for i :Nxp column, to
for j :Nyu row, to
k NypNypj; to
kv NyvNyvj; to
ku NyuNyuj; to
vbarvkvivkvi;
vbarvkvivkvi;
Akuirhoukuirhoukuidx
rhoukuivbarrhoukuivbardy
muukuiukuiukuidx
ukuiukuiukuidy;
rhoustarkui rhoustarkui Akuidt
dtdxpstarki pstarki;
if i
ustarkuiustarkui;
end
if i Nxp
ustarkuiustarkui;
end
ukui ustarkui;
end
end
u ustar;
for i :Nxu column, to
for j :Nyu row, to
k NypNypj; to
kv NyvNyvj; to
ku NyuNyuj; to
ubarukuiukui;
ubarukuiukui;
Bkvirhovkviubarrhovkviubardx
rhovkvirhovkvidy
muvkvivkvivkvidx
vkvivkvivkvidy;
rhovstarkvi rhovstarkvi Bkvidt
dtdypstarki pstarki;
vstarkvi rhovstarkvirho;
vstar:vstar:;
vstarNyv:vstarNyv:;
vkvi vstarkvi;
end
end
v vstar;
maxdivergence ; Initia
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
