0

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

这是使用“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

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

4

1 回答 1

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)
}
于 2022-01-12T19:26:30.157 回答