# [Tutorials] Tutorial of how to plot residuals !

 Register Blogs Members List Search Today's Posts Mark Forums Read

 November 19, 2011, 18:34 #41 Senior Member   Sandy Lee Join Date: Mar 2009 Posts: 213 Rep Power: 18 It's ok, I think. If p equation gets convergent, you can judge other equations have got convergent early.

 April 19, 2012, 03:53 #42 Member   Arina Join Date: Oct 2009 Location: Belarus Posts: 71 Rep Power: 16 Hello, everyone! I use scripts for plot residuals and coefficients (thank you VERY MUCH). Residuals are plotting, but coefficients - not. I have only grid of graphics, and a tip, that lift coeff have red color, drag - green. I look inside file and change it according my solver. Did I do something wrong? Or how can I get the graphic of force coefficients?

 August 13, 2012, 06:29 #43 New Member   tanzil tjhin Join Date: Jan 2012 Posts: 4 Rep Power: 14 Thanks Wolfgang for the great script, I was wondering what syntax is needed to plot Residual vs Time in transient case instead of Residual vs Iteration. Does anyone have an Idea? Regards

 August 14, 2012, 01:33 #44 Senior Member     ata kamyabi Join Date: Aug 2009 Location: Kerman Posts: 323 Rep Power: 17 Hi May be you can use pyFoam

 November 2, 2012, 02:05 #45 Member   Suranga Dharmarathne Join Date: Jan 2011 Location: TX, USA Posts: 39 Rep Power: 15 how to save pyFoamPlotWatcher.py generated gunplots at the end of the run. BR, Suranga.

November 21, 2012, 12:00
#46
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
Quote:
 Originally Posted by sdharmar how to save pyFoamPlotWatcher.py generated gunplots at the end of the run. BR, Suranga.
With all pyFoam-utilities the option "--help" is your friend. The option you're looking for is callled --hardcopy I believe (just because I write this stuff doesn't mean that I know how to use it ). There are also options to write the data to postprocess it with other programs (going through pyFoamRedoPlot.py even allows you to write CSV-files that you can directly use in a Spreadsheet)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

 November 29, 2012, 16:41 #47 New Member   Join Date: Nov 2012 Location: Scotland, UK Posts: 19 Rep Power: 13 This is quite nice, but is there anyway to import the data from the log file into excel for some nicer looking graphs?

 November 29, 2012, 16:50 #48 Senior Member     mauricio Join Date: Jun 2011 Posts: 172 Rep Power: 17 hi! u can create a bash script to create a txt/csv like file so u can import it to excel.. the command "awk" is the best call imo gl GPan1 likes this. __________________ Best Regards /calim "Elune will grant us the strength"

November 29, 2012, 17:55
#49
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
Quote:
 Originally Posted by GPan1 This is quite nice, but is there anyway to import the data from the log file into excel for some nicer looking graphs?
"This" you mean hardcopy in pyFoamPlotWatcher?

One possible way was described in the next sentence: read the file with the pickled data with pyFoamRedoPlot.py and instead of generating images write CSV-files (CSV is read by almost everyone including Excel)

Other way would be to let the Watcher write files with the --write-files-option and use pyFoamConvertToCSV.py
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

 November 29, 2012, 18:16 #50 New Member   Join Date: Nov 2012 Location: Scotland, UK Posts: 19 Rep Power: 13 oops, no I meant using gnuplot however I'll take a look at using pyFoamWatcher. CSV data would be perfect. Thanks!

November 29, 2012, 19:10
#51
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
Quote:
 Originally Posted by GPan1 oops, no I meant using gnuplot however I'll take a look at using pyFoamWatcher. CSV data would be perfect. Thanks!
In the thread tree your posting showed up as a response to one of my postings. And that was all context there was for the "this". Didn't mean to impose PyFoam on you
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

 November 30, 2012, 04:20 #52 New Member   Join Date: Nov 2012 Location: Scotland, UK Posts: 19 Rep Power: 13 Ah right, the quick reply function is different here compared to other forums. Usually just adds a comment onto the thread without specifying who you reply to. Found an easier way, simply copy and paste the log file into excel, split into columns by delimiting (use space and comma). Use an if/else function to select the row of the column that has (for me Uy) then return the row 3 columns to the right or return zero. Filter out the zeros, copy and paste the non-zero data into a new sheet as 'values' and you're sorted.

