"初始化程序
const k=0.375,f=0.95
const x=2,max=200
const H=6,Cd=0.1,Co=0.2
Dim xc,x3,y3,x4,xc1,L as Single
Dim T,Cg as single
Dim g(max),w(max)
Dim a(max),b(max),d(max)
Dim a1(max),b1(max),d1(max)
Dim s(max),c(max),c1(max)
Dim I as Integer
FOR I=1 To max
c(I)=Co
c1(I)=Co
NEXT
"矩阵元素计算与赋值
a(1)=-f
d(1)=1+f+u
FOR I=2 To max-1
a(I)=-f
b(I)=-f
d(I)=2*(1+f)
NEXT
b(max)=-f
a(max)=1+f
a1(1)=f
d1(1)=1-f-k
FOR I=2 To max-1
a(I)=f
b(I)=f
d(I)=2*(1-f)
NEXT
b(max)=f
a(max)=1-f
s(1)=d1(1)*c1(1)+a1(1)*c(2)+2*k*Cg
s(max)=b1(max)*c(max-1)+d1(max)*c(max)
FOR I=2 To max-1
s(I)=b1(I)*c(I-1)+d1(I)*c(I)+a1(I)*c(I+1)
NEXT
"求g(i),w(i)追的过程
g(1)=s(1)/d(1)
w(1)=a(1)/d(1)
FOR I=2 To max-1
W(I)=a(I)/(d(I)-b(I)*w(z-1))
g(I)=(s(I)-b(I)*g(I-1))/(d(I)-b(I)*w(I-1))
NEXT
"保存前一时刻的c(I)
FOR I=1 To max
c1(I)=c(I)
NEXT
"求当前时刻各点浓度值c(I)赶的过程
g(max)=(s(max)-b(max)*g(max-1))/d(max)-b(max)*w(max-1)
c(max)=g(max)
FOR I=max-1 To 1 step-1
c(I)=g(I)-w(I)*c(I+1)
NEXT
"做浓度梯度曲线
x4=line8.x1-x3
xc1=x4/max
FOR I=1 To max
Frm.line((x3+(i-1)*xd),y3)-((x3+(I-1)*xc1),(y3-L*c1(I))),Frm.BackColor
Frm.line((x3+(I-1)*xc1),y3)-((x3+(I-1)*xc1),(y3-L*c(I))),RGB(0,0,255*Rnd)
NEXT
const k=0.375,f=0.95
const x=2,max=200
const H=6,Cd=0.1,Co=0.2
Dim xc,x3,y3,x4,xc1,L as Single
Dim T,Cg as single
Dim g(max),w(max)
Dim a(max),b(max),d(max)
Dim a1(max),b1(max),d1(max)
Dim s(max),c(max),c1(max)
Dim I as Integer
FOR I=1 To max
c(I)=Co
c1(I)=Co
NEXT
"矩阵元素计算与赋值
a(1)=-f
d(1)=1+f+u
FOR I=2 To max-1
a(I)=-f
b(I)=-f
d(I)=2*(1+f)
NEXT
b(max)=-f
a(max)=1+f
a1(1)=f
d1(1)=1-f-k
FOR I=2 To max-1
a(I)=f
b(I)=f
d(I)=2*(1-f)
NEXT
b(max)=f
a(max)=1-f
s(1)=d1(1)*c1(1)+a1(1)*c(2)+2*k*Cg
s(max)=b1(max)*c(max-1)+d1(max)*c(max)
FOR I=2 To max-1
s(I)=b1(I)*c(I-1)+d1(I)*c(I)+a1(I)*c(I+1)
NEXT
"求g(i),w(i)追的过程
g(1)=s(1)/d(1)
w(1)=a(1)/d(1)
FOR I=2 To max-1
W(I)=a(I)/(d(I)-b(I)*w(z-1))
g(I)=(s(I)-b(I)*g(I-1))/(d(I)-b(I)*w(I-1))
NEXT
"保存前一时刻的c(I)
FOR I=1 To max
c1(I)=c(I)
NEXT
"求当前时刻各点浓度值c(I)赶的过程
g(max)=(s(max)-b(max)*g(max-1))/d(max)-b(max)*w(max-1)
c(max)=g(max)
FOR I=max-1 To 1 step-1
c(I)=g(I)-w(I)*c(I+1)
NEXT
"做浓度梯度曲线
x4=line8.x1-x3
xc1=x4/max
FOR I=1 To max
Frm.line((x3+(i-1)*xd),y3)-((x3+(I-1)*xc1),(y3-L*c1(I))),Frm.BackColor
Frm.line((x3+(I-1)*xc1),y3)-((x3+(I-1)*xc1),(y3-L*c(I))),RGB(0,0,255*Rnd)
NEXT