Using the code from http://math.mit.edu/~gs/cse/codes/mit18086_navierstokes.pdf, I simulated cavity flow with an external force with the boundary conditions on the all 4 sides are $u=v=0$ and $\frac{\partial p}{\partial n}=0$. I just added external force to u direction in the step that calculates nonlinear term $$\text{(1)} \quad \frac{U^*-U^n}{\Delta t} = -((U^n)^2)_x - (U^nV^n)_y $$ to $$\text{(1)} \quad \frac{U^*-U^n}{\Delta t} = -((U^n)^2)_x - (U^nV^n)_y +f $$ . So the code was changed only 2 lines, from
uN = x*0+1
U = U-dt*(UVy(2:end-1,:)+U2x);
to
uN = x*0
U = U-dt*(UVy(2:end-1,:)+U2x+10);
I am confused with this result. This external force is like gravity, so I thought, when applying only gravity the fluid inside a cavity does not circulate. It is like water in a glass. Why does it circulate? Is this physically correct or because of the numerical simulation method?