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 Tree130Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   February 4, 2013, 09:09
Default
  #61
Member
 
Martin
Join Date: Dec 2011
Location: Latvia
Posts: 54
Rep Power: 5
latvietis is on a distinguished road
Awesome tool!

Thank you!

P.S. This post was made since it didn't work, but I found my issue seconds after I posted
latvietis is offline   Reply With Quote

Old   March 14, 2013, 19:15
Default
  #62
New Member
 
Ben Graves
Join Date: Dec 2012
Posts: 18
Rep Power: 4
bgraves is on a distinguished road
Thank you very much for this awesome step by step tutorial!

-Ben
bgraves is offline   Reply With Quote

Old   April 1, 2013, 07:07
Default Printing subiteration residuals
  #63
Member
 
Ilya
Join Date: Dec 2011
Location: Russia
Posts: 82
Blog Entries: 39
Rep Power: 5
skeptik is on a distinguished road
Quote:
Originally Posted by anger View Post
Hi,

you could change the line extracting the pressure to read:
cat log | grep 'Solving for p' | cut -d' ' -f9 | sed -n 'p;N;N;N;N' | tr -d ','" title 'p' with lines
If you had two pressure iterations, you would change the argument to sed to read 'p;N'.
If the final residual should be plottet, replace f9 at the cut command with f13.

Best,
-Thomas
Dear Thomas and other foamers.

I tried some tests with gnuplot and discover that better to use something like this:

Code:
"< cat log | grep 'Solving for p' | cut -d' ' -f13 | sed -n 10p | tr -d ','" title 'p' with lines
where
Code:
sed -n 10p
means "print tenth string" (i have 10 subiterations for p).

Anybody could do some curious experiments in terminal copying this step by step
Code:
cat log | grep 'Solving for p'
Code:
cat log | grep 'Solving for p' | cut -d' ' -f13
__________________
practice makes perfect
skeptik is offline   Reply With Quote

Old   April 10, 2013, 09:26
Default
  #64
New Member
 
wan,Bangqi
Join Date: Feb 2013
Posts: 7
Rep Power: 4
wanxlxg is on a distinguished road
Code:
DILUPBiCG:  Solving for Ux, Initial residual = 0.11902604, Final residual = 0.0070412572, No Iterations 1
DILUPBiCG:  Solving for Uy, Initial residual = 0.1142661, Final residual = 0.0057272586, No Iterations 1
DILUPBiCG:  Solving for Uz, Initial residual = 0.11446305, Final residual = 0.0057460693, No Iterations 1
GAMG:  Solving for p, Initial residual = 0.48817918, Final residual = 0.0019587405, No Iterations 6
GAMG:  Solving for p, Initial residual = 0.49249198, Final residual = 0.0038667108, No Iterations 2
GAMG:  Solving for p, Initial residual = 0.059867564, Final residual = 0.00021565867, No Iterations 3
GAMG:  Solving for p, Initial residual = 0.010320323, Final residual = 5.6870971e-05, No Iterations 3
time step continuity errors : sum local = 2.0630983e-07, global = -1.0375901e-07, cumulative = 1.3807206e-07
Pressure gradient source: uncorrected Ubar = 0.0010286698, pressure gradient = -1.293371e-05
 ExecutionTime = 1.71 s  ClockTime = 2 s

please could somone tell me how can i plot 'pressure gradient'?
wanxlxg is offline   Reply With Quote

Old   April 10, 2013, 17:12
Default
  #65
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by wanxlxg View Post
Code:
time step continuity errors : sum local = 2.0630983e-07, global = -1.0375901e-07, cumulative = 1.3807206e-07
Pressure gradient source: uncorrected Ubar = 0.0010286698, pressure gradient = -1.293371e-05
 ExecutionTime = 1.71 s  ClockTime = 2 s

please could somone tell me how can i plot 'pressure gradient'?
I'd use pyFoamPlotWatcher.py (or the Runner) from http://openfoamwiki.net/index.php/Contrib_PyFoam with a customRegexp-file like this:
Code:
pGrad {
   expr "Pressure gradient source: uncorrected Ubar = (%f%), pressure gradient = (%f%)";
   titles ( Ubar pGrad);
}
But I'm extremely subjective in that matter
__________________
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   April 11, 2013, 05:53
Default
  #66
Member
 
