CfdOF default maxCo/maxAlphaCo in controlDict

A subforum specific to the development of the OpenFoam-based workbenches ( Cfd https://github.com/qingfengxia/Cfd and CfdOF https://github.com/jaheyns/CfdOF )

Moderator: oliveroxtoby

User avatar
markinca
Posts: 56
Joined: Sun Apr 30, 2023 2:41 pm

CfdOF default maxCo/maxAlphaCo in controlDict

Post by markinca »

For transient analysis, it is useful to be able to change the fields in controlDict for maxCo and maxAlphaCo. Documentation recommends < 0.7 but the default seems to be 5 which seems very high and there doesn't seem to be a way to change it other than manually editing controlDict. Am I missing something?

Also, Convergence Tol does not allow for small residuals (e.g. 1e-4). The toggle up/down steps in integer values which is much too large for residuals.
User avatar
oliveroxtoby
Posts: 812
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by oliveroxtoby »

markinca wrote: Mon May 01, 2023 7:57 pm For transient analysis, it is useful to be able to change the fields in controlDict for maxCo and maxAlphaCo. Documentation recommends < 0.7 but the default seems to be 5 which seems very high and there doesn't seem to be a way to change it other than manually editing controlDict. Am I missing something?
There are various settings which can be changed in combination and the idea is to have a default which gives decent computational time as well as being robust and sufficintly accurate. The philosophy is not to expose potentially baffling settings to the user unless it's really necessary. Are you finding that the defaults don't work for your use case?
Also, Convergence Tol does not allow for small residuals (e.g. 1e-4). The toggle up/down steps in integer values which is much too large for residuals.
You can use the 'expression editor' at the far right when changing the value to input smaller values than the FreeCAD number of decimal places. I think we're limited here by how FreeCAD format numbers in the data panel, and I'm not actually sure if that can be changed.
User avatar
markinca
Posts: 56
Joined: Sun Apr 30, 2023 2:41 pm

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by markinca »

Thanks for the response.

The simulation appears to be stable but I am more concerned about accuracy. From what I have read, large current numbers can result in inaccurate results especially in highly turbulent flow multiphase transient analyses.

https://www.simscale.com/knowledge-base ... nt-number/
For transient multiphase runs, keep the maximum Courant number smaller than 1. For other analysis types, using a maximum Courant number larger than 1 is possible/desired, as long as the best practices for accuracy and stability (above) are observed
So when the maxCo value is set to 5, was this calculated from the simulation inputs or is it always set 5 no matter what?
User avatar
markinca
Posts: 56
Joined: Sun Apr 30, 2023 2:41 pm

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by markinca »

If anyone is interested, you can change the default templates of CfdOF for any of the openfoam input files from this folder:

C:\Users\user\AppData\Roaming\FreeCAD\Mod\CfdOF\Data\Templates\case\system

I set maxCO and maxAlphaCo to default to 0.7 instead of 5.
User avatar
markinca
Posts: 56
Joined: Sun Apr 30, 2023 2:41 pm

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by markinca »

So I just wanted to show you what the impact is for courant number. These two pictures of flow mixture (water and air) are for the same time period but one has a courant of 5 and the other 1. If you will notice that the 5 version has air inside the venturi nozzle which should not be there. So the high courant number is creating a lot of error. The type of simulation is very critical when choosing courant number so courant should really be an explicit input.

Courant=5
pic5.png
pic5.png (42.38 KiB) Viewed 1466 times
Courant=1
pic1.png
pic1.png (26.56 KiB) Viewed 1466 times
User avatar
oliveroxtoby
Posts: 812
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by oliveroxtoby »

markinca wrote: Wed May 10, 2023 2:11 pm So I just wanted to show you what the impact is for courant number. These two pictures of flow mixture (water and air) are for the same time period but one has a courant of 5 and the other 1. If you will notice that the 5 version has air inside the venturi nozzle which should not be there. So the high courant number is creating a lot of error. The type of simulation is very critical when choosing courant number so courant should really be an explicit input.
Fair enough. I have added them as settings in the solver object.

Would you perhaps be willing to share this case setup? It would be a helpful example to use in improving the default settings.
User avatar
markinca
Posts: 56
Joined: Sun Apr 30, 2023 2:41 pm

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by markinca »

Attached is the project.

Note that I have another thread regarding this project here:

viewtopic.php?style=5&t=78096&sid=81099 ... c1d9db4866

The problem is that CFDof or FreeCad stops responding after several minutes of run time so you may need to kill FreeCAD at some point. If you don't, then memory is quickly consumed and the PC will run out of memory. I have 32GB of RAM. I believe there is a memory leak somewhere.

Thanks
Attachments
Spa_Jet_TR.FCStd
(59.32 KiB) Downloaded 34 times
User avatar
oliveroxtoby
Posts: 812
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by oliveroxtoby »

markinca wrote: Wed May 10, 2023 8:29 pm Attached is the project.
Thank you.
User avatar
markinca
Posts: 56
Joined: Sun Apr 30, 2023 2:41 pm

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by markinca »

I have one follow up question regarding this topic.

One thing that I noticed is that in the fvSolution file, nOuterCorrectors is always set to 1. From what I understand, when performing transient analysis, this means that PISO is always used instead of the PIMPLE algorithm. According to the following documentation, if you use a courant higher than 1 (default=5), you should be using the PIMPLE algorithm with nOuterCorrectors > 1:

https://openfoamwiki.net/index.php/Open ... OAM#Case_C

PIMPLE is useful in that it basically turns an explicit solution into an implicit solution and significantly reduces processing time.

Is my understanding correct?
User avatar
oliveroxtoby
Posts: 812
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: CfdOF default maxCo/maxAlphaCo in controlDict

Post by oliveroxtoby »

markinca wrote: Sun May 14, 2023 2:26 pm I have one follow up question regarding this topic.

One thing that I noticed is that in the fvSolution file, nOuterCorrectors is always set to 1. From what I understand, when performing transient analysis, this means that PISO is always used instead of the PIMPLE algorithm.
Yes
According to the following documentation, if you use a courant higher than 1 (default=5), you should be using the PIMPLE algorithm with nOuterCorrectors > 1:

https://openfoamwiki.net/index.php/Open ... OAM#Case_C
I'm not sure I agree that there is a hard-and-fast Co < 1 limit for PISO. That is the stability limit for an entirely explicit scheme, but PISO has implicit aspects to it. The same applies to the implicit MULES scheme use for the alpha advection - Co < 1 isn't required as a stability limit, although it does improve accuracy.
PIMPLE is useful in that it basically turns an explicit solution into an implicit solution and significantly reduces processing time.
You are only likely to see a gain in processing time if taking much larger time steps. (5 correctors with Co = 5 costs the same as a PISO solution with Co = 1, so no great advantage there.)

I tried to select the current defaults to give decent accuracy and processing time while being as hands-off as possible for the user, but this was an initial estimate that I'm sure can be improved upon. It's not an easy task though as there are tradeoffs.
Post Reply