CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Residual plotting (http://www.cfd-online.com/Forums/openfoam-post-processing/61330-residual-plotting.html)

Mattijs Janssens (Mattijs) April 2, 2002 06:23

Often I have to filter some d
 
Often I have to filter some data out of a Foam log file. Foam2.1 comes with a script, foamLog, which extracts data from the log file in an x-y format suitable for plotting.

foamLog root case logFile

will create a root/case/logs directory with in there all variable residuals split into separate files.

foamLog -h for more info.

hani September 8, 2005 04:08

I would just like to add that
 
I would just like to add that xmgrace can plot the logs files easily. Use: Data/Import/ASCII. Choose the logs directory and remove '.dat' from the filter. Then you can plot whatever you like in the logs directory.

Håkan.

hjasak September 8, 2005 20:50

Hi Hakan, Just to whet your
 
Hi Hakan,

Just to whet your apetite: I've played around with it a bit and now it's runnign smoothly, about 90s per iteration on my laptop (which is no great shakes). I've got 50-ish iterations so far and it looks just fine :-) The pressure is still flapping about a bit but it's too early to really tell if that is a problem.

http://www.cfd-online.com/OpenFOAM_D...ges/1/1088.jpg

I'll pass over the case back to you when I get bored.

Enjoy,

Hrv

hani September 9, 2005 03:52

Lets's hope that it doesn't st
 
Lets's hope that it doesn't stop converging too soon, that the pressure also converges and that the results are steady!

Do you also use xmgrace for residual plotting, or do you have a better suggestion?

Please don't get bored. I'm not!

I was just discussing the case with other people that are also very interested in getting a solution for this case with OpenFoam, so I am not alone.

Thanks,
Håkan.

hjasak September 9, 2005 09:12

Sorry, I seem to have ended up
 
Sorry, I seem to have ended up in the wrong thread...

It run over night and the residual went straight down (bored now). I'll try to set one up with the proper inlet b.c. (I was running plug flow), but if you want the case back, please E-mail me and you can have a go yourself.

The changes were minor: Gamma scheme instead of limited linear and bounded laplacian on the k-e + the AMG solver to speed things up a bit. BTW, your mesh is way too nice to need non-orthogonal correctors for SIMPLE, and it runs just fine without them.

http://www.cfd-online.com/OpenFOAM_D...ges/1/1090.jpg

Have fun,

Hrv

hani September 12, 2005 03:16

To Hrvoje. We're already in
 
To Hrvoje.

We're already in the wrong thread, so let's continue being so. That is the problem with gathering FAQ this way - it becomes extremely unstructured.

I hope that you had a go with the correct boundary conditions, plug flow is much easier to converge (I think that even I have succeeded). In the case of plug flow I don't think that you get the same problems with unsteadiness. Do you consider the results converged with reiduals at 0.001 as you show in the plot? I am not yet really sure how OpenFoam defines the residuals.

Let's see if non-orthogonal correctors are needed when I compare with experiments. When I started doing these computations I noticed that the static pressure distribution was completely wrong (compared both to experiments and other computations). When I turned on non-orthogonal correctors the results were similar to the measurements. In that case they are really needed, but let's see.

Please have a go with the correct bc:s, and then hand back the case to me. Unfortunately you are not able to upload the files to me, so you will have to send them to me another way. Since it is only the setup files that are changed, you could perhaps paste the changes into the discussion forum, or I can give you my e-mail address. Then also tell me if you had any particular way of performing the computations (start with potentialFoam, then use simpleFoam with underrelaxation factors ??? for ??? iterations ...)

Thanks,
Håkan.

hjasak September 12, 2005 03:59

Hi, - I have sorted out the
 
Hi,

- I have sorted out the boundary conditions
- initialization with potentialFoam is not needed: runs fine with normal start-up
- non-orthogonal correctors are not needed, the mesh is OK
- the convergence behaviour is fine: the residual intialilly goes straight down as expected and then...
- you have a low-frequency instability in the flow, something like a shifting recirculation on the outlet boundary or a moving (secondary?) recirculation somewhere in there. I am pretty sure this is physics rather than numerical problems. In order to investigate it further, you should run turbFoam with a reasonable time-step etc and you'll see precisely what's going on. My latest residual curve is below, note the slow and regular behaviour of residual curves at the end.

http://www.cfd-online.com/OpenFOAM_D...ges/1/1102.jpg

- I can kill the instability if I put crap discretisation in, which will give you a converged but dubious solution. However, my morals don't allow me to do that :-) The actual result is much more interesting and I bet if you dig into the experimental results properly, you will find something similar.

I now need my machine for other stuff so please click on my name here (to get my E-mail) and I'll hand the case back to you.

This was quite fun, I hope it was useful.

Enjoy,

Hrv

hani September 12, 2005 04:14

I'm glad that you enjoyed it!
 
I'm glad that you enjoyed it! It was very useful. I might however get back to you when I have made more tests.

I know that the physical flow is likely to be unsteady. However, I also know that many other people have produced steady results for this case, although I think that it is better if the solver shows that there is no steady solution - so it's a healthy sign of OpenFoam.

I guess that you mean that the behaviour of the residuals is more important than the absolute values? I will have to dig more into the residuals definitions later on.

I will send you an e-mail so that you can hand over the files.

Thanks,
Håkan.

ivanwhlau July 25, 2008 16:42

Does anyone know if I can cont
 
Does anyone know if I can continuously monitor the residual using xmgrace or other methods? At this moment, I do... foamLog and then xmgrace (kill data and then re-import" once a while. It is ok to do this way. The only problem is that foamLog takes a while to generate the "logs" folder. Any ideas?
Thanks,
IL

gschaider July 29, 2008 06:35

Hi Ivan! Beware! (Advertism
 
Hi Ivan!

Beware! (Advertisment): The pyFoamPlotRunner.py from http://openfoamwiki.net/index.php/Contrib_PyFoam does such a thing.
Currently does not work with 1.5 (only 1.4.1)

Bernhard

ivanwhlau July 29, 2008 07:34

Hi, Bernhard, Unfortunat
 
Hi, Bernhard,
Unfortunately, I am currently working with Version 1.5, and I don't plan to "downgrade" to 1.4.1. http://www.cfd-online.com/OpenFOAM_D...lipart/sad.gif
Btw, I thought ver 1.5 shares most of same codes as ver 1.4.1 (I only know that they movie some directories, add new tools and now users need to operate under case directory). Why does this not work for version 1.5?
I guess I will wait till the working version for 1.5. Anyway, thanks for your reply.
Ivan

gschaider July 29, 2008 08:18

Hi Ivan The problem is that p
 
Hi Ivan
The problem is that pyFoam relies on the "old" way of specifying the case ("dot casename") and I've got to rewrite it in a way that takes the used version into account (so that it doesn't break everything for old 1.4.x). It's not that difficult, but I've got some other stuff I've got to finish before I do that
Bernhard

ivanwhlau July 29, 2008 08:43

Hi, Bernhard, That's ex
 
Hi, Bernhard,
That's exactly what I thought.
No rush at all. Please kindly advise if this tools is available.
thanks,
Ivan

santos July 29, 2008 11:00

Hi Ivan, I am using Bernhar
 
Hi Ivan,

I am using Bernhard PyFoam tools to monitor the residuals in OpenFOAM 1.5 as follows:

simpleFoam > log &
pyFoamPlotWatcher.py log

Regards,
Jose Santos

ivanwhlau September 16, 2008 16:02

Hi, Bernhard, Jose, or others,
 
Hi, Bernhard, Jose, or others,

I tried to use pyFoamPlotWatcher, but I got an error of gnuplot, Do you know how to solve this problem?
The complete error is as the follows:

Starting time loop

Time = 1

DILUPBiCG: Solving for Ux, Initial residual = 1, Final residual = 0.0571514, No Iterations 1
DILUPBiCG: Solving for Uy, Initial residual = 1, Final residual = 0.0917252, No Iterations 1
sh: gnuplot: command not found
sh: gnuplot: command not found
DICPCG: Solving for p, Initial residual = 1, Final residual = 0.00945253, No Iterations 514
DICPCG: Solving for p, Initial residual = 6.54853e-05, Final residual = 9.78431e-07, No Iterations 193
time step continuity errors : sum local = 1.21402e-06, global = -3.04686e-09, cumulative = -3.04686e-09
DILUPBiCG: Solving for epsilon, Initial residual = 0.608184, Final residual = 0.0248181, No Iterations 1
DILUPBiCG: Solving for k, Initial residual = 1, Final residual = 0.0301132, No Iterations 1
ExecutionTime = 21.77 s ClockTime = 22 s

Time = 2
Traceback (most recent call last):
File "/usr/local/bin/pyFoamPlotWatcher.py", line 5, in <module>
PlotWatcher()
File "/usr/local/lib64/python2.5/site-packages/PyFoam/Applications/PlotWatcher.py", line 28, in __init__
PyFoamApplication.__init__(self,args=args,descript ion=description,usage="%prog [options] <logfile>",interspersed=True,nr=1)
File "/usr/local/lib64/python2.5/site-packages/PyFoam/Applications/PyFoamApplication. py", line 26, in __init__
self.run()
File "/usr/local/lib64/python2.5/site-packages/PyFoam/Applications/PlotWatcher.py", line 87, in run
run.start()
File "/usr/local/lib64/python2.5/site-packages/PyFoam/Execution/BasicWatcher.py", line 60, in start
self.lineHandle(line)
File "/usr/local/lib64/python2.5/site-packages/PyFoam/Execution/AnalyzedCommon.py", line 45, in lineHandle
self.analyzer.analyzeLine(line)
File "/usr/local/lib64/python2.5/site-packages/PyFoam/LogAnalysis/FoamLogAnalyzer.py" , line 80, in analyzeLine
self.analyzers[nm].doAnalysis(line)
File "/usr/local/lib64/python2.5/site-packages/PyFoam/LogAnalysis/TimeLineAnalyzer.py ", line 31, in doAnalysis
self.notify(float(m.group(1)))
File "/usr/local/lib64/python2.5/site-packages/PyFoam/LogAnalysis/LogLineAnalyzer.py" , line 60, in notify
f(*data)
File "/usr/local/lib64/python2.5/site-packages/PyFoam/LogAnalysis/FoamLogAnalyzer.py" , line 44, in setTime
listener.timeChanged()
File "/usr/local/lib64/python2.5/site-packages/PyFoam/Execution/StepAnalyzedCommon.py ", line 24, in timeChanged
self.timeHandle()
File "/usr/local/lib64/python2.5/site-packages/PyFoam/Execution/GnuplotRunner.py", line 101, in timeHandle
self.plot.redo()
File "/usr/local/lib64/python2.5/site-packages/PyFoam/Basics/GnuplotTimelines.py", line 89, in redo
self.replot()
File "/usr/local/lib64/python2.5/site-packages/PyFoam/ThirdParty/Gnuplot/_Gnuplot.py" , line 333, in replot
self.refresh()
File "/usr/local/lib64/python2.5/site-packages/PyFoam/ThirdParty/Gnuplot/_Gnuplot.py" , line 226, in refresh
self(self.plotcmd + ' ' + string.join(plotcmds, ', '))
File "/usr/local/lib64/python2.5/site-packages/PyFoam/ThirdParty/Gnuplot/_Gnuplot.py" , line 210, in __call__
self.gnuplot(s)
File "/usr/local/lib64/python2.5/site-packages/PyFoam/ThirdParty/Gnuplot/gp_unix.py", line 210, in __call__
self.flush()
IOError: [Errno 32] Broken pipe

Please kindly advise.

Regards,
iL

ivanwhlau September 16, 2008 16:46

Hi, all, I solved my own pr
 
Hi, all,

I solved my own problem now by reinstalling gnuplot.

Thanks,
iL

ivanwhlau September 16, 2008 16:56

Hi, Sorry for sending anoth
 
Hi,

Sorry for sending another message.
But, I got another error with pyPlotWatcher.py log

Here is an example when trying with simpleFoam:

Time = 20
Warning: empty x range [1:1], adjusting to [0.99:1.01]
Warning: empty y range [-3.04686e-09:-3.04686e-09], adjusting to [-3.01639e-09:-3.07733e-09]
Warning: empty y2 range [-3.04686e-09:-3.04686e-09], adjusting to [-3.01639e-09:-3.07733e-09]

DILUPBiCG: Solving for Ux, Initial residual = 0.0122534, Final residual = 0.000895386, No Iterations 1
DILUPBiCG: Solving for Uy, Initial residual = 0.0150332, Final residual = 0.00111655, No Iterations 2
DICPCG: Solving for p, Initial residual = 0.407735, Final residual = 0.00402762, No Iterations 539
DICPCG: Solving for p, Initial residual = 0.000405376, Final residual = 4.02599e-06, No Iterations 204
time step continuity errors : sum local = 1.83833e-07, global = -1.24031e-09, cumulative = 3.64998e-08
DILUPBiCG: Solving for epsilon, Initial residual = 0.0435693, Final residual = 0.000439403, No Iterations 2
DILUPBiCG: Solving for k, Initial residual = 0.0505866, Final residual = 0.00268979, No Iterations 1
ExecutionTime = 414.23 s ClockTime = 415 s

Please kindly comment and advise.
Regards, iL

suredross September 18, 2008 06:46

hello, can some one please ad
 
hello,
can some one please advise whether foamlog is still available in openfoam 1.4 and the correct synthax for it?i tried
[cfd@sm-pc16-linux ~]$ foamLog OpenFOAM/OpenFOAM-1.4.1/tutorials/junctionFoam/rectCyo/ log
,
but could not get any results.also does it only monitor a run or can be used for saved log files?

thank you

ryan_m September 18, 2008 07:18

Its a post processing utility
 
Its a post processing utility so it will only work for a saved log file. Try the following syntax:

foamLog <root> <case> <case>/<logfile>

matthias October 28, 2008 06:54

Hi all, I got the same erro
 
Hi all,

I got the same error like Ivan when I start pyPlotWatcher.py ! (No lines were plotted)

...
Warning: empty x range [1:1], adjusting to ...
Warning: empty y range ...
...


The OF case seems to be OK. Maybe a bug in the plot tool?

Best regards,

Matthias


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