# Discussion Forum

## Navier-Stokes Simulation using General Form PDE: The Continuity Equation

RSS feed   |   Turn on email notifications   |   13 Replies   Last post: September 5, 2016 6:15pm UTC

Mark Suchomel

September 2, 2011 7:57pm UTC

Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Greetings all.

I am working to solve a standard fluid flow problem (e.g. flow in a pipe as a start) using the General Form PDE interfaces instead of the Fluid Flow built in GUI. I am able to define a u-momentum and a v-momentum equation without too much difficulty, but it is the continuity equation that I am struggling with. Right now I have 3 instances of PDE General Form (2 momentum equations + 1 continuity equation). For the continuity equation, all of the coefficients are set to zero with the exception of the source, f. The source f is set equal to -(ux + vy), giving the spatial derivatives of the velocity components equal to zero (incompressible, Newtonian fluid). The problem now becomes the boundary conditions - the continuity equation must be satisfied everywhere (not just on the boundaries) in the domain! I can set all the boundaries to zero and it works fine, but I don't get a converged velocity field because there is no enforcement of continuity.

Does anyone have any insight on how the built in Fluid Flow module implements the continuity constraint? Perhaps I could use a probe to integrate "abs(ux+vy)" over the domain, but then I have no way of requiring that to be zero (or some small number).

Any advice would be greatly appreciated! Thanks!

JM

September 3, 2011 11:49am UTC in response to Mark Suchomel

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi Mark,

Define two PDE, the first with u and v and the second with p, the continuity equation is defined in the second PDE, see the mph file.

--
JM Buchot

Mark Suchomel

September 7, 2011 7:32pm UTC in response to JM

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Thank you JM for the advice.

I now have a follow-up question. I have the equations set up and I let the solver run. Eventually it reaches its maximum number of iterations and tells me that it could not find a converged solution. HOWEVER, the "solution" from the last iteration step seems completely converged. I know the solution for flow in a pipe (or between two plates), the pressure profile is perfect and continuity is satisfied. Why didn't the solver stop?? I have tried changing the solver settings (originally just used the default), tolerances, etc - but they all give the same result: returning what appears to be a converged solution without realizing it.

I am baffled and clearly missing something. Is there a way to tell *what* isn't converged and why the solver has not stopped? At one point, the MUMPS solver showed a convergence of 10^-11 but didn't stop. The next step showed convergence of 2.5!

Any advice anybody can provide would be greatly appreciated!

Solver settings:
Stationary, Direct Solver: MUMPS
Max Iterations: 25
Tolerance Factor: 1
Relative Tolerance: 0.001

Mark

Zhu Yao

November 17, 2011 2:00pm UTC in response to JM

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi Mark,

Define two PDE, the first with u and v and the second with p, the continuity equation is defined in the second PDE, see the mph file.

--
JM Buchot

Dear JM,
According to your suggestion, I defined a coupled model by 2 PDEs to reproduce the Navier-Stokes module(built-in model) in Comsol module library. Comparing the simulation result by this defined model and the built-in model, the pressure(p) is not smooth or converged by the defined model, although the u, v looks very similar. This puzzled me after I try to make both models with the same solver parameters and mesh. Could you please give me some suggestion. I can forward both model to you by email if you would like to.
The mph file I downloaded couldn't be opened in Comsol 3.5 or 4.1. Thanks a lot.

November 17, 2011 5:16pm UTC in response to Zhu Yao

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Try changing the element type for pressure from Quadratic to linear. It solved my problem.

Zhu Yao

November 18, 2011 7:49am UTC in response to Nader Noroozi

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Yes!, It works. I changed mesh element for p to linear and it works before I got your warmhearted reply. Anyway, thanks so much.

Mehrez Agnaou

December 14, 2012 12:45pm UTC in response to Zhu Yao

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi guys,

Can someone tell me how to change mesh element for p to linear ?

Thanks

Ivar Kjelberg

