CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Plotting Velocity Probe File with gnuplot

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

Like Tree8Likes
  • 2 Post By hanness
  • 2 Post By RomainBou
  • 4 Post By McCharles

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 19, 2016, 05:06
Default Plotting Velocity Probe File with gnuplot
  #1
Member
 
Charles K.
Join Date: Feb 2016
Location: Germany
Posts: 37
Rep Power: 7
McCharles is on a distinguished road
Hello everyone,

i used the probe function to record the velocity components at different probe locations over a few iterations. The resulting file looks like this:

Code:
#            x      -0.131405     -0.0651938      -0.076365      -0.038918
#            y       0.217974       0.168556       0.157857       0.140393
#            z              0              0              0              0
#         Time
         30001              (-66.1109 -119.8326 25.50102)              (4.886721 -3.84177 61.53438)              (-3.194476 1.791498 61.15488)              (-0.9615131 -0.001325707 63.65683)
         30002              (-66.10999 -119.8314 25.50123)              (4.886713 -3.841753 61.53451)              (-3.194472 1.791497 61.15505)              (-0.961551 -0.001290854 63.65706)
         30003              (-66.10908 -119.8303 25.50143)              (4.886701 -3.841732 61.53466)              (-3.194465 1.791497 61.15522)              (-0.9615866 -0.001260145 63.65731)
         30004              (-66.10817 -119.8291 25.50164)              (4.886687 -3.841709 61.53481)              (-3.194457 1.791498 61.15539)              (-0.9616209 -0.001232042 63.65756)
         30005              (-66.10726 -119.828 25.50185)              (4.886672 -3.841684 61.53496)              (-3.19445 1.791498 61.15557)              (-0.9616544 -0.001205453 63.65782)
         30006              (-66.10634 -119.8268 25.50205)              (4.886656 -3.841658 61.53513)              (-3.194443 1.791498 61.15576)              (-0.9616873 -0.001179835 63.65808)
         30007              (-66.10543 -119.8257 25.50226)              (4.88664 -3.841632 61.53529)              (-3.194437 1.791499 61.15594)              (-0.9617197 -0.001154599 63.65833)
         30008              (-66.10452 -119.8245 25.50246)              (4.886624 -3.841606 61.53546)              (-3.194432 1.7915 61.15613)              (-0.9617518 -0.001129642 63.65859)
         30009              (-66.10361 -119.8234 25.50266)              (4.886609 -3.841581 61.53563)              (-3.194428 1.7915 61.15632)              (-0.9617837 -0.00110496 63.65884)
         30010              (-66.1027 -119.8223 25.50287)              (4.886595 -3.841557 61.5358)              (-3.194424 1.791501 61.15652)              (-0.9618155 -0.001080633 63.65909)
         30011              (-66.10178 -119.8211 25.50307)              (4.886581 -3.841533 61.53597)              (-3.194421 1.791502 61.15671)              (-0.9618472 -0.001056746 63.65934)
         30012              (-66.10087 -119.82 25.50328)              (4.886568 -3.841511 61.53614)              (-3.194418 1.791502 61.15691)              (-0.961879 -0.001033452 63.6596)
         30013              (-66.09996 -119.8188 25.50348)              (4.886556 -3.841489 61.53631)              (-3.194414 1.791502 61.15711)              (-0.9619109 -0.00101076 63.65985)
         30014              (-66.09904 -119.8177 25.50369)              (4.886544 -3.841468 61.53647)              (-3.19441 1.791502 61.1573)              (-0.9619431 -0.0009887137 63.6601)
         30015              (-66.09813 -119.8165 25.5039)              (4.886531 -3.841447 61.53664)              (-3.194406 1.791501 61.1575)              (-0.9619756 -0.0009672426 63.66035)
         30016              (-66.09721 -119.8154 25.5041)              (4.886519 -3.841427 61.5368)              (-3.194401 1.791499 61.1577)              (-0.9620084 -0.0009462494 63.66061)
         30017              (-66.09629 -119.8142 25.50431)              (4.886506 -3.841407 61.53696)              (-3.194396 1.791498 61.15789)              (-0.9620416 -0.0009255863 63.66086)
         30018              (-66.09537 -119.8131 25.50452)              (4.886494 -3.841387 61.53712)              (-3.19439 1.791495 61.15808)              (-0.962075 -0.0009050651 63.66112)
         30019              (-66.09446 -119.8119 25.50472)              (4.88648 -3.841367 61.53728)              (-3.194384 1.791493 61.15828)              (-0.9621086 -0.0008844772 63.66137)
         30020              (-66.09354 -119.8108 25.50493)              (4.886467 -3.841347 61.53744)              (-3.194377 1.791491 61.15847)              (-0.9621423 -0.0008636631 63.66162)
The Time column and the 4 Velocity Probes are separated by TAB, whereas the Ux Uy and Uz components of each Probes are separated by SPACE. I would like to monitor the Velocity components over the iterations with Gnuplot. The problem is that i don't know how to tell gnuplot to use the single SPACE separated values within a column. Or is there a special functionality for vetor-type data in gnuplot?

