CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Pressure difference as an input to simpleFoam

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree7Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 29, 2021, 08:22
Question Pressure difference as an input to simpleFoam
  #1
New Member
 
Ahmad Mahmoud
Join Date: Aug 2021
Posts: 2
Rep Power: 0
a.mahmoud is on a distinguished road
I have a problem where I am required to simulate the flow through a reconstructed geometry of a human vessel (pipe flow), where the pressure at the inlet and at the outlet is known, in order to find the resultant flow rate.



My question is how should I set up a case in openFoam using the simpleFoam solver, where the pressures are the input and no velocity is specified. I have tried doing this by setting the velocity boundary condition to zero gradient at both ends, and the pressure as fixed value for both values, but the results were usually unstable and did not converge satisfactorily. I have tried with k-epsilon turbulence models as well as k-omega SST and even fully laminar, but none of them would converge.


What appropriate boundary conditions should I use and how can I improve the stability and convergence of the problem?


Thank in advance!
a.mahmoud is offline   Reply With Quote

Old   August 29, 2021, 20:00
Default
  #2
Member
 
Francisco T
Join Date: Nov 2011
Location: Melbourne, Australia
Posts: 64
Blog Entries: 1
Rep Power: 14
frantov is on a distinguished road
That seems correct. Check the file attached, which is a microchannel (100microns x 20) the velocity is generated correctly with pressure. This case is laminar.

microch_vel.png
microchannel100x20Pressure.zip
Perhaps you can try laminar first and then add turbulence later?


What issues are you having?
Cheers
Francisco
joshwilliams likes this.
frantov is offline   Reply With Quote

Old   August 31, 2021, 02:10
Default
  #3
Member
 
Andreas P.
Join Date: May 2017
Posts: 41
Rep Power: 9
AndreasPe is on a distinguished road
Maybe you can try the pressureInletUniformVelocity instead of zeroGradient for one side. This sets velocity to a constant value over the whole inlet in one direction, which made simulations stable in my case...

https://www.openfoam.com/documentati...d.html#details
joshwilliams likes this.
AndreasPe is offline   Reply With Quote

Old   September 6, 2021, 05:52
Default
  #4
New Member
 
Ahmad Mahmoud
Join Date: Aug 2021
Posts: 2
Rep Power: 0
a.mahmoud is on a distinguished road
Quote:
Originally Posted by AndreasPe View Post
Maybe you can try the pressureInletUniformVelocity instead of zeroGradient for one side. This sets velocity to a constant value over the whole inlet in one direction, which made simulations stable in my case...

https://www.openfoam.com/documentati...d.html#details

What value would I set i to. Note that I do not have vales for the velocity or the flux, that is the value i am after.
a.mahmoud is offline   Reply With Quote

Old   September 6, 2021, 06:04
Default
  #5
Member
 
Andreas P.
Join Date: May 2017
Posts: 41
Rep Power: 9
AndreasPe is on a distinguished road
The "value" field ist just a dummy field for this boundary condition, that will be overwritten by the calculation of the boundary condition. So you can just set it to 0.
AndreasPe is offline   Reply With Quote

