# cavity flow with only an external force. Why does it circulate?

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);


, and I got this result. 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?

• It might be your pressure boundary conditions. In such a static setup, as you describe it, the gravity -- which can be written as the gradient of a potential field -- is compensated by the pressure gradient. From your setup and from your plot, I would say that $\partial p /\partial n = 0$ is not correct at the uppper and lower boundaries. Can you try to just set $p=0$ at the right (or left) boundary?
– Jan
Nov 9, 2016 at 13:25
• I can't seem to understand what your formulas represent. Can you state what you choose as a force $f$ when you make these modifications? Nov 9, 2016 at 15:41
• I agree with @Jan, your pressure BC does not make sense in the situation you describe.
– user20857
Nov 9, 2016 at 17:48
• @Jan, I changed the boundary condition to set p=0, following the comment "Discretization schemes should not change when you differ the BCs. However the matrices used for multiplication change depending on the boundary conditions, the value at matrix location (1,1) and (n,n)." and the code posted on the link cfd-online.com/Forums/main/90303-matlab-code-pipe-flow.html. But I still get the same result. Nov 9, 2016 at 20:39
• So what is $f$ then in your example? Nov 9, 2016 at 22:25

@Wolfgang Bangerth has a very important point about what $f$ is. The constant external force will not affect your solution unless your BCs allow for motion. In your case, they do not. An easy conceptual proof of this is to look at the vorticity equation (by taking the curl of your equations). The source term disappears, which means no motion will ensue. Therefore, the motion you're see is from an non-physical setup.