My current Gnuplotscript (which is not working....) looks like this :

Code:
# Gnuplot script file for plotting data from file "probes.dat"
set title "Convergence process"
set xlabel "Iterations"
set ylabel "Velocity Ux Uy Uz at selected points"
plot  "postProcessing/probes/30000/U" using 1:2 title 'Probe U1'
     # "postProcessing/probes/30000/U" using 1:3 '(%lf %lf %lf)' title 'Probe U2', \

reread
Any idea?

Cheers!

Charles
McCharles is offline   Reply With Quote

Old   July 20, 2016, 06:43
Default
  #2
Member
 
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 10
hanness is on a distinguished road
Hi Charles,

perhaps it helps if you first delete the brackets?
Code:
plot "< cat postProcessing/probes/30000/U | tr -d '()'" using 1:2 title 'ProbeU1'
not tested though.

regards
Hannes
hanness is offline   Reply With Quote

Old   July 20, 2016, 08:00
Cool
  #3
New Member
 
Join Date: Mar 2016
Posts: 14
Rep Power: 7
RomainBou is on a distinguished road
I followed this tutorial yesterday to do the exact same job (page 249 of the pdf file). I ended up with the following sh script. Read the comments :

Code:
#! /bin/sh

#deleting all parenthesis everywhere in the file, using a temporary "tmp" file that is deleted just at next line :
cat U | tr -d "()" > tmp
mv tmp U

#deleting the 4 first lines of my probe file "U", using a temporary file caled "U.bak" that is erased just at next line :
sed -i.bak "1,4d" U
rm U.bak

gnuplot <<EOF
    reset
    set terminal png
    set output "sonde_vitesse_centrale.png"
    set title "Sonde de vitesse au centre cellule"
    set xlabel 'Temps (s)'
    set ylabel 'V (m/s)'
    plot 'U' u 1:3 w l
EOF
I tested it with only one probe, so i plotted the Uy column (e.g. the 3rd). I think gnuplot doesn't make any difference between Tabs and Spaces.
RomainBou is offline   Reply With Quote

Old   July 21, 2016, 07:12
Default
  #4
Member
 
Charles K.
Join Date: Feb 2016
Location: Germany
Posts: 37
Rep Power: 7
McCharles is on a distinguished road
Thanks Romain and Hannes for your replies,

actually, I found out how to solve my issue.

The solution is quite straight forward and there is no need to change the format or structure of the Vector Data (Ux Uy Uz) in the probe files. I used the following syntax to use the specific vector components in each column:

Code:
1:(($2**2)+($3**2)+($4**2))**(0.5) " %lf (%*lf %*lf %*lf) (%lf %lf %lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf)"
where (($2**2)+($3**2)+($4**2))**(0.5) is the formula to calculate the resulting velocity out of Ux, Uy and Uz

with "%lf (%*lf %*lf %*lf) (%lf %lf %lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf)" it is possible to tell gnuplot which values of each vector in each column it should use or not, %*lf meaning it should ignore the value. I am using 4 probes, that's why I need several brackets.

My final script looks like this:

Code:
# Gnuplot script file for plotting data from file "probes.dat"
set title "Convergence process"
set xlabel "Iterations"
set ylabel "Velocity Ux Uy Uz at selected points"

 plot    'run/alpha90_s24/older/800K_NoSlip/rhoSimplecFoam/postProcessing/probes/30000/U' u 1:(($2**2)+($3**2)+($4**2))**(0.5) " %lf (%*lf %*lf %*lf) (%lf %lf %lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf)" w l title 'Probe U1', \
     'run/alpha90_s24/older/800K_NoSlip/rhoSimplecFoam/postProcessing/probes/30000/U' u 1:(($2**2)+($3**2)+($4**2))**(0.5) " %lf (%*lf %*lf %*lf) (%*lf %*lf %*lf) (%lf %lf %lf) (%*lf %*lf %*lf)" w l title 'Probe U2', \
    '/run/alpha90_s24/older/800K_NoSlip/rhoSimplecFoam/postProcessing/probes/30000/U' u 1:(($2**2)+($3**2)+($4**2))**(0.5) " %lf (%*lf %*lf %*lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf) (%lf %lf %lf)" w l title 'Probe U3'
reread
I hope that i was able to help you all with this issue!
Cheers
McCharles is offline   Reply With Quote

Old   November 27, 2017, 05:05
Default
  #5
New Member
 
Luca Montagliani
Join Date: Nov 2017
Posts: 5
Rep Power: 5
luca_mon is on a distinguished road
resolved in this way to plot the components and the module

