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/)
-   -   Plotting not working using gnuplot (http://www.cfd-online.com/Forums/openfoam-post-processing/126373-plotting-not-working-using-gnuplot.html)

Naruto November 15, 2013 08:30

Plotting not working using gnuplot
 
1 Attachment(s)
Hello all,
I have recently upgraded to the newest version of OpenFOAM. I am using OpenFOAM for wind turbine simulation. In the previous versions results were saved in a file named forces.dat under the directory forces/0/forces.dat. I wrote a script file to post process the result in gnuplot. The forces.dat file used to contain
time step pressure force (x_val y_val z_val) viscous force (x_val, y_val, z_val) pressure momentum (x_val y_val z_val) viscous momentum (x_val y_val z_val)
My script for gnuplot is like this:
set title "Power Co-efficient"
set xlabel "Azimuthal Angle"
set ylabel "Power Co-efficient"
set xrange [0:*]
set xtic 60
set mxtic 6
set ytic 0.05
set yrange [0:0.7]
plot 'forces.dat' using ($1*3102):((($10+$13)*54.14)/83.0703125) w lines lt 3 lw 3 title "Power Co-efficient"

Here $10 and $13 represents the pressure momentum (z_val) and viscous momentum (z_val) respectively.

In the newer version of OpenFOAM they have also added a new feature named porous force and momentum. Now the current result section is lie that:
time step pressure force (x_val y_val z_val) viscous force (x_val, y_val, z_val) Porous force (val val val) pressure momentum (x_val y_val z_val) viscous momentum (x_val y_val z_val) porous momentum (val val val)
So I just changed the
plot 'forces.dat' using ($1*3102):((($10+$13)*54.14)/83.0703125) w lines lt 3 lw 3 title "Power Co-efficient" to the following line:
plot 'forces.dat' using ($1*3102):((($16+$19)*54.14)/83.0703125) w lines lt 3 lw 3 title "Power Co-efficient"
Logic says it should work. But it is not working. Instead it is showing a bizarre error like xrange is not valid. What does it mean?
I am copying a portion of the forces.dat file here:
# CofR : (0 0 0)
# Time forces(pressure,viscous,porous) moment(pressure,viscous,porous)
1.19904e-05 ((338.008 0.354984 -16300.4),(0.951959 -0.00138936 0.180745),(0 0 0)) ((-6.70899 126.019 63.7206),(0.0050454 0.357485 1.87497),(0 0 0))
2.63616e-05 ((-6.04664 35.7617 77.5156),(0.800409 0.00167469 0.10359),(0 0 0)) ((-12.7962 -2.38944 -0.0540749),(-0.00608388 0.299752 1.4314),(0 0 0))
4.35873e-05 ((0.226422 -8.14431 137.207),(0.610408 -0.00145384 0.0376114),(0 0 0)) ((3.26375 0.119641 0.787413),(-0.00221222 0.228798 1.09764),(0 0 0))
Any help will be appreciated.

Linse November 18, 2013 16:27

gnuplot script not working after OF version change
 
Dear Naruto,

I can only guess, but:
Did the old output look the same in matters of formatting as well? I am particularly curious concerning the brackets and the commas...

Could you maybe add a short snippet of the former output as well? Then one could compare it for any further differences...

Regards,
Bernhard

Naruto November 19, 2013 09:00

Dear Linse,
Sorry for my late reply. I think I have solved the problem already. :) The behavior of gnuplot is kind of strange. It is not recognizing 0 as a value. So I have modified the last line like this:
plot 'forces.dat' using ($1*3102):((($11+$13)*54.14)/83.0703125) w lines lt 3 lw 3 title "Power Co-efficient"

Now it is working fine.
About my previous postprocessing:
The forces.dat file is like this:
# Time forces(pressure, viscous) moment(pressure, viscous)
1.19916e-05 (((4260.91 -0.166375 3.39634e-14) (0.182072 -0.00188388 -3.98097e-14)) ((0.00831877 213.045 3523.73) (9.41938e-05 0.00910361 3.56908)))
2.63682e-05 (((4.04834 -9.33206 1.79013e-16) (0.181656 -0.00469656 7.81041e-15)) ((0.466603 0.202417 0.958215) (0.000234828 0.00908278 3.53391)))
4.36042e-05 (((2.13951 -2.11679 2.16429e-17) (0.177937 -0.00526848 4.70594e-15)) ((0.105839 0.106976 2.28102) (0.000263424 0.00889687 3.49862)))
6.42692e-05 (((8.25938 -1.70984 1.97122e-17) (0.176112 -0.00566661 3.2367e-14)) ((0.0854922 0.412969 2.63943) (0.000283331 0.00880559 3.46185)))
8.90474e-05 (((12.7919 -1.44451 5.11419e-17) (0.175164 -0.00580794 3.90404e-15)) ((0.0722256 0.639593 3.0061) (0.000290397 0.00875821 3.42243)))
0.000118753 (((15.1393 -0.907841 8.83164e-17) (0.174672 -0.00568096 2.44926e-15)) ((0.0453921 0.756966 2.91402) (0.000284048 0.00873361 3.37947)))
0.000154399 (((16.7987 -0.345978 1.05696e-17) (0.174309 -0.00547897 2.51539e-15)) ((0.0172989 0.839936 2.72218) (0.000273948 0.00871544 3.3322)))
0.000197136 (((17.8817 0.24749 -1.23958e-17) (0.173768 -0.00532384 2.49786e-15)) ((-0.0123745 0.894083 2.43213) (0.000266192 0.00868839 3.28003)))

And the script file is given above.
Anyways, I have a question for you. Do you know how could I get a mean line using gnuplot. Thanks

Ruli January 24, 2014 06:59

Quote:

Originally Posted by Naruto (Post 462532)
The behavior of gnuplot is kind of strange. It is not recognizing 0 as a value.

Dear Naruto,
I think I encountered the same problem. I don`t think Gnuplot does not NOT recognize 0 as a value, but it has problems identifying all columns. If I replace all "((" with "(( " and ",(" with ",( " (See the spaces!) plotting does work perfectly.
If you simply change column 10 to 11, I fear you might be plotting the wrong column.

Best regards
Julian

Naruto January 24, 2014 08:37

Thanks for your feedback. But I think my present script is working perfectly fine. I have tested the present script for very small time interval. It worked. I know it doesn't sound logical. But it is working. :)

I have one question for you. Do you know how to plot average value in gnuplot?

Thanks


All times are GMT -4. The time now is 15:39.