CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

Tutorial of how to plot residuals !

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

Like Tree165Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   February 11, 2014, 06:03
Default
  #81
Member
 
Ilya
Join Date: Dec 2011
Location: Russia
Posts: 93
Blog Entries: 41
Rep Power: 6
skeptik is on a distinguished road
Quote:
Originally Posted by odin View Post
skript does not work with OpenFoam 2.1.1
It does not matter. Script uses standard unix-commands to work with txt log-file.
__________________
practice makes perfect
skeptik is offline   Reply With Quote

Old   February 12, 2014, 04:51
Default
  #82
New Member
 
Join Date: Oct 2013
Posts: 15
Rep Power: 4
pingat is on a distinguished road
Quote:
Originally Posted by Stephan8 View Post
Hey all,
i have a problem according to plotting the residuals. After the command gnuplot Residuals i got the following error:

Code:
at: write error: Broken pipe

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 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 8: 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 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 8: 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 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 8: 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 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 8: 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 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 8: x range is invalid
solving you problem is quite easy.
I think the problem is, that the cut utility cuts out the wrong part.

you should have a look at the "-f9" part of the script.

In your case you maybe need to cut out the 3. or 7. word and not the 9., just try it
pingat is offline   Reply With Quote

Old   February 12, 2014, 18:00
Default
  #83
New Member
 
Stephan
Join Date: Feb 2014
Posts: 2
Rep Power: 0
Stephan8 is on a distinguished road
Quote:
Originally Posted by pingat View Post
solving you problem is quite easy.
I think the problem is, that the cut utility cuts out the wrong part.

you should have a look at the "-f9" part of the script.

In your case you maybe need to cut out the 3. or 7. word and not the 9., just try it
Thank you for the idea, but if i use "-f3" i get the message "line 8: Bad data on line 1" with "-f7" i get same error than with -"f9"
Stephan8 is offline   Reply With Quote

Old   February 13, 2014, 11:17
Default
  #84
New Member
 
Join Date: Oct 2013
Posts: 15
Rep Power: 4
pingat is on a distinguished road
Quote:
Originally Posted by Stephan8 View Post
Thank you for the idea, but if i use "-f3" i get the message "line 8: Bad data on line 1" with "-f7" i get same error than with -"f9"
1. do you have checked that you named your log file right?

2. 3 or 5 where just ideas. seems like you cut out words.

you have to look into your log file, to get the right position in the line, where you got a search hit by your grep.

maybe you should have a look at, what this script reallys does. it's a nice exercise to get known to the grep and cut utilities.
Stephan8 likes this.
pingat is offline   Reply With Quote

Old   March 15, 2014, 08:50
Default pressure iterations -- final iteration final residual
  #85
New Member
 
Kai
Join Date: Mar 2014
Posts: 5
Rep Power: 4
ssboss is on a distinguished road
Hello all

First of all, Openfoam is PITA. Second of all, thanks for this very useful script. Now I am having an issue:

so my log file output looks like this:

Code:
smoothSolver:  Solving for Ux, Initial residual = 0.000427706, Final residual = 4.58245e-06, No Iterations 2
smoothSolver:  Solving for Uy, Initial residual = 0.00102392, Final residual = 1.18461e-05, No Iterations 2
GAMG:  Solving for p, Initial residual = 0.00490348, Final residual = 0.000327938, No Iterations 2
GAMG:  Solving for p, Initial residual = 0.000625867, Final residual = 4.67654e-05, No Iterations 3
GAMG:  Solving for p, Initial residual = 0.000200362, Final residual = 1.50974e-05, No Iterations 3
time step continuity errors : sum local = 1.33872e-07, global = -2.67987e-18, cumulative = 1.0102e-14
smoothSolver:  Solving for nuTilda, Initial residual = 0.000758284, Final residual = 7.80812e-06, No Iterations 2
Uncorrected Ubar = 0.886833	Ubar = 1.06	pressure gradient correction = 8749.53	pressure gradient = 13
ExecutionTime = 1062.22 s  ClockTime = 1551 s
So, as you can see, my pressure has 3 iterations, and I wish to plot the final residual value from the last iteration. My Residual.H script looks like this:

Code:
set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Time'
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 p' | cut -d' ' -f13 | sed -n 'p;N;N' | tr -d ','" title 'p' with lines,\
"< cat log | grep 'Solving for nuTilda' | cut -d' ' -f13 | tr -d ','" title 'nuTilda' with lines
reread
What is happening, as far as I can see is that my gnuplot is plotting the final residual of the first iteration for pressure p. So note my final residual for first iteration is around 3e-04, and my final residual for last iteration is around 1e-05. What I am seeing in the pressure residual plot is of order 1e-04.

