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

plot of residuals

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 3 Post By mmkr825
  • 1 Post By Lieven
  • 1 Post By Bernhard

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 6, 2012, 10:57
Default plot of residuals
  #1
Member
 
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 14
hawkeye321 is an unknown quantity at this point
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?
hawkeye321 is offline   Reply With Quote

Old   December 6, 2012, 14:01
Default
  #2
Member
 
M Mallikarjuna Reddy
Join Date: Jul 2012
Posts: 91
Rep Power: 14
mmkr825 is on a distinguished road
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
vsammartano, calf.Z and aero_head like this.
mmkr825 is offline   Reply With Quote

Old   December 6, 2012, 18:09
Default
  #3
Member
 
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 14
hawkeye321 is an unknown quantity at this point
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.
hawkeye321 is offline   Reply With Quote

Old   December 7, 2012, 07:51
Default
  #4
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
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
hawkeye321 likes this.
Lieven is offline   Reply With Quote

Old   December 7, 2012, 08:54
Default
  #5
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
You can also use pyFoam: http://openfoamwiki.net/index.php/Co...mPlotRunner.py
hawkeye321 likes this.
Bernhard is offline   Reply With Quote

Old   December 7, 2012, 10:05
Default
  #6
Member
 
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 14
hawkeye321 is an unknown quantity at this point
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,
hawkeye321 is offline   Reply With Quote

Reply


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
[Tutorials] Tutorial of how to plot residuals ! wolle1982 OpenFOAM Community Contributions 171 February 20, 2024 03:55
plot residuals in multiregion solver val46 OpenFOAM 4 December 12, 2016 07:06
Residuals Plot kamalipour FLUENT 2 December 15, 2011 04:44
URGENT: plot residuals for complete simulation?? Khan FLUENT 1 February 1, 2007 13:35
residuals Karl CFX 2 June 25, 2003 00:13


All times are GMT -4. The time now is 05:28.