December 14, 2012 3:03pm UTC in response to Mehrez Agnaou

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi
check your main physics node for the Discretization tab, if not there turn it on via the view icon "discretization" of the "options - preferences - show - discretization"

--
Good luck
Ivar

Pu

December 14, 2012 5:05pm UTC in response to Nader Noroozi

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Try changing the element type for pressure from Quadratic to linear. It solved my problem.

Why can changing the element order improve the convergence?

--
Pu, ZHANG ??
Departamento de Física Teórica de la Materia Condensada,

Ivar Kjelberg

December 14, 2012 7:17pm UTC in response to Pu

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi

there are probably several possible explanations, but the higher the order the higher you might get oscillations to your esults, and these might be "wrong" hence increasing the rrors used by COMSOL to control the convergence, and then give poor or no convergence. Try interpolating a few ponts in Excel with a linear, secondary, third order etc polynomial, you will quickly se the tendencies to get oscillations, if you move your reference point up and down. You can go further in your study if you use matalb or another numerical tool

--
Good luck
Ivar

Mehrez Agnaou

December 17, 2012 9:15am UTC in response to Ivar Kjelberg

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi dear all,

I'm simulating a flow in a porous media but I still have a problem with the convergence.
I'm using Comsol 4.2a and I have implemented my equations (Momentum equations and continuity equation) with 2 general PDE.

In the 1st PDE, I have the 2 momentum equations (2D case) where the dependent variables are u and v and using a quadratic discretisation order.

In the 2nd PDE, I have the continuity equation. The dependent variable is p (pressure) and I'm using a linear discretisation order (as you have suggested before).

Can you please take a look at my model (here attached).

PS : I'm using a dimensionless NS equations.

Jorge Concepcion

June 27, 2013 9:07pm UTC in response to Mehrez Agnaou

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi:
I have this problem: How do you solve a similar problem, but in 3d. For example in a square duct with adimensionalized equations:

Geometry: Lz=1/2, Ly=1/2, Lx+=1;

u*ux+v*uy+w*uz=-px+1/Re^2*uxx+uyy+uzz

u*vx+v*vy+w*vz=-py*Re^2+1/Re*vxx+vyy+vzz

u*wx+v*wy+w*wz=-pz*Re^2+1/Re*wxx+wyy+wzz

ux+vy+wz=0

BC=
u,v,w=0 on walls;
u=1 at x=0

John Lovell

November 28, 2014 8:22pm UTC in response to Jorge Concepcion

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi, not sure if the forum protocol is to keep old chains alive or start a new one. Anyway, I have a question which follows on this discussion. The coding up of the PDE's is relatively straightforward and the choice of quadratic/linear/etc, not so bad.

But then you get into the details - crosswind diffusion, streamline diffusion, etc. How to add that?

And then for time-dependent equations how do you specify upwind differentiation, etc? I've stumbled over this in the past.

For example, I've had occasion often enough to try to solve turbulent Navier-Stokes with uniform cross-section (d/dz=0 except for dp/dz). Should be easy enough to type this in by hand, but the only way I've got it to work is to load up the full Navier Stokes from COMSOL and edit the equations to try to delete all of the items I expect to be zero.

Any thoughts? For that matter - "out-of-plane" models already exist for heat transfer, but could be popular to add to the list for Navier-Stokes too.

Regards, John

Di Shen

September 5, 2016 6:15pm UTC in response to Zhu Yao

Re: Navier-Stokes Simulation using General Form PDE: The Continuity Equation

Hi Yao

I am working on a pipe flow simulation almost exactly like your case by using general PDE interface to solve the Navier-Sotkes equation. However, after I created 2 momentum + 1 continuity equation ( pressure defined, linear Lagrange ), it still can not give me a converged solution with pressure inlet and pressure outlet boundary condition.

I noticed that you have solve your problem, Is that possible to give me some more advice or teach me how you did it?

Best
Di Shen

Rules and guidelines