Ilya
Join Date: Dec 2011
Location: Russia
Posts: 82
Blog Entries: 39
Rep Power: 5
skeptik is on a distinguished road
Quote:
Originally Posted by wanxlxg View Post
Code:
DILUPBiCG:  Solving for Ux, Initial residual = 0.11902604, Final residual = 0.0070412572, No Iterations 1
DILUPBiCG:  Solving for Uy, Initial residual = 0.1142661, Final residual = 0.0057272586, No Iterations 1
DILUPBiCG:  Solving for Uz, Initial residual = 0.11446305, Final residual = 0.0057460693, No Iterations 1
GAMG:  Solving for p, Initial residual = 0.48817918, Final residual = 0.0019587405, No Iterations 6
GAMG:  Solving for p, Initial residual = 0.49249198, Final residual = 0.0038667108, No Iterations 2
GAMG:  Solving for p, Initial residual = 0.059867564, Final residual = 0.00021565867, No Iterations 3
GAMG:  Solving for p, Initial residual = 0.010320323, Final residual = 5.6870971e-05, No Iterations 3
time step continuity errors : sum local = 2.0630983e-07, global = -1.0375901e-07, cumulative = 1.3807206e-07
Pressure gradient source: uncorrected Ubar = 0.0010286698, pressure gradient = -1.293371e-05
 ExecutionTime = 1.71 s  ClockTime = 2 s
please could somone tell me how can i plot 'pressure gradient'?
Just replace one of standart gnuplot's strings on this

cat log | grep 'Pressure gradient'
and add it to the end of gnuplot file.
__________________
practice makes perfect
skeptik is offline   Reply With Quote

Old   April 11, 2013, 07:08
Default
  #67
New Member
 
wan,Bangqi
Join Date: Feb 2013
Posts: 7
Rep Power: 4
wanxlxg is on a distinguished road
Thanks,all of you.
i used this and it works
Code:
plot "< cat log | grep 'Pressure gradient' | cut -d' ' -f11 | tr -d ','" title 'p' with lines
i have a question here, the code runs only with -f11, but it should be -f8 or not?

from where should i start to count the pieces?

thanks again, you are all good people
wanxlxg is offline   Reply With Quote

Old   July 29, 2013, 10:47
Default Problems with the Force Coefficients
  #68
Member
 
Join Date: Jul 2013
Posts: 42
Rep Power: 4
HHOS is on a distinguished road
Hello everybody!!

The threat is very old, but it was helpful anyway. THANK YOU!. I am using paraFOAM just since some weeks ago, and I am still learning the basics. The version that I am using is the 2.2.0

I managed to plot the Residuals and the Forces, but I am not able to get the Force Coefficients... I have the following lines calling to the functions in ControlDict:

functions
(
#include "forces" //to load the file as a function
#include "forceCoeff"
);


And the forceCoeff function is as follows:

forceCoeffs
{
type forceCoeffs;
enabled true;
functionObjectLibs ("libforces.so");
outputControl timeStep;
outputInterval 1;
patches ("SPHERE"); //change to your patch name
pName p;
UName U;
rhoName rhoInf;
log true;
rhoInf 998.2;
CofR (0 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0 0 0);
magUInf 0.001;
lRef 1;
Aref 1;
}

);


The folder with the required data is not even created!

The case is the most simple, just a ball inside a laminar flux, nothing else... It is just to learn using the software.

ANY HELP WOULD BE NICE!! THANK YOU VERY MUCH!
HHOS is offline   Reply With Quote

Old   July 29, 2013, 13:21
Default
  #69
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by HHOS View Post
Hello everybody!!

The threat is very old, but it was helpful anyway. THANK YOU!.
THANK YOU. Replacing a "D" with a "T" in this really made my day!

Quote:
Originally Posted by HHOS View Post
I am using paraFOAM just since some weeks ago, and I am still learning the basics. The version that I am using is the 2.2.0

I managed to plot the Residuals and the Forces, but I am not able to get the Force Coefficients... I have the following lines calling to the functions in ControlDict:

functions
(
#include "forces" //to load the file as a function
#include "forceCoeff"
);


And the forceCoeff function is as follows:

forceCoeffs
{
type forceCoeffs;
enabled true;
functionObjectLibs ("libforces.so");
outputControl timeStep;
outputInterval 1;
patches ("SPHERE"); //change to your patch name
pName p;
UName U;
rhoName rhoInf;
log true;
rhoInf 998.2;
CofR (0 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0 0 0);
magUInf 0.001;
lRef 1;
Aref 1;
}

);


The folder with the required data is not even created!
Can't help you very concretely here.
a. Where do you expect the data to be created? Starting with 2.2 such stuff is written to a folder called postProcessing in the case, not the the case-directory itself
b. To make sure that the FO is actually read introduce an error that would make it fail (for instance "enabled neitherTrueNorFalse;")
__________________
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 30, 2013, 07:43
Default I got it!
  #70
Member
 
Join Date: Jul 2013
Posts: 42
Rep Power: 4
HHOS is on a distinguished road
Yes, you are right gschaider, the data should be in the folder called postProcessing; and actually I managed to achieve it!

When I was changing the "forces" file to check if OF was actually reading it, as you suggested, I noticed that the file was ending like:

Code:
...
   rhoInf     998.2;     //Reference density for fluid
   }

);
So OF read it and not the next function which was actually the one for the coefficients.
HHOS is offline   Reply With Quote

Old   August 13, 2013, 23:31
Default How to generate residual plots for transient runs
  #71
New Member
 
