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

Under-relaxation: Misunderstanding or bug?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Tobermory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2022, 04:52
Default Under-relaxation: Misunderstanding or bug?
  #1
New Member
 
Join Date: Dec 2019
Posts: 19
Rep Power: 7
c_023 is on a distinguished road
Hello,


I am currently having troubles understanding how OpenFOAM handles under-relaxation. As I understand it, under-relaxation of fields will result in only a fraction of the newly calculated value being taken as new result, which only makes sense for a steady-state solver. Under-relaxation of equations should (at least according to https://doc.cfd.direct/notes/cfd-gen...der-relaxation) be working on the level of the linear system solver, ensuring diagonal dominance and thus I would understand that choosing a certain equation under-relaxation factor should not have an influence on the final result (and therefore make sense for use in a transient simulation). Either I misunderstand the concept up to here, or there seems to be a bug. I noticed, that choosing an equation under-relaxation factor <1 will lead to what I would expect from field under-relaxation:


To reproduce this I took scalarTransportFoam (I tested it in Foundation versions OpenFOAM 6 and OpenFOAM 7) and modified the equation it solves for to the following:




Code:
while (simple.correctNonOrthogonal())
 {
    fvScalarMatrix HEqn
    (
        fvm::ddt(H)                                           
       ==
        heatSource
    );                              
    HEqn.relax();
    HEqn.solve();
}
Therefore, I only solve the simple case of a constant heat source. I use SIMPLE without NonOrthogonalCorrectors to transiently solve this equation. If I now choose an equation under-relaxation factor alpha, only (1-alpha)*heatSource end up in my field H after each time step. If I choose field under-relaxation, the correct amount of my heatSource is added in each time step. I would expect it to be the other way round?
I tested both PBiCGStab and smoothSolver, using different values for tolerance, with no difference in this behaviour.


If someone is interested I can also make availabe the solver and a quick test case (which take about 10 seconds to compile and 10 seconds to run).


Any advice is very much appreciated.
c_023 is offline   Reply With Quote

Old   May 3, 2022, 07:44
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14
Tobermory will become famous soon enough
I suspect it's due to the way that you have defined your source term - as a scalar field instead of using the fvm::Su function. Take a look at kEpsilon.C, as an example. Maybe try rewriting the source term and let us know if that fixes the problem.
c_023 likes this.
Tobermory is offline   Reply With Quote

Old   May 3, 2022, 08:31
Default
  #3
New Member
 
Join Date: Dec 2019
Posts: 19
Rep Power: 7
c_023 is on a distinguished road
@Tobermory, thanks for the suggestion. I tried using fvm::Su(), but it did not change the outcome.

If I am correct, fvm::Su() would add the source term as implicit, while adding a volScalarField directly will have it treated as explicit, correct?
c_023 is offline   Reply With Quote

Old   May 3, 2022, 12:55
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14
Tobermory will become famous soon enough
Hmm - that's odd. If you can share your testcase, I am happy to take a look.

PS Su is the explicit term, Sp would be the implicit term.
Tobermory is offline   Reply With Quote

Old   May 5, 2022, 04:52
Default
  #5
New Member
 
Join Date: Dec 2019
Posts: 19
Rep Power: 7
c_023 is on a distinguished road
Thanks for your help. In the attached folder you can find two folders, "scalarTransportFoam" (the solver) and "energyAnalysis" (the case). Solver compilation should work fine using the Allwmake script. You may need to change the location for sourcing your openfoam installation's bashrc in the case's Allrun3D.sh script (also depending on which OpenFOAM version you want to use).


Try out different values for the relaxationFactor in fvSolution and look at the output in the log file.
Attached Files
File Type: zip relaxationTests.zip (10.5 KB, 3 views)
c_023 is offline   Reply With Quote

Reply

Tags
openfoam 6, openfoam 7, source term, under-relaxation


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
Lets talk about relaxation factor optimization chriss85 OpenFOAM Running, Solving & CFD 35 June 21, 2019 10:54
Long output in terminal. ssa_cfd OpenFOAM Running, Solving & CFD 1 March 18, 2019 06:25
About equation relaxation chriss85 OpenFOAM Running, Solving & CFD 1 May 2, 2017 20:52
buoyantPimpleFoam - no relaxation Tobi OpenFOAM Bugs 1 January 14, 2014 18:14
Relaxation and convergence sammi Phoenics 0 March 20, 2008 04:32


All times are GMT -4. The time now is 12:47.