CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums

Tutorial of how to plot residuals !

Register Blogs Community New Posts Updated Threads Search

Rate this Entry

Tutorial of how to plot residuals !

Posted May 31, 2018 at 07:31 by yashjo

Found this very helpful.

Quote:
Originally Posted by wolle1982 View Post
Hi all,

since apearantly noone has an idea of how to plot the residuals of a calculation on-the-fly, I will give a small manual on that:

Tutorial on "How to plot the residuals (and forces) graphically on screen on-the-fly"

Step 1:
Start the calculation and make it write out a log-file. for example
turbFoam >log
"log" is the name of the log-file to be output. It is written into the main-case-folder.

Step 2:
If desired you can open a new console-window of the main-case-folder and follow the text-output by the command
tail -f log
"log" is the name of the log-file to be read in. To stop reading the file constantly just use Crtl+C

Step 3:
To plot the residuals graphically on the screen you can use gnuplot that is delivered with linux already.
Within the main-case-folder you have to put a text file with a name e.g. "Residuals"
(also see attachments).
The file should contain the following gnuplot properties:
set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Iteration'
plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines,\
"< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines,\
"< cat log | grep 'Solving for Uz' | cut -d' ' -f9 | tr -d ','" title 'Uz' with lines,\
"< cat log | grep 'Solving for omega' | cut -d' ' -f9 | tr -d ','" title 'omega' with lines,\
"< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines,\
"< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines
pause 1
reread
The pause-command sets the seconds till reload. Deletion makes it faster in some cases.

Execute the command
gnuplot Residuals -
in the main-case-folder.

Step 4:
Another good indicator for the calculations convergence is the forces-plot. Therefore you have to set the function in the controlDict that calculates the forces and forceCoeffs. See thread http://www.cfd-online.com/Forums/ope...es-of15-3.html or attachments.

Be sure to have the properties for gnuplot in the main-case-folder (see attachments).

You have the adapt the folder-name where the forceCoeffs.dat is inside before.

While the calculation runs you also can use the gnuplot command
gnuplot forceCoeffs -
in the main-case-folder. When the forces seem to not change any more, the pressure allocation must be constantly what makes the convergent case proofed.

Step5:
Plotting the real forces is also easy. Proceed identically like in "Step 4" but be sure to set
magUInf 1.0; //free stream velocity magnitude
lRef 1.0; //reference length
Aref 1.632653; //reference area
in the controlDict.

Using the attached text-files, remove the ".txt" first.

Hope that helps somebody.

Greetings,
Wolfgang
Posted in Uncategorized
Views 1378 Comments 2 Edit Tags Email Blog Entry
« Prev     Main     Next »
Total Comments 2

Comments

  1. Old Comment
    These may be old 6dollaressay wounds, struggles which you may have ‘resolved’ the easy way, and ideas to which you seem to be clinging on and you will be put to the challenge of facing them.
    permalink
    Posted November 4, 2018 at 17:53 by Cherri A. Solis
  2. Old Comment
    Hello guys,


    I'm pretty new to OF in this forum, so HELLO to all of you.


    Currently, I'm trying to plot the residuals using the foamMonitor function. I want to see them live. But I don't get the point how to realize this.


    As far as I know I have to call the function foamMonitor when the simulation is in progress. But then I have no access to the terminal....


    For example:
    ...

    blockMesh
    checkMesh
    icoFoam
    --> Simulation is running
    foamMonitor?



    I hope you get the point and you can help me.


    Thanks in advance,
    Manni
    permalink
    Posted November 22, 2019 at 06:02 by manni87
 

All times are GMT -4. The time now is 23:46.