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 February 6, 2018 at 18:59 by TurbJet

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
How to plot residuals by Gnuplot
Posted in Uncategorized
Views 1474 Comments 0 Edit Tags Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT -4. The time now is 02:17.