Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Animation 如何在Gnuplot 5中制作动画gif_Animation_Fortran_Gnuplot_Animated Gif - Fatal编程技术网

Animation 如何在Gnuplot 5中制作动画gif

Animation 如何在Gnuplot 5中制作动画gif,animation,fortran,gnuplot,animated-gif,Animation,Fortran,Gnuplot,Animated Gif,基本上,我已经解出了(x,y,t)的热方程,我想显示温度函数随时间的变化。程序是用Fortran 90编写的,解的数据存储在diffeqn3D_file.txt文件中 以下是节目: Program diffeqn3D Implicit none Integer:: b,c,d,l,i,j,k,x,y,t Real:: a,r,s,h,t1,k1,u,v,tt,p Real,Dimension(0:500,0:500,0:500):: f1 !f=f(x,t) !t1=time

基本上,我已经解出了(x,y,t)的热方程,我想显示温度函数随时间的变化。程序是用Fortran 90编写的,解的数据存储在diffeqn3D_file.txt文件中

以下是节目:

Program diffeqn3D
  Implicit none
  Integer:: b,c,d,l,i,j,k,x,y,t
  Real:: a,r,s,h,t1,k1,u,v,tt,p
  Real,Dimension(0:500,0:500,0:500):: f1 !f=f(x,t)
  !t1=time step and h=position step along x and
  !k=position step along y and a=conductivity
  open(7, file='diffeqn3D_file.txt', status='unknown')
  a=0.024
  t1=0.1
  h=0.1
  k1=0.1
  r=(h**2)/(k1**2)
  s=(h**2)/(a*t1)
  l=10
  tt=80.5
  b=100
  c=100
  d=100
  !The temperature is TT at x=0 and 0 at x=l.
  !The rod is heated along the line x=0.
  !Initial conditions to be changed as per problem..
  Do x=0,b
     Do y=0,c
        Do t=0,d
           If(x==0) Then
              f1(x,y,t)=tt
           Else If((x.ne.0).and.t==0) Then
              f1(x,y,t)=0
           End If
        End Do   
     End Do
  End Do
  print *,f1(9,7,5)
  print *,r
  print *,a,h,t1,h**2,a*t1,(h**2)/(a*t1)
  print *,f1(0,1,1)
  print *,f1(3,1,1)
  !num_soln_of_eqnwrite(7,*)
  Do t=1,d
     Do y=1,c-1
        Do x=1,b-1
           p=f1(x-1,y,t-1)+f1(x+1,y,t-1)+r*f1(x,y-1,t-1)+r*f1(x,y+1,t-1)-(2+2*r-s)*f1(x,y,t-1)
           f1(x,y,t)=p/s
           !f1(x,t)=0.5*(f1(x-1,t-1)+f1(x+1,t-1))
           !print *,f1(x,t),b
        End Do
     End Do
  End Do
  Do i=0,d
     Do k=0,b
        Do j=0,c
           u=k*h
           v=j*k1
           write(7,*) u,v,f1(k,j,i)
        End Do
     End Do
     write(7,*) "  "
     write(7,*) "  "
  End Do
  close(7)
End Program diffeqn3D
编译并运行之后,我在gnuplot中输入以下代码,但它没有运行,而是挂起或创建gif图片,而不是动画

set terminal gif animate delay 1
set output 'diffeqn3D.gif'
stats 'diffeqn3D_file.txt' nooutput
do for [i=1:int(STATS_blocks)] {
  splot 'diffeqn3D_file.txt'
   }
有时它还会显示一条警告消息,指出自动缩放范围没有z值


我的代码有什么问题,应该如何继续?

首先,尝试添加一些用于“调试”信息的
print
命令:

set terminal gif animate delay 1
set output 'diffeqn3D.gif'
stats 'diffeqn3D_file.txt' nooutput
print int(STATS_blocks)
do for [i=1:int(STATS_blocks)] {
  print i
  splot 'diffeqn3D_file.txt'
}
第二,发生了什么

splot
命令没有索引说明符,请尝试使用:

splot 'diffeqn3D_file.txt' index i
如果没有索引i,gnuplots总是打印整个文件,这有两个后果:

  • 数据文件相当大。密谋需要相当长的时间,而且gnuplot似乎挂起了
  • Gnuplot始终绘制相同的数据,没有显示在动画中的更改
  • 现在gnuplot运行得更快,我们将修复自动缩放错误。同样,有两点:

  • 索引
    指定数据文件中的数据集。
    stats
    命令统计那些“由成对的空白记录分隔”(来自gnuplot文档)的集合。您的数据文件以一对空白记录结束-这将在gnuplot中启动一个新的数据集。但是这个数据集是空的,这最终导致了错误。只有
    STATS\u blocks-1
    数据集

  • 索引是基于零的。循环应以0开始,以STATS_blocks-2结束

  • 所以我们得到了这个绘图命令:

    do for [i=0:int(STATS_blocks)-2] {
      print i
      splot 'diffeqn3D_file.txt' index i
    }
    

    请对所有Fortran问题使用tag。你的问题甚至不针对旧的90标准。事实上,我不确定Fortran部分是否与此相关……您可能确实能够用它创建的输出的一个样本来替换整个Fortran代码(甚至只是列表定向输出)。@francescalus您能告诉我GNU术语中的代码有什么问题吗?我不是一个热心的程序员。恐怕我对这些gnuplot方面完全没有经验。但是,如果您对Fortran有问题。。。