CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   plot of residuals (https://www.cfd-online.com/Forums/openfoam/110264-plot-residuals.html)

hawkeye321 December 6, 2012 09:57

plot of residuals
 
Hi
I am solving a set of equations which are coupled with he (U, V) momentum. The equations are solved in an implicit manner, i.e. in each time step all the equations are solved couple of times (~ 18). So, as you might expect, for each time step my final log file includes residuals at all the the iterations (~18 residual for each time step). Do you have any idea how I can filter this file to get the final residuals at each time step?

mmkr825 December 6, 2012 13:01

Hi,

Just Follow the steps:

step1. start calculation and make it write out a log-file.
e.g: icoFoam > log &
step2: If desired you can open a new console window of the main case folder (when your case is runniong) and Follow the text -output by the command tail -f log
To stop reading the file constantly just use ctrl-c
step3: By using gnuplot with in the main case folder you have to put a text file with a name "Residuals" having

Code:

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

Step4: Execute the command
gnuplot Residuals-
then you can get residuals plot.

Cheers
Mallikarjuna

hawkeye321 December 6, 2012 17:09

mmkr825

Thanks for your answer, but I have already tried it. It gives me a plot of all the residuals and not the plot of final residual (residual of the final iteration) at each time step.

Lieven December 7, 2012 06:51

Dear Mahdi,

You can run
$ foamLog log

which creates a new directory 'logs' in which you can find all residuals (initial, final, etc.) in separate files for all variables. You can make a plot of the residuals in function of the iteration number or in function of the simulated time. Suppose you want to make a plot of the final residual of Ux, the gnuplot command will look like:

* In function of the simulated time:
Code:

plot 'UxFinalRes_0' u 1:2 w l
* In function of the time step:
Code:

plot 'UxFinalRes_0' u 0:2 w l
Just out of curiosity, why whould one be interested in the final residual?

Kind regards,


L

Bernhard December 7, 2012 07:54

You can also use pyFoam: http://openfoamwiki.net/index.php/Co...mPlotRunner.py

hawkeye321 December 7, 2012 09:05

Dear Lieven
Thanks for your wonderful comments. I will try it very soon.
The reason that I want to see this plot is that, in my final velocity contours, I have some flow into the wall, which I defiantly because of relatively low residuals (Right???). So, I want to see these plots to make sure my solution has acceptable level of convergence. If you have better ideas, i would love to hear.

Mahdi,


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