Ravi Duggirala
Join Date: Feb 2013
Posts: 2
Rep Power: 0
dravimech is on a distinguished road
I have used the same method to plot residuals but how to plot "Time" in x-axis rather than timestep number.

Regards
Ravi
dravimech is offline   Reply With Quote

Old   September 10, 2013, 20:53
Default Rayleigh Benard Convection Problem
  #72
Member
 
Lucas Mutti
Join Date: Aug 2013
Posts: 47
Rep Power: 4
lramutti is on a distinguished road
Hello Wolfgang,

First of all thank you very much for releasing this module that speeds us our research significantly. Second, I recognize that it has been a while since you last posted in this page. I am currently working on simulating a Rayleigh Benard Convection Problem and I am trying to do a mesh convergence analysis so I may know how long it takes my code to converge and consequently approach my stipulated tolerance of 10^-3.

After going over your files I have noticed that the Residuals.txt do not include parameters such as temperature. As a beginner in OpenFOAM, I am not sure how I should modify your file to incorporate the temperature distribution. Would you be able to show me how to do so? Also, with regards to your other files (functions and forceCoeffs) are they applicable to every problem in fluid mechanics or only under aerodynamic problems?

Thank you very much,
Lucas Mutti
lramutti is offline   Reply With Quote

Old   September 11, 2013, 03:21
Question
  #73
Member
 
Join Date: Jul 2013
Posts: 42
Rep Power: 4
HHOS is on a distinguished road
Hello Iramutti:

I am completely new with OpenFOAM too, so I don't know if my reply will be useful. Besides I have never run a case where temperature is involved.

Anyway, I guess that you can check the log file, and find the line where the Temperature residual is shown (maybe something like "Solving for T" ???), then, you just have to search for the correct string analogously to the example, with which I am reading the residuals for different variables (you have to remove all the # and all the explanations in the end of each line):

Code:
#    plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines,\                # Ux residuals
#         "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines,\                # Uy residuals
#         "< cat log | grep 'Solving for Uz' | cut -d' ' -f9 | tr -d ','" title 'Uz' with lines,\                # Uz residuals
#         "< cat log | grep 'Solving for nuTilda' | cut -d' ' -f9 | tr -d ','" title 'nuTilda' with lines,\      # nuTilda residuals
#         "< cat log | grep 'Solving for omega' | cut -d' ' -f9 | tr -d ','" title 'omega' with lines,\          # omega residuals
#         "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines,\                  # k residuals
#         "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines                    # p residuals
I hope it will be OK.

Regards
HHOS is offline   Reply With Quote

Old   October 24, 2013, 06:32
Default
  #74
Member
 
chen long
Join Date: Dec 2012
Posts: 32
Rep Power: 4
Jackie Chen is on a distinguished road
where to find the residuals plot? it will generate automatically?
Jackie Chen is offline   Reply With Quote

Old   October 24, 2013, 06:50
Default
  #75
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Jackie Chen View Post
where to find the residuals plot?
In the standard output of the solver
Quote:
Originally Posted by Jackie Chen View Post
it will generate automatically?
No. That is the point of this whole thread
__________________
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   October 24, 2013, 23:14
Default
  #76
Member
 
chen long
Join Date: Dec 2012
Posts: 32
Rep Power: 4
Jackie Chen is on a distinguished road
Hi Bernhard
Thanks for your reply. Actually when i type the code "gnuplot Residuals", it shws "Residulas", line XXX: warning:skipping data file with no valid points". DO you have any idea about this?
Jackie Chen is offline   Reply With Quote

Old   October 27, 2013, 19:12
Default
  #77
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Jackie Chen View Post
Hi Bernhard
Thanks for your reply. Actually when i type the code "gnuplot Residuals", it shws "Residulas", line XXX: warning:skipping data file with no valid points". DO you have any idea about this?
I don't use the way of plotting described above. Check what is in the Residuals-file
__________________
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   February 9, 2014, 16:08
Default
  #78
New Member
 
Stephan
Join Date: Feb 2014
Posts: 2
Rep Power: 0
Stephan8 is on a distinguished road
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

Last edited by wyldckat; February 10, 2014 at 17:13. Reason: Added [CODE][/CODE]
Stephan8 is offline   Reply With Quote

Old   February 10, 2014, 02:42
Default
  #79
Member
 
Ilya
Join Date: Dec 2011
Location: Russia
Posts: 82
Blog Entries: 39
Rep Power: 5
skeptik is on a distinguished road
Quote:
Originally Posted by Stephan8 View Post
Hey all,
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
RTFM.
Gnuplot documentation will help you. At least you can try to use command promt of GNU Plot and feed it there string by string. The result will surprize you.
__________________
practice makes perfect
skeptik is offline   Reply With Quote

Old   February 11, 2014, 05:57
Default does not work any more?
  #80
New Member
 
fabi
Join Date: Jan 2014
Posts: 5
Rep Power: 3
odin is on a distinguished road
skript does not work with OpenFoam 2.1.1
odin 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 19:47.