set title "U_probe1"
set ylabel 'U'
set yrange [ ]
set xlabel 'time [s]'
plot 'postProcessing/probes/0/U' using 1($2**2)+($3**2)+($4**2))**(0.5) "%lf (%lf %lf %lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf)" w l title 'magU' lt rgb "blue", \
'postProcessing/probes/0/U' using "%lf (%lf %*lf %*lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf)" w l lt rgb "red" title 'Ux',\
'postProcessing/probes/0/U' using "%lf (%*lf %lf %*lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf)" w l lt rgb "green" title "Uy"
pause 1

Thanks

Last edited by luca_mon; November 27, 2017 at 17:16.
luca_mon is offline   Reply With Quote

Old   December 20, 2017, 06:21
Default Help
  #6
gu1
Senior Member
 
Guilherme
Join Date: Apr 2017
Posts: 180
Rep Power: 6
gu1 is on a distinguished road
If you have tree points...

Quote:
set output "conv_U.epg"

set title "Conv"

set xlabel "Time (s)"
set ylabel "magU (m/s)"

set grid xtics lt 0 lw 1 lc rgb "#bbbbbbb"
set grid ytics lt 0 lw 1 lc rgb "#bbbbbbb"

plot 'postProcessing/probes/0/U' u 1: (($2**2)+($3**2)+($4**2))**(0.5) " %lf (%lf %lf %lf) (%*lf %*lf %*lf) (%*lf %*lf %*lf)" title 'pto1' with lines lt 4 lw 1.5, \
'postProcessing/probes/0/U' u 1: (($2**2)+($3**2)+($4**2))**(0.5) " %lf (%*lf %*lf %*lf) (%lf %lf %lf) (%*lf %*lf %*lf)" title 'pto2' with lines lt 3 lw 1.5, \
'postProcessing/probes/0/U' u 1: (($2**2)+($3**2)+($4**2))**(0.5) " %lf (%*lf %*lf %*lf) (%*lf %*lf %*lf) (%lf %lf %lf)" title 'pto3' with lines lt 2 lw 1.5
gu1 is offline   Reply With Quote

Old   September 18, 2018, 11:01
Default Plotting the Velocity with gnuplot
  #7
New Member
 
Johannes
Join Date: Jul 2018
Posts: 6
Rep Power: 4
Mexes is on a distinguished road
Dear Foamers,



in controlDict I defined functions to get probes for the velocity-field on different points. The restult is this:


# Probe 11 (1.5 1.5 1.5)
# Probe 0 1 2 3 4 5 6 7 8 9 10 11
# Time
0.0002 (1.02472 -0.00370842 -0.00702691) (0.298415 0.0239647 0.0236811) (0.0702029 0.0333547 0.033016) (0.184431 -0.026987 -0.0271025) (0.00195649 -0.0108012 -0.0108247) (1.62031 -0.02633 -0.0267462) (1.62019 0.0265368 0.0265032) (0.965851 -0.359919 0.0538214) (0.966087 0.0540248 -0.360035) (1.04432 -0.0152247 -0.0153117) (1.04432 -0.0152247 -0.0153117) (1.04432 -0.0152247 -0.0153117)
0.0002 (1.02472 -0.00370842 -0.00702691) (0.298415 0.0239647 0.0236811) (0.0702029 0.0333547 0.033016) (0.184431 -0.026987 -0.0271025) (0.00195649 -0.0108012 -0.0108247) (1.62031 -0.02633 -0.0267462) (1.62019 0.0265368 0.0265032) (0.965851 -0.359919 0.0538214) (0.966087 0.0540248 -0.360035) (1.04432 -0.0152247 -0.0153117) (1.04432 -0.0152247 -0.0153117) (1.04432 -0.0152247 -0.0153117)

(It's similar to the first post from McCharles!)


So I get vectors with 3 entries for every Point.







How can I plot the x-velocity entry over the time with gnuplot?





Thanks in advice for your help
Mexes is offline   Reply With Quote

Old   October 22, 2018, 16:22
Default
  #8
New Member
 
Tony Jia
Join Date: Jul 2018
Posts: 2
Rep Power: 0
code7760 is on a distinguished road
Hi Mexes,
Have you found a solution to this issue?

Thanks!
code7760 is offline   Reply With Quote

Old   October 22, 2018, 16:51
Default
  #9
New Member
 
Johannes
Join Date: Jul 2018
Posts: 6
Rep Power: 4
Mexes is on a distinguished road
Hi code7760!


I found a solution. It worked when I load the textfiles in Microsoft Excel. Afterwards go with this file back to linux / OpenFoam



For the import in Excel you have to seperat all columns (it's easy. Just try a few different settings). With this file you can plot arbitrary diagrams.



Unfortunately with libre office it didn't work, cause in every field in the beginning there was a --> ' <-- and gnuplot couldn't handle this





Mexes is offline   Reply With Quote

Old   November 18, 2019, 07:44
Default
  #10
New Member
 
Harish Selvam
Join Date: Jun 2019
Posts: 2
Rep Power: 0
Harish Selvam is on a distinguished road
It's working perfectly
Harish Selvam is offline   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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 03:30
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 13:59
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 11:46
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 18:51.