**Discussion Closed** This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

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

Posted 2 sept. 2011 15:57 UTC−04:00 13 Replies

Mark Suchomel

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!

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!

13 Replies Last Post 5 sept. 2016 14:15 UTC−04:00

Posted:
6 years ago
3 sept. 2011 07:49 UTC−04:00

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

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

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

Attachments:

Mark Suchomel

Posted:
6 years ago
7 sept. 2011 15:32 UTC−04:00

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

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

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

Posted:
6 years ago
17 nov. 2011 09:00 UTC−05:00

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.

[QUOTE]
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
[/QUOTE]
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.

Nader Noroozi

Posted:
6 years ago
17 nov. 2011 12:16 UTC−05:00

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

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

Zhu Yao

Posted:
6 years ago
18 nov. 2011 02:49 UTC−05:00

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

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

Posted:
5 years ago
14 déc. 2012 07:45 UTC−05:00

Hi guys,

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

Thanks

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

Thanks

Hi guys,
Can someone tell me how to change mesh element for p to linear ?
Thanks

Ivar Kjelberg

Posted:
5 years ago
14 déc. 2012 10:03 UTC−05:00

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

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

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

Posted:
5 years ago
14 déc. 2012 12:05 UTC−05:00

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,

Universidad Autónoma de Madrid,

Madrid, Spain.

[QUOTE]
Try changing the element type for pressure from Quadratic to linear. It solved my problem.
[/QUOTE]
Why can changing the element order improve the convergence?
--
Pu, ZHANG ??
Departamento de Física Teórica de la Materia Condensada,
Universidad Autónoma de Madrid,
Madrid, Spain.

Ivar Kjelberg

Posted:
5 years ago
14 déc. 2012 14:17 UTC−05:00

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

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

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

Posted:
5 years ago
17 déc. 2012 04:15 UTC−05:00

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.

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.

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.

Attachments:

Jorge Concepcion

Posted:
5 years ago
27 juin 2013 17:07 UTC−04:00

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

Thanks in advance!!

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

Thanks in advance!!

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
Thanks in advance!!

Posted:
3 years ago
28 nov. 2014 15:22 UTC−05:00

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

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

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

Posted:
1 year ago
5 sept. 2016 14:15 UTC−04:00

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

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

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

Note that while COMSOL employees may participate in the discussion forum, COMSOL^{®} software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.

## Suggested Content

- BLOG Solving Algebraic Field Equations
- BLOG Which Multiphase Flow Interface Should I Use?
- FORUM Implementation of the Navier - Stokes Equation using the PDE interface
- KNOWLEDGE BASE How do I solve a PDE with space derivatives of order higher than two?
- FORUM how to manipulate the external force in Navier Stokes Equation?