CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Help with GNUPlot

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 25, 2007, 21:23
Default Help with GNUPlot
  #1
Renato.
Guest
 
Posts: n/a
Hi folks,

I've beem implementing a dynamic convergence monitor for my finite element solver with GNUPlot. The idea is quite simple and is already working. It consists in calling gnuplot with the following script:

------------------- monitor.gnu file --------------------

reset

set size 1.0, 1.0 set origin 0.0, 0.0 set multiplot set grid unset key set logscale y

# Absolute residuous set size 0.5, 0.5 set origin 0.0, 0.5 set title "Absolute Flow residua" set xlabel "Time step (adim)" set ylabel "log (||r||)" plot 'flow-plot.dat' using 1:3 with lines

# Relative residuous set size 0.5, 0.5 set origin 0.5, 0.5 set title "Relative Flow residua" set xlabel "Time step (adim)" set ylabel "log (||r||/||r0||)" plot 'flow-plot.dat' using 1:4 with lines

# Relative solution increment set size 0.5, 0.5 set origin 0.0, 0.0 set title "Relative solution increment" set xlabel "Time step (adim)" set ylabel "log (||du||/||u||)" plot 'flow-plot.dat' using 1:5 with lines

# Linear Tolerance set size 0.5, 0.5 set origin 0.5, 0.0 set title "Linear Tolerance" set xlabel "Time step (adim)" set ylabel "GMRES tolerance" unset logscale y plot 'flow-plot.dat' using 1:6 with lines

pause 1 reread ---------------------------------------------

the script above is called with the command gnuplot monitor.gnu

my program writes the convergence data in "flow-plot.dat" file and the script is continuosly reread to plot the updated data. My problem is that after some, let's say..., 1000 iterations the x axis begins to turn completely squeezed due to the autoscale. My idea is adjust the xmin and xmax range to follow the converge data in a constant offset, e.g., with a constant offset of 50 iterations I'd have the xrange "rolling" to right as a constant window. 0-50, 50-100, 100-150, 150-200, and so on...

Does anyone know how could I do it in GNUplot?

thanks for any help

Renato.

  Reply With Quote

Old   May 27, 2007, 18:34
Default Re: Help with GNUPlot
  #2
Sergei Chernyshenko
Guest
 
Posts: n/a
Hi, Renato,

Using reread in this way is an interesting idea.

No, I do not know how to do what you want in gnuplot. However, I did some animations with gnuplot under Linux, see

http://www.afm.ses.soton.ac.uk/~sergei/Plotter.f

May be this will help.

Regards Sergei
  Reply With Quote

Old   May 28, 2007, 10:01
Default Re: Help with GNUPlot
  #3
Renato.
Guest
 
Posts: n/a
Hy Sergei

in fact I had already found your routine googling around. It was my starting point ;o) ... but in my case I chose to write a bunch of information as a table and select the data to be plotted in with the "using x:y" clause. In this way I could use the same data file to create other plots using other softwares such as Excel, etc... . The idea is to write a general tabular data that could be loaded and plotted by gnuplot or any other software (Excel, SigmaPlot, Origin, etc...) and not to write a specific formatted data suited only to gnuplot.

I was thinking about a solution to my problem. It would be easy to do if I had some way to read the data, get the number of lines, and setting the range as

from MAXLINES-OFFSET to MAXLINES

a pseudo-algorithm would be like this:

1. load data 2. get the number of lines 3. set xrange [number of lines]-[offset]:[number of lines] 4. Go ahead with the script described in the last post

here I'm considering "offset" as the number of points that must be plotted in the x axis as exemplified in my last post.

Regards

Renato.

  Reply With Quote

Old   May 28, 2007, 11:00
Default Re: Help with GNUPlot
  #4
Sergei Chernyshenko
Guest
 
Posts: n/a
Hi, Renato,

What abot your master code repeatedly writing to the disk one more file, with gnuplot commands, and your gnuplot file loading that another file? That would give you a lot of flexibility.

Regards

Sergei
  Reply With Quote

Old   June 5, 2007, 09:06
Default Re: Help with GNUPlot
  #5
Renato.
Guest
 
Posts: n/a
I've found an interesting way to solve my problem. Look at this:

------------------------------------ reset

nlines = `wc --lines flow-plot.dat | sed "s/ .*//"`-1 offset = 50

set size 1.0, 1.0 set origin 0.0, 0.0 set multiplot set grid unset key unset logscale x set logscale y set xrange [nlines-offset:nlines+offset]

# Absolute residuous set size 0.5, 0.5 set origin 0.0, 0.5 set title "Absolute Flow residua" set xlabel "Global iteration" set ylabel "log (||r||)" plot 'flow-plot.dat' using 1:3 with lines

# Relative residuous set size 0.5, 0.5 set origin 0.5, 0.5 set title "Relative Flow residua" set xlabel "Global iteration" set ylabel "log (||r||/||r0||)" plot 'flow-plot.dat' using 1:4 with lines

# Relative solution increment set size 0.5, 0.5 set origin 0.0, 0.0 set title "Relative solution increment" set xlabel "Global iteration" set ylabel "log (||du||/||u||)" plot 'flow-plot.dat' using 1:5 with lines

# Linear Tolerance set size 0.5, 0.5 set origin 0.5, 0.0 set title "Linear Tolerance" set xlabel "Global iteration" set ylabel "GMRES tolerance" unset logscale y plot 'flow-plot.dat' using 1:6 with lines

pause 1 reread ------------------------------------

Note that I'm using the "wc" command to know the plot x range before plotting it. In this way, I can set the xrange accordingly.

Regards

Renato.

  Reply With Quote

Old   June 5, 2007, 18:30
Default Re: Help with GNUPlot
  #6
Sergei Chernyshenko
Guest
 
Posts: n/a
Hi, Renato,

Great!

Next time I need to animate something I will try to use your idea. The data file can be on a virtual (RAM) drive so that read/write operations will be fast (I never tried this but it should work).

May be you should describe this idea in some kind of publication, or simply put it on a web-page, as many people would be interested.

Regards

Sergei

  Reply With Quote

Old   June 6, 2007, 20:51
Default Re: Help with GNUPlot (an easier solution)
  #7
Renato.
Guest
 
Posts: n/a
Hi Sergei

after taking a look in this tutorial http://t16web.lanl.gov/Kawano/gnuplo...le2-e.html#7.2 I realized an easier solution for the same problem:

we can simply use:

plot "< tail -150 datafile.dat"

to dynamically plot only the latest 150 points

Of course, it's only supported on Unix systems because of the tail command.

In my case, I'm running my simulation on a SGI Altix system (IA64/Linux) while plotting the convergence data in a Windows Vista using a X-server and SSH conection, so, my GNUPlot is running on the *nix side.

I hope it can be helpful for other users. I'll post these tics on my site as soon as possible

cheers

Renato.

  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gnuplot installation on Ubuntu 9.10 zhoubinwx OpenFOAM Post-Processing 4 January 19, 2010 21:06
Help with Gnuplot Sham FLUENT 0 April 23, 2008 03:12
Gnuplot usage mike_jaworski OpenFOAM Post-Processing 3 December 17, 2007 13:43
gnuplot Mich Main CFD Forum 0 August 7, 2006 08:30
how to plot isotherms in gnuplot? sivasamy Main CFD Forum 0 December 19, 2005 02:26


All times are GMT -4. The time now is 02:48.