|
|
发表于 2002-7-21 15:12:57
|
显示全部楼层
【建议】能否提供一些源代码分析说明?
include 'TriCross.f90' !TriCross是求解三对角方程的子程序
program main
implicit none
real:: L,NJ,TIME,DT,Y,UEDGE,UINITIAL
real,dimension(1:200,0:1000)::u
real,allocatable,dimension(:, :: a
real,allocatable,dimension( ::b,U1D
real,dimension(0:1000)::x,tm
integer i,j,n,jmax,nmax
real dx,r
!-------------------------
open(1,file = 'control.txt',status = 'old')
read(1,*)
read(1,*) L
read(1,*)
read(1,*) NJ
read(1,*)
read(1,*) TIME
read(1,*)
read(1,*) DT
read(1,*)
read(1,*) Y
read(1,*)
read(1,*) UEDGE
read(1,*)
read(1,*) UINITIAL
close(1)
!-----------------------
nmax = int(TIME/DT)
dx = L/(NJ-1)! Length
jmax = NJ
do j = 1, jmax
X(j) = dx * (j-1)
end do
do n = 0,nmax
Tm(n) = DT * n
end do
!------------------------
do j = 1, jmax
U(j,0) = UInitial
end do
do n = 0, nmax
U(1,n)= UEdge
U(jmax,n)= UEdge
end do
!-------------------------
r = Y*DT/dx**2
!--------------- 三对角方程求解 ------------
allocate(a(jmax-2,jmax-2))
a = 0.0
do j = 2, jmax-3
a(j,j) = -2*(r+1)
a(j,j-1) = r
a(j,j+1) = r
end do
a(1,1) = -2*(r+1)
a(1,2) = r
a(jmax-2,jmax-2) = -2*(r+1)
a(jmax-2,jmax-3) = r
allocate(b(jmax-2))
b = 0.0
allocate(U1D(jmax-2))
U1D = 0.0
do n = 0, nmax-1
do j = 1,jmax-2
b(j) = -r*U(j+2,n)+2*(r-1)*U(j+1,n)-r*U(j,n)
end do
b(1) = b(1) - r*U(1,n+1)
b(jmax-2) = b(jmax-2) - r*U(jmax,n+1)
CALL TriCross(a,b,U1D,jmax-2)
do j = 1, jmax-2
U(j+1,n+1) = U1D(j)
end do
continue
end do
!---------------------------
open(1,file = 'Simple.tec')
write(1,*)" variables = x,t,u"
write(1,*) " zone i = "
write(1,*) jmax
write(1,*) " j = "
write(1,*) nmax+1
do i = 0, nmax
do j = 1, jmax
write(1,*) tm(i), X(j), U(j,i)
end do
end do
close(1)
end program main |
|