【发布时间】:2017-12-26 12:37:34
【问题描述】:
基本上,我已经求解了 (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 值。
我的代码有什么问题,我应该如何处理?
【问题讨论】:
-
对于所有 Fortran 问题,请使用标签 fortran。您的问题甚至不是针对旧的 90 标准。实际上,我不确定 Fortran 部分是否与此处相关......
-
您确实可以用它创建的输出样本替换整个 Fortran 代码(它甚至只是列表导向的输出)。
-
@francescalus 你能告诉我 GNU 术语中的代码有什么问题吗?我不是一个狂热的程序员。
-
恐怕我对这些 gnuplot 方面完全没有经验。但是,如果您对 Fortran 有疑问...
标签: animation fortran gnuplot animated-gif