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

Use gnuplot to plot graph of friction_coefficient for T3A Flat Plate case in OpenFOAM

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

Rate this Entry

Use gnuplot to plot graph of friction_coefficient for T3A Flat Plate case in OpenFOAM

Posted February 12, 2019 at 23:29 by purnp2

Hello,
I am new to OF and gnuplot. I am working on the T3A flat plate case in tutorials of OpenFOAM. I was struggling a lot to plot graph of friction coefficient from simulation and experimental data using the default plot_file (creatGraphs.plt) provided with the tutorial. I looked on the internet for a solution but remained unsuccessful. So, after trying for some time, I got the graph correct so I decided to share it here for use of anyone else.

The trick is we have to edit the default plot file provided in the case file. This is how the default file looks like:
Code:
#!/bin/sh
cd ${0%/*} || exit 1                        # Run from this directory

# Test if gnuplot exists on the system
command -v gnuplot >/dev/null 2>&1 || {
    echo "gnuplot not found - skipping graph creation" 1>&2
    exit 1
}

gnuplot<<GNUPLOT
    set term post enhanced color solid linewidth 2.0 20
    set out "graphs.eps"
    set encoding utf8
    set termoption dash
    set style increment user
    set style line 1 lt 1 linecolor rgb "blue"  linewidth 1.5
    set style line 11 lt 2 linecolor rgb "black" linewidth 1.5

    time = system("foamListTimes -case .. -latestTime")

    set xlabel "x"
    set ylabel "u'"
    set title "T3A - Flat Plate - turbulent intensity"
    plot [:1.5][:0.05] \
        "../postProcessing/kGraph/".time."/line_k.xy" \
        u (\$1-0.04):(1./5.4*sqrt(2./3.*\$2))title "kOmegaSSTLM" w l ls 1, \
        "exptData/T3A.dat" u (\$1/1000):(\$3/100) title "Exp T3A" w p ls 11

    set xlabel "Re_x"
    set ylabel "c_f"
    set title "T3A - Flat Plate - C_f"
    plot [:6e+5][0:0.01] \
        "../postProcessing/wallShearStressGraph/".time."/line_wallShearStress.xy" \
        u ((\$1-0.04)*5.4/1.5e-05):(-\$2/0.5/5.4**2) title "kOmegaSSTLM" w l, \
        "exptData/T3A.dat" u (\$1/1000*5.4/1.51e-05):2 title "Exp" w p ls 11
GNUPLOT

#------------------------------------------------------------------------------
After editing it, it should look like the following:
Code:
# #!/bin/sh
# cd ${0%/*} || exit 1                        # Run from this directory

# # Test if gnuplot exists on the system
# command -v gnuplot >/dev/null 2>&1 || {
    # echo "gnuplot not found - skipping graph creation" 1>&2
    # exit 1
# }

# gnuplot<<GNUPLOT
    set term post enhanced color solid linewidth 2.0 20
    set out "graphs2.eps"
    set encoding utf8
    set termoption dash
    set style increment user
    set style line 1 lt 1 linecolor rgb "blue"  linewidth 1.5
    set style line 11 lt 2 linecolor rgb "black" linewidth 1.5

    time = system("foamListTimes -case .. -latestTime")

    # set xlabel "x"
    # set ylabel "u'"
    # set title "T3A - Flat Plate - turbulent intensity"
    # plot [:1.5][:0.05] \
        # "../postProcessing/kGraph/".time."/line_k.xy" \
        # u (\$1-0.04):(1./5.4*sqrt(2./3.*\$2))title "kOmegaSSTLM" w l ls 1, \
        # "exptData/T3A.dat" u (\$1/1000):(\$3/100) title "Exp T3A" w p ls 11

    set xlabel "Re_x"
    set ylabel "c_f"
    set title "T3A - Flat Plate - C_f"
    plot [:6e+5][0:0.01] \
		"/home/purnp2/OpenFOAM/purnp2-v1812/run/T3A/postProcessing/wallShearStressGraph/269/line_wallShearStress.xy" \
        u (($1-0.04)*5.4/1.5e-05):(-$2/0.5/5.4**2) title "kOmegaSSTLM" w l, \
        "/home/purnp2/OpenFOAM/purnp2-v1812/run/T3A/validation/exptData/T3A.dat" u ($1/1000*5.4/1.51e-05):2 title "Exp" w p ls 11
# GNUPLOT

#------------------------------------------------------------------------------
Please notice the following changes:
a. the lines need to be commented out.
2. the back-slash (\) sign deleted before all dollar-sign ($) which is used to represent a column in a file used by gnuplot for plotting the graph.
3. full path of data files is added instead of a path to the data file from the current working directory.
Posted in Uncategorized
Views 474 Comments 0 Edit Tags Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT -4. The time now is 09:37.