Can anyone tell me if there is something wrong with my code? If not how should I go about plotting final residual of last pressure iteration? Thank you very very much.
ssboss is offline   Reply With Quote

Old   April 26, 2014, 09:06
Default
  #86
New Member
 
wubin
Join Date: Mar 2013
Posts: 9
Rep Power: 5
nuaawubin is on a distinguished road
nice ,thks for sharing
nuaawubin is offline   Reply With Quote

Old   May 6, 2014, 23:45
Default
  #87
New Member
 
Mohammed Ameenuddin
Join Date: Feb 2014
Posts: 15
Rep Power: 4
ameen@cfd is on a distinguished road
Hello everyone,

I have used pyfoam to plot residuals but when I use parallel, I am not able to get the plots. Can anyone tell how can I make pyfoam to plot residuals when running in parallel.

Thank you
ameen@cfd is offline   Reply With Quote

Old   May 7, 2014, 05:08
Default
  #88
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,920
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by ameen@cfd View Post
Hello everyone,

I have used pyfoam to plot residuals but when I use parallel, I am not able to get the plots. Can anyone tell how can I make pyfoam to plot residuals when running in parallel.

Thank you
I guess you'll have to be more specific: I use it for parallel runs all the time (without problems)

Bernhard
__________________
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
gschaider is offline   Reply With Quote

Old   May 7, 2014, 06:14
Default
  #89
New Member
 
Mohammed Ameenuddin
Join Date: Feb 2014
Posts: 15
Rep Power: 4
ameen@cfd is on a distinguished road
I am using scotch method to decompose my problem into two processors.
I used mpirun -np 2 simpleFoam -parallel > log& command to start my simulations.
Later I used pyFoamPlotWatcher.py log in order to plot my residuals but I get

gnuplot > plot
line 0: function to plot expected

but I don't find the output being generated.

Thank you
ameen@cfd is offline   Reply With Quote

Old   May 7, 2014, 09:01
Default
  #90
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,920
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by ameen@cfd View Post
I am using scotch method to decompose my problem into two processors.
I used mpirun -np 2 simpleFoam -parallel > log& command to start my simulations.
Later I used pyFoamPlotWatcher.py log in order to plot my residuals but I get

gnuplot > plot
line 0: function to plot expected

but I don't find the output being generated.

Thank you
The Watcher doesn't care whether the run is serial or parallel. It only looks at the log. And that should be almost the same in both cases. Have you had a look at the log-file? (alternative possibility is that less than two timesteps have finished. PyFoam needs that many to start plotting properly)
__________________
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
gschaider is offline   Reply With Quote

Old   May 8, 2014, 00:27
Default
  #91
New Member
 
Mohammed Ameenuddin
Join Date: Feb 2014
Posts: 15
Rep Power: 4
ameen@cfd is on a distinguished road
I have looked into the log file and it seems to be as it should be.

After using command for Watcher this is I get

Quote:
gnuplot> set terminal x11
^
line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11 noraise
^
line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11
^
line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11 noraise
^
line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11
^
line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11 noraise
^
line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> plot
^
line 0: function to plot expected

smoothSolver: Solving for Ux, Initial residual = 0.000188298, Final residual = 6.1361e-06, No Iterations 4
smoothSolver: Solving for Uy, Initial residual = 0.000162305, Final residual = 5.29564e-06, No Iterations 4
Mean while these files have been generated

pyfoamFiles.tar.gz

log.tar.gz
ameen@cfd is offline   Reply With Quote

Old   May 8, 2014, 08:29
Default
  #92
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,920
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by ameen@cfd View Post
I have looked into the log file and it seems to be as it should be.

After using command for Watcher this is I get



Mean while these files have been generated

Attachment 30677

Attachment 30678
PLEASE use CODE not QUOTE for output because that makes answering easier (see above)

Anyway: the problem is that your gnuplot is missing the default terminal type x11? Two possibilities: it is Windows or similar. The other: the environment variable DISPLAY is not set (probably because you connected to a remote machine via ssh without the -X-option) and gnuplot decided (No DISPLAY: no X11). Any way it seems that there is vital information that you're withholding from us
ameen@cfd likes this.
__________________
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
gschaider is offline   Reply With Quote

Old   May 9, 2014, 02:05
Default
  #93
New Member
 
Mohammed Ameenuddin
Join Date: Feb 2014
Posts: 15
Rep Power: 4
ameen@cfd is on a distinguished road
The terminal x11 was the issue. I re-installed gnuplot and it is working fine now. Thank you for the help.
ameen@cfd is offline   Reply With Quote

