【问题标题】:How can I display the current simulation time on my heatmap animation with Gnuplot? [duplicate]如何使用 Gnuplot 在热图动画上显示当前模拟时间? [复制]
【发布时间】:2022-01-12 17:59:28
【问题描述】:

我正在对立方体进行热传递模拟,并使用立方体中间深度的二维热图绘制随时间的演变。

这是使用“Image Viewer”启动的 .gif 热图动画的屏幕截图:

我想在 .gif 动画上显示每次迭代的当前模拟时间,也就是说,在每个图像上,使用 Gnuplot。实际上,增量时间是 0.001 s,所以我想显示类似“Time = 0.001 s”...“Time = 0.002 s”之类的内容。

我的数据集是这样的:

  x      z       t      T
0.000  0.000  0.000  373.000
0.000  0.005  0.000  298.000
0.000  0.015  0.000  298.000
            ...
0.000  0.985  0.000  298.000
0.000  0.995  0.000  298.000
0.000  1.000  0.000  373.000

            ...
0.015  0.000  0.001  373.000
0.015  0.005  0.001  292.000
0.015  0.015  0.001  283.000
0.015  0.025  0.001  283.000
           ....
0.015  0.985  0.001  283.000
0.015  0.995  0.001  292.000
0.015  1.000  0.001  373.000
           ...
0.615  0.000  0.004  373.000
0.615  0.005  0.004  309.900
0.615  0.015  0.004  287.100
0.615  0.025  0.004  283.300
           ...

这里是 Gnuplot 的 .plt 代码:

set view map scale 1
set size square
set xlabel("x (m)")
set ylabel("z (m)")
set zlabel("T")
set xrange [-0.01:1.01]
set yrange [-0.01:1.01]
set title "Heat transfert 3D at mid depth of a cube"
set cblabel "T (K)"

set hidden3d
set palette rgb 33,13,10 
set cbrange [283:373] # colobar range

set pm3d implicit at s 
set pm3d corners2color max 

set term gif animate delay 100 

set output "para_heat_3D_insta_4_0.gif"

stats "plot_para_heat_3D_insta.dat"

do for [i=1:int(STATS_blocks)]{
    splot "plot_para_heat_3D_insta.dat" index (i-1) using 1:2:4 with pm3d notitle 

}

set output

有人有想法可以帮助我吗?提前致谢。

【问题讨论】:

    标签: animation gnuplot simulation heatmap current-time


    【解决方案1】:

    使用当前版本的 gnuplot (5.4) 的解决方案

    DATA = "plot_para_heat_3D_insta.dat"
    set key center at screen 0.5, 0.95
    set key samplen 0
    
    do for [i=1:int(STATS_blocks)]{
        splot DATA index (i-1) using 1:2:(t=$3,$4) with pm3d title sprintf("time = %g",t)
    
    }
    

    这会将变量 t 设置为每个评估点的第 3 列的内容。评估完所有点后,最后一个点的第 3 列值仍位于 t 中,因此您可以使用它来构造绘图的标题。

    如果您有早期版本的 gnuplot

    同样的技巧是可能的,但它需要一个额外的虚拟绘图命令来加载 t 但不绘制任何东西。

    do for [i=1:int(STATS_blocks)]{
        splot DATA index (i-1) every 1::1::1 using (t=$3):(NaN):(NaN) notitle, \
              DATA index (i-1) using 1:2:4 with pm3d title sprintf("time = %g",t)
    }
    

    【讨论】:

    • 感谢您的回答。我有 Gnuplot 的 5.2 版本,第一个命题似乎有效,但是 time = 0 被 time = NaN 取代,所以我没有最后一次的显示。不知道为什么……?但第二个命题完美!谢谢!
    • 关键是 5.4 版评估标题 after 情节,而早期版本评估标题 before 情节。如果您在每个绘图之前和之后考虑t 的值,就会解释两种不同解决方案的原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    • 1970-01-01
    • 2020-03-27
    • 2012-08-27
    相关资源
    最近更新 更多