Old   September 6, 2021, 11:21
Default
  #6
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 670
Rep Power: 14
Tobermory will become famous soon enough
Another suggestion is to apply a total pressure boundary condition at the upstream end; the ESI documentation page (https://www.openfoam.com/documentati...tions-subsonic) suggests that this gives good stability ... my experience is a bit mixed though. Let us know what ends up working for you.
dlahaye likes this.
Tobermory is offline   Reply With Quote

Old   September 6, 2021, 12:44
Default
  #7
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 736
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Aha!

What has your experience with subsonic cases been?

I am working on a jet-in-co-flow with transonic jet to (hopefully) clarify convergence issues. What are in your experience are point to look into?

Would pressure-velocity coupled solver help in these cases?

Thx, Domenico.
dlahaye is offline   Reply With Quote

Old   April 24, 2022, 00:04
Exclamation Have you solved the problem yet?
  #8
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 4
zyliao is on a distinguished road
Quote:
Originally Posted by a.mahmoud View Post
I have a problem where I am required to simulate the flow through a reconstructed geometry of a human vessel (pipe flow), where the pressure at the inlet and at the outlet is known, in order to find the resultant flow rate.



My question is how should I set up a case in openFoam using the simpleFoam solver, where the pressures are the input and no velocity is specified. I have tried doing this by setting the velocity boundary condition to zero gradient at both ends, and the pressure as fixed value for both values, but the results were usually unstable and did not converge satisfactorily. I have tried with k-epsilon turbulence models as well as k-omega SST and even fully laminar, but none of them would converge.


What appropriate boundary conditions should I use and how can I improve the stability and convergence of the problem?


Thank in advance!
Hi Ahmad,
Have you solved the problem yet? What boundary conditions are appropriate?
These days I met the same stability and convergence problem when I simulated the plane-Poiseuille flow (plane-parallel plates with pressure gradient).
I chose the simpleFoam solver, and set simulationType as laminar in the turbulenceProperties file, and the boundary and initial conditions are showed in the followed figure.

According to my result, it didn’t converge even after 200000 time steps (attached figure 2).

But, one good point is the simulated outlet flux is matched quite well with the calculated flux by the theoretical equation (Cubic law: v=-△Pw^2/(12μL) (m/s)).
Attached Images
File Type: jpg plane-Poiseuille flow.jpg (25.1 KB, 30 views)
File Type: png screenshot of the log file.png (67.2 KB, 33 views)
zyliao is offline   Reply With Quote

Old   April 24, 2022, 00:11
Default Attached OpenFOAM case
  #9
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 4
zyliao is on a distinguished road
Quote:
Originally Posted by zyliao View Post
Hi Ahmad,
Have you solved the problem yet? What boundary conditions are appropriate?
These days I met the same stability and convergence problem when I simulated the plane-Poiseuille flow (plane-parallel plates with pressure gradient).
I chose the simpleFoam solver, and set simulationType as laminar in the turbulenceProperties file, and the boundary and initial conditions are showed in the followed figure.

According to my result, it didn’t converge even after 200000 time steps (attached figure 2).

But, one good point is the simulated outlet flux is matched quite well with the calculated flux by the theoretical equation (Cubic law: v=-△Pw^2/(12μL) (m/s)).
I uploaded one of my OF case to the GoogleDrive, maybe someone can have a look? Thank you!
https://drive.google.com/drive/folde...Th?usp=sharing
zyliao is offline   Reply With Quote

Old   April 24, 2022, 05:08
Default
  #10
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 670
Rep Power: 14
Tobermory will become famous soon enough
If you look at the log file that you posted, you'll see that it is doing zero iterations on the solvers for Ux and p ... which means that it has stopped solving. You need to adjust the solver tolerances to force it to solve to a tighter residual level, or add a minIter line in the solver instructions to force it to always do at least 1 iteration. That will keep it solving ... up to the limit posed by your grid design. Hope that helps.
hydroRussian likes this.
Tobermory is offline   Reply With Quote

Old   April 24, 2022, 09:05
Exclamation Add a minIter line? Meaning of "No Iterations X" and different tolerances
  #11
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 4
zyliao is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
If you look at the log file that you posted, you'll see that it is doing zero iterations on the solvers for Ux and p ... which means that it has stopped solving. You need to adjust the solver tolerances to force it to solve to a tighter residual level, or add a minIter line in the solver instructions to force it to always do at least 1 iteration. That will keep it solving ... up to the limit posed by your grid design. Hope that helps.
Hi Tobermory,
Actually I conducted some other cases by setting different tolerances. As you can see from the attached figure, if the tolerances are bigger (cases name highlight by yellow), it can converge very fast, but the outlet flux didn’t match the theoretical value well (the theoretical averaged flow rate v = 0.4464 m/s); while if the tolerances are smaller, it’ll converge very hard.

And how to add a minIter line in the solver intructions?
I also a little confused about the exact meaning of “No Iterations X” in the log file. As you can see in my results, X can equal to nonzero in the converged cases.

BTW, I wonder what’s the difference between the “tolerance” and “residualControl”?
What are the exact meanings of “tolerance”, “relTol” and “residualControl”? What do these three values control? What settings are appropriate for them? Are there any tips or rules for people to obey?
zyliao is offline   Reply With Quote

Old   April 24, 2022, 09:31
Exclamation Problem of pressureInletUniformVelocity
  #12
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 4
zyliao is on a distinguished road
Quote:
Originally Posted by AndreasPe View Post
Maybe you can try the pressureInletUniformVelocity instead of zeroGradient for one side. This sets velocity to a constant value over the whole inlet in one direction, which made simulations stable in my case...

https://www.openfoam.com/documentati...d.html#details
Hi AndreasPe
I tried the pressureInletUniformVelocity type for the inlet (cases name highlight by green), it indeed converges very fast, but the calculated outlet flow rate didn’t match the theoretical value (v = 0.4464 m/s) well.
I also tried the pressureInletVelocity type (cases name highlight by blue), it seems still has the stability and convergence problem.
zyliao is offline   Reply With Quote

Old   April 24, 2022, 10:26
Default
  #13
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 4
zyliao is on a distinguished road
Quote:
Originally Posted by frantov View Post
That seems correct. Check the file attached, which is a microchannel (100microns x 20) the velocity is generated correctly with pressure. This case is laminar.

Attachment 86086
Attachment 86087
Perhaps you can try laminar first and then add turbulence later?


What issues are you having?
Cheers
Francisco
Hi Francisco,

I wonder which solver did you use for your case? simpleFoam, pisoFoam or pimpleFoam? I'm a little confused because I see seetings for PISO, SIMPLE & PIMPLE in the fvSolution file.
zyliao is offline   Reply With Quote

Old   April 24, 2022, 12:49
Default
  #14
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 670
Rep Power: 14
Tobermory will become famous soon enough
Quote:
Originally Posted by zyliao View Post
Hi Tobermory,
And how to add a minIter line in the solver intructions?
In fvSolution, just add a line for each variable you want to apply it to, eg.:
Code:
    p
    {
        solver          GAMG;
        tolerance       1e-08;
        relTol          0.01;
        smoother        GaussSeidel;
        minIter         1;
    }

Quote:
Originally Posted by zyliao View Post
I also a little confused about the exact meaning of “No Iterations X” in the log file. As you can see in my results, X can equal to nonzero in the converged cases.
The log file is showing you how many inner iterations the linear systems solver is taking to reach the tolerances you have set in the fvSolution file. This should generally be nonzero (an exception is a diagonal solver that does not have to iterate to solve), else the solver is not doing any work. In your case that you shared above, the Ux and p equations showed 0 inner iterations, which is a sign that your tolerances needed to be lowered.

Quote:
BTW, I wonder what’s the difference between the “tolerance” and “residualControl”?
What are the exact meanings of “tolerance”, “relTol” and “residualControl”? What do these three values control? What settings are appropriate for them?
You need to do some homework on this - see the user guide, and perhaps have a read of https://doc.cfd.direct/notes/cfd-gen...iples/contents. Suffice it to say that tolerance and relTol controls the inner iterations, and determine when the linear solver has "converged" sufficiently, whilst residualControl controls when the whole simulation has "converged".
Tobermory is offline   Reply With Quote

Old   April 24, 2022, 23:55
Smile
  #15
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 4
zyliao is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
In fvSolution, just add a line for each variable you want to apply it to, eg.:
Code:
    p
    {
        solver          GAMG;
        tolerance       1e-08;
        relTol          0.01;
        smoother        GaussSeidel;
        minIter         1;
    }


The log file is showing you how many inner iterations the linear systems solver is taking to reach the tolerances you have set in the fvSolution file. This should generally be nonzero (an exception is a diagonal solver that does not have to iterate to solve), else the solver is not doing any work. In your case that you shared above, the Ux and p equations showed 0 inner iterations, which is a sign that your tolerances needed to be lowered.


You need to do some homework on this - see the user guide, and perhaps have a read of https://doc.cfd.direct/notes/cfd-gen...iples/contents. Suffice it to say that tolerance and relTol controls the inner iterations, and determine when the linear solver has "converged" sufficiently, whilst residualControl controls when the whole simulation has "converged".
Hi Tobermory,

Thank you very much for your patience!

I have gone through the User Guide, it didn’t introduce much about the “No Iterations” and tolerance. I’ll refer to the book you recommended.
According to my limited understanding, the values of “No Iterations” will lower from a high value towards to 0, right? So, when the values of Ux & p equal to 0, does it means Ux & p have converged (i.e., stopped solving/iterating)? So a better result maybe that when the whole simulation is converged, all the “No Iterations” values equal to 0? I mean, each variables (Ux, Uy, p) converged, then the whole simulation converged?

And I have run some cases by adding the minIter and lowering the tolerances, hope they will show better results.
zyliao is offline   Reply With Quote

Old   April 25, 2022, 04:07
Default
  #16
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 670
Rep Power: 14
Tobermory will become famous soon enough
The main issue is that although the residual values are normalised, their magnitude can vary from problem to problem, so a solver tolerance value that works for one problem may not be effective in another. That's why you need to keep an eye on your log file and adjust your solver settings from case to case.

Quote:
According to my limited understanding, the values of “No Iterations” will lower from a high value towards to 0, right? So, when the values of Ux & p equal to 0, does it means Ux & p have converged (i.e., stopped solving/iterating)?
Umm - no, I don't think that that is the case. I don't think that the number of iterations for any of the solvers should ever drop to zero since otherwise the solution for some variables is not progressed in that iteration and my experience is that the solution then goes to junk.

For most SIMPLE simulations, you should have a small number of velocity and turbulence inner iterations (maybe even just one) and rather more pressure iterations - sometimes a few hundred. This should be the case all the way through to "convergence", i.e. until you decide that the solution is not changing significantly and you can stop the run. To decide the latter, use the residuals of course, but also monitor quantities that are of interest to you (eg velocity in a key point in the flow, macro quantity like drag on a wing, etc etc).
Tobermory is offline   Reply With Quote

Old   April 29, 2022, 13:02
Default
  #17
Senior Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5
joshwilliams is on a distinguished road
Quote:
Originally Posted by zyliao View Post
Hi AndreasPe
I tried the pressureInletUniformVelocity type for the inlet (cases name highlight by green), it indeed converges very fast, but the calculated outlet flow rate didn’t match the theoretical value (v = 0.4464 m/s) well.
I also tried the pressureInletVelocity type (cases name highlight by blue), it seems still has the stability and convergence problem.

In my experience with pressure driven flow, it is best when the inlet is pressureInletVelocity and the outlet is pressureInletOutletVelocity. See attached figure where the flowrate calculated by OpenFOAM shows excellent agreement to the analytical flowrate I design the pressure BCs to replicate.
Attached Images
File Type: png pressure-driven-flow-validation.png (12.6 KB, 35 views)
hydroRussian likes this.
joshwilliams is offline   Reply With Quote

Old   May 3, 2022, 23:45
Default
  #18
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 4
zyliao is on a distinguished road
Hi Tobermory,

You're right, the number of iterations do not need to drop to zero, I misunderstood this point.

Thank you very much for your patient and careful reply!

And I found that for my cases, if I set tolerances to 10e-8, residualControls to 10e-6, they can converge much better.
Tobermory likes this.
zyliao is offline   Reply With Quote

Old   May 3, 2022, 23:57
Default
  #19
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 4
zyliao is on a distinguished road
Hi Josh,

Thank you for you advice!

According to my newest result, if I set inlet is pressureInletVelocity and the outlet is zeroGradient, and set tolerances to 10e-8, residualControls to 10e-6, it can converge better and match the theoretical value well.

I'll try to set the outlet to pressureInletOutletVelocity to see if it can perform better!
zyliao is offline   Reply With Quote

Old   May 4, 2022, 02:35
Default
  #20
Senior Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5
joshwilliams is on a distinguished road
I am working on something similar; flow in human airways taken from CT scans, with time-varying pressure defined at outlets. For a simple one bifurcation case, the BCs I mentioned above work very well (as I showed). But when the geometry gets more complex it fails (timestep gets very small as few cells at the outlet have big courant number).


Is your geometry complex like this? What fvSchemes are you using? I think my velocity BCs and pressure BCs are okay, so I think there is something else causing this.
joshwilliams is offline   Reply With Quote

Reply

Tags
boundary condition, internal flow, pipe flow, simplefoam convergence, simplefoam pressure bc

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between p (pressure) and static pressure PeterShi OpenFOAM Post-Processing 2 March 19, 2019 16:23
pressure in incompressible solvers e.g. simpleFoam chrizzl OpenFOAM Running, Solving & CFD 13 March 28, 2017 05:49
Pressure difference at INLET and OUTLET. lovegne FLUENT 2 January 27, 2017 07:28
Neumann pressure BC and velocity field Antech Main CFD Forum 0 April 25, 2006 02:15
Hydrostatic pressure in 2-phase flow modeling (CFX4.2) HB &DS CFX 0 January 9, 2000 13:19


All times are GMT -4. The time now is 09:14.