Old   June 6, 2014, 09:07
Default
  #94
New Member
 
Thomas
Join Date: May 2014
Posts: 12
Rep Power: 4
Meister is on a distinguished road
Hi Foamers,

it is also possible to use cat to separate the data before using gnuplot. It is very much flexible in that way. I know it has also disadvantages but maybe it helps someone. I used it to plot the residuals vs Time:
Code:
cat log | grep -w 'Time =' | cut -d' ' -f3 | tr -d ',' > time_tmp.dat
Code:
cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ',' > Uy_tmp.dat
same for Ux, Uy
Code:
paste time_tmp.dat Ux_tmp.dat Uy_tmp.dat Uz_tmp.dat > residuals.dat
then in gnuplot
Code:
plot "residuals.dat" using 1:2 title 'Ux' with lines,"residuals.dat" using 1:3 title 'Uy' with lines,"residuals.dat" using 1:4 title 'Uz' with lines
regards

Thomas
ayhan515, skeptik and StefanW like this.
Meister is offline   Reply With Quote

Old   July 22, 2014, 11:45
Default Plot U and T residuals on reactingFoam
  #95
New Member
 
Duarte Magalh„es
Join Date: Apr 2014
Location: Lisbon, Portugal
Posts: 24
Rep Power: 4
DuarteMagalhaes is on a distinguished road
Hi everyone!

I am trying to plot the U (Ux, Uy, Uz) and T residuals from reactingFoam. I am only able to plot the variables that are discriminated in my log file, not these.

Anyone knows how to plot these other variables? Or how to make them appear in my log file?


Thanks in advance
DuarteMagalhaes is offline   Reply With Quote

Old   July 22, 2014, 17:32
Default
  #96
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,920
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by DuarteMagalhaes View Post
Hi everyone!

I am trying to plot the U (Ux, Uy, Uz) and T residuals from reactingFoam. I am only able to plot the variables that are discriminated in my log file, not these.

Anyone knows how to plot these other variables? Or how to make them appear in my log file?


Thanks in advance
If they're not in the log-file they can't be plotted (and probably not even solved for).

Missing U in the log-file is strange, but missing T is probably OK: usually OF solves for the enthalpy h. T is then calculated from that
__________________
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
gschaider is offline   Reply With Quote

Old   July 23, 2014, 11:04
Default
  #97
New Member
 
Duarte Magalh„es
Join Date: Apr 2014
Location: Lisbon, Portugal
Posts: 24
Rep Power: 4
DuarteMagalhaes is on a distinguished road
Thank you for your reply Bernhard.

Yes, indeed I also found it strange to be missing U.

I have also run a reactingFoam tutorial, and again, U was not present in the log file. Is this a characteristic of the solver? Does not make much sense since it solves the momentum equation, U should be there, as the enthalpy and the species are.
DuarteMagalhaes is offline   Reply With Quote

Old   July 23, 2014, 16:50
Default
  #98
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,920
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by DuarteMagalhaes View Post
Thank you for your reply Bernhard.

Yes, indeed I also found it strange to be missing U.

I have also run a reactingFoam tutorial, and again, U was not present in the log file. Is this a characteristic of the solver? Does not make much sense since it solves the momentum equation, U should be there, as the enthalpy and the species are.
Have a look at your fvSolution-file. If the momentumPredictor is switched off then the behaviour is perfectly OK (because the U-Eqn is never solver. Only used)
DuarteMagalhaes likes this.
__________________
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
gschaider is offline   Reply With Quote

Old   July 24, 2014, 03:39
Default
  #99
New Member
 
Duarte Magalh„es
Join Date: Apr 2014
Location: Lisbon, Portugal
Posts: 24
Rep Power: 4
DuarteMagalhaes is on a distinguished road
Thank you so much Bernhard!
DuarteMagalhaes is offline   Reply With Quote

Old   September 30, 2014, 14:17
Default
  #100
New Member
 
sampath
Join Date: Sep 2014
Posts: 11
Rep Power: 3
sampy is on a distinguished road
This is very useful. Thank you
sampy is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT: plot residuals for complete simulation?? Khan FLUENT 1 February 1, 2007 13:35
Convergence - scaled vs unscaled residuals HS FLUENT 1 November 7, 2005 06:45
fluent: residuals Madhukar Rapaka FLUENT 1 October 14, 2005 10:28
graph plot anindya Main CFD Forum 2 September 17, 2003 12:00
residuals Karl CFX 2 June 24, 2003 23:13


All times are GMT -4. The time now is 03:37.