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

Plotting Residuals

Register Blogs Community New Posts Updated Threads Search

Like Tree12Likes
  • 9 Post By Marta
  • 1 Post By megacrout
  • 2 Post By joel.lehikoinen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 17, 2009, 00:18
Default Plotting Residuals
  #1
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 323
Rep Power: 17
ata is on a distinguished road
Hi foamers
I have some problem with residual plotting in OF. I don't know how can I plot residuals that I have saved in log file? Can any one help me?
Thanks

Ata
ata is offline   Reply With Quote

Old   November 17, 2009, 01:27
Default Plotting Residuals
  #2
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 323
Rep Power: 17
ata is on a distinguished road
Hi
Thanks I got it.

Ata
ata is offline   Reply With Quote

Old   November 17, 2009, 09:18
Default
  #3
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hello ,
to plot the residuals you have to first run the foamLog script on your log file, if you are using OF-1.5

just run
FoamLog logfile

it will produce a directory of name logs/. This will contain all the files you need for plotting. Use simple gnuplot script to plot the values.

If you are running a unsteady calculation then you can plot the final residuals files against the times to verify if your equation is converged at all time steps.
bye
hope this helps
K.Suresh kumar
kumar is offline   Reply With Quote

Old   November 17, 2009, 10:52
Default
  #4
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 620
Blog Entries: 6
Rep Power: 24
elvis will become famous soon enough
you can use pyfoam for a couple of nice features like plotting residuals
http://openfoamwiki.net/index.php/Co...mPlotRunner.py

grettings

elvis
elvis is offline   Reply With Quote

Old   November 29, 2009, 02:20
Default Plotting Residuals
  #5
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 323
Rep Power: 17
ata is on a distinguished road
Hi every one
When I try to plot residuals with gnuplot I got this error:
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
^
"Residuals", line 10: warning: Skipping data file with no valid points

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
^
"Residuals", line 10: warning: Skipping data file with no valid points

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
^
"Residuals", line 10: warning: Skipping data file with no valid points

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
Can any body help me?
Regards

Ata
ata is offline   Reply With Quote

Old   November 29, 2009, 02:22
Default Plotting Residuals
  #6
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 323
Rep Power: 17
ata is on a distinguished road
Hi Elvis
Thank you
Can you send me some tutorial.
Thanks

Ata
ata is offline   Reply With Quote

Old   November 29, 2009, 12:55
Default
  #7
Member
 
Marta's Avatar
 
Marta Lazzarin
Join Date: Jun 2009
Location: Italy
Posts: 71
Rep Power: 16
Marta is on a distinguished road
Hi ata,
I found this piece of advice last month when i needed to find out how to plot the residuals of a simulation. It is taken from another section of this forum, I followed this steps and I managed to plot the residuals, so I think it can help you too.

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.

This way I did not have any errors by gnu plot, maybe it could help you too.

Marta
Marta is offline   Reply With Quote

Old   November 29, 2009, 14:05
Default
  #8
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 323
Rep Power: 17
ata is on a distinguished road
Hi Marta
Thank you very much but I already have seen this tutorial and when I try it I got that error.
Best regards

Ata
ata is offline   Reply With Quote

Old   October 29, 2010, 21:10
Default Fix for "FinalResiduals", line 8: warning:
  #9
lth
Member
 
lth's Avatar
 
lth
Join Date: Mar 2009
Location: Madison, WI, USA
Posts: 37
Blog Entries: 45
Rep Power: 17
lth is on a distinguished road
Hi Foamers,

Using output& folder to monitor jobs and FinalResidual was giving similar errors.
------------------------------------
"FinalResiduals", line 8: warning: Skipping data file with no valid points openfoam
"Final Residuals", line 8: x range is invalid
-----------------------------------

By quick switch of names in the FinalResidual code
to "< cat output | ... from "< cat log | ... has it working fine.

Best, Lori
lth is offline   Reply With Quote

Old   November 23, 2010, 13:07
Default
  #10
New Member
 
Bertrand Delvaux
Join Date: Apr 2010
Posts: 29
Rep Power: 16
Bertrand is on a distinguished road
Hello Marta,

Thanks a lot for posting this kind of tutorial : makes OF life much easier! ;-)
As I am not really familiar with gnuplot syntax, I was wondering what exactly we need to change in Residuals.txt in order to plot the Courant Number mean and max?

Best regards,

Bertrand
Bertrand is offline   Reply With Quote

Old   November 23, 2010, 13:23
Default
  #11
New Member
 
Bertrand Delvaux
Join Date: Apr 2010
Posts: 29
Rep Power: 16
Bertrand is on a distinguished road
OK,

Sorry for the silly question, I'm new to Linux as well, but I just found how to deal with the syntax...
Bertrand is offline   Reply With Quote

Old   July 7, 2011, 07:44
Default
  #12
Member
 
Tibo
Join Date: Jun 2011
Posts: 68
Rep Power: 14
megacrout is on a distinguished road
Quote:
Originally Posted by ata View Post
Hi Marta
Thank you very much but I already have seen this tutorial and when I try it I got that error.
Ata
Hey ata.

This happens if the Residuals-file contains more terms to look for than there are in the log file (e.g. k or epsilon). Either delete the "reread" command at the end of the Residuals-file (ugly solution) or delete the lines that make gnu look for parameters that it is never going to find.

Tibo
Bollonga likes this.
megacrout is offline   Reply With Quote

Old   July 8, 2011, 02:50
Default
  #13
New Member
 
Joel Lehikoinen
Join Date: Jun 2011
Posts: 26
Rep Power: 14
joel.lehikoinen is on a distinguished road
Quote:
Originally Posted by ata View Post
Hi every one
When I try to plot residuals with gnuplot I got this error:
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
^
"Residuals", line 10: warning: Skipping data file with no valid points
...

Can any body help me?
Regards

Ata
This script doesn't work out of the box for all solvers, you have to modify it, depending on your turbulence model and the algorithm (especially number of loops) you are using. You may need to twiddle with the field specified for the cut command. The best way to check if it works is to just run this command in a terminal:
Code:
cat log | grep 'Solving for Ux' | cut -d' ' -f9
This should output a floating point number followed by a comma. If it doesn't, then you need to see which field it is actually reading (see man pages for cut).

Also, if you are running some other model than k-omega the script will be unable to plot omega (naturally). And if you are running a solver with buoancy, then you need to grep p_rgh instead of p. This script is very handy, it just requires some Unix-fu to get it working.
shipman and FrankFlow like this.
joel.lehikoinen 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 02:55
what to monitor besides residuals? franzdrs FLUENT 5 March 21, 2013 03:59
Plotting lift and drag coefficient residuals Tunc Siemens 0 February 6, 2006 10:25
Convergence - scaled vs unscaled residuals HS FLUENT 1 November 7, 2005 05:45
Plotting residuals for solid Julie Siemens 1 October 29, 2004 06:24


All times are GMT -4. The time now is 22:27.