November 30, 2012, 12:16
#53
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
Quote:
 Originally Posted by GPan1 Ah right, the quick reply function is different here compared to other forums. Usually just adds a comment onto the thread without specifying who you reply to. Found an easier way, simply copy and paste the log file into excel, split into columns by delimiting (use space and comma). Use an if/else function to select the row of the column that has (for me Uy) then return the row 3 columns to the right or return zero. Filter out the zeros, copy and paste the non-zero data into a new sheet as 'values' and you're sorted.
Well. Whatever you consider easy
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

December 7, 2012, 10:25
Problems with plotting by gnuplot, simpleFoam Residuals
#54
Senior Member

Sören
Join Date: Mar 2012
Posts: 102
Rep Power: 14
Hi foamers,

I have a maybe stupid question about how to plot the residuals of a simpleFoam Simulation.

I'm used to pyFoam but this is no longer an option so I've tried gnuplot and the script provided by W.Heydlauff.
As I understand the script it should plot the Final Residual of the log-file, right? But when I use it now it gives me the Initial Residual of the log-file. How comes?

Here is my gnuplot-script:

Quote:
 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 p' | cut -d' ' -f9 | sed -n 'p;N;N' | tr -d ','" title 'p' with lines pause 1 reread
The Log-file and my plot are attached.

Attached Images
 Residuals_Baffle_seriell.jpg (29.4 KB, 301 views)
Attached Files
 Log.tar.gz (87.2 KB, 79 views) Residuals_Baffle_seriell.png.tar.gz (11.6 KB, 47 views)

 December 7, 2012, 11:33 #55 New Member   tanzil tjhin Join Date: Jan 2012 Posts: 4 Rep Power: 14 It should be f13 instead of f9 to plot Final residual. regards, Tanzil

 December 7, 2012, 11:44 #56 Senior Member   Sören Join Date: Mar 2012 Posts: 102 Rep Power: 14 Sure? I've tried f12, f13 and f14 but these tries just produced error-messages...

December 10, 2012, 06:31
#57
New Member

Dima Risch
Join Date: Jun 2011
Location: Cologne
Posts: 22
Rep Power: 14
Hi Sören,

with your gnuplot-script and the changes described by Tanzil the plot works without errors

Quote:
 set logscale y set title "Residuals" set ylabel 'Residual' set xlabel 'Iteration' plot "< cat Log | grep 'Solving for Ux' | cut -d' ' -f13 | tr -d ','" title 'Ux' with lines,\ "< cat Log | grep 'Solving for Uy' | cut -d' ' -f13 | tr -d ','" title 'Uy' with lines,\ "< cat Log | grep 'Solving for Uz' | cut -d' ' -f13 | tr -d ','" title 'Uz' with lines,\ "< cat Log | grep 'Solving for p' | cut -d' ' -f13 | sed -n 'p;N;N' | tr -d ','" title 'p' with lines pause 1 reread
regards,
dima
Attached Images
 Residuals_Baffle_seriell_finalRes.jpg (26.1 KB, 249 views)

 December 10, 2012, 06:43 #58 Senior Member   Sören Join Date: Mar 2012 Posts: 102 Rep Power: 14 Thanks, I copied your script - working fine. I guess that I've overlooked something in my script... Thnaks for the quick help.

 December 18, 2012, 12:15 how draw pressure coefficient in openFoam #59 Senior Member   saeideh mohamadi Join Date: Aug 2012 Posts: 229 Rep Power: 14 hi dear Wolfgang; it was really useful post, it help me alot. would you please tell us how can draw pressure coefficient on airfoil using paraview? our multi element airfoil have been solved with openFoam software. thank you very much

 January 4, 2013, 08:03 How about parallel situation #60 Member   Jianye Xia Join Date: Mar 2009 Posts: 32 Rep Power: 18 Hi, can this method applicable to parallel cases?