Tutorial of how to plot residuals !
Posted February 6, 2018 at 19:59 by TurbJet
Quote:
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
Step 2:
If desired you can open a new console-window of the main-case-folder and follow the text-output by the command
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:
Execute the command
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
Step5:
Plotting the real forces is also easy. Proceed identically like in "Step 4" but be sure to set
Using the attached text-files, remove the ".txt" first.
Hope that helps somebody.
Greetings,
Wolfgang
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 yThe pause-command sets the seconds till reload. Deletion makes it faster in some cases.
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
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 magnitudein the controlDict.
lRef 1.0; //reference length
Aref 1.632653; //reference area
Using the attached text-files, remove the ".txt" first.
Hope that helps somebody.
Greetings,
Wolfgang
Total Comments 0