fortran运算时出现NaN,不知道怎么了,并且这个程序运算出来的结果不收敛,不懂了。。
这是一个解薛定谔方程的程序,用的是numerov算法。subroutineintgrt(ei,phip)implicitreal*8(a-h,o-z)dimensionk...
这是一个解薛定谔方程的程序,用的是numerov 算法。
subroutine intgrt(ei,phip)
implicit real*8 (a-h,o-z)
dimension k(0:1100)
real*8 K
integer n
open(1,file="out.dat",status="unknown")
b=0.
z=0.
nstep=1000
h=0.001
phim=0.
phiz=0.001
k(0)=1.0e5*dsqrt(26.19207*ei-0.447821*(b*z)**2)
k(1)=1.0e5*dsqrt(26.19207*ei-0.447821*(b*(z+h))**2)
k(2)=1.0e5*dsqrt(26.19207*ei-0.447821*(b*(z+2*h))**2)
do 10 n=2,nstep
k(n)=1.0e5*dsqrt(26.19207*ei-0.447821*(b*(z+n*h))**2.)
c1=2*(1-5.*(h*k(n))**2/12.)/(1+(h*k(n+1))**2/12.)
c2=-(1+(h*k(n-1))**2/12.)/(1+(h*k(n+1))**2/12.)
phip=c1*phiz+c2*phim
phim=phiz
phiz=phip
10 continue
write(1,*) ei,phip
return
end
program main
real*8 ei,dei,phip,phiold
ei=0.02
dei=0.001
call intgrt(ei,phip)
phiold=phip
10 continue
ei=ei+dei
call intgrt(ei,phip)
if (phip*phiold .lt. 0) then
ei=ei-dei
dei=dei/2
end if
if (dabs(dei) .gt. 1.e-6) goto 10
print*,'eigenvalue=',ei,'function=',phip
stop
end 展开
subroutine intgrt(ei,phip)
implicit real*8 (a-h,o-z)
dimension k(0:1100)
real*8 K
integer n
open(1,file="out.dat",status="unknown")
b=0.
z=0.
nstep=1000
h=0.001
phim=0.
phiz=0.001
k(0)=1.0e5*dsqrt(26.19207*ei-0.447821*(b*z)**2)
k(1)=1.0e5*dsqrt(26.19207*ei-0.447821*(b*(z+h))**2)
k(2)=1.0e5*dsqrt(26.19207*ei-0.447821*(b*(z+2*h))**2)
do 10 n=2,nstep
k(n)=1.0e5*dsqrt(26.19207*ei-0.447821*(b*(z+n*h))**2.)
c1=2*(1-5.*(h*k(n))**2/12.)/(1+(h*k(n+1))**2/12.)
c2=-(1+(h*k(n-1))**2/12.)/(1+(h*k(n+1))**2/12.)
phip=c1*phiz+c2*phim
phim=phiz
phiz=phip
10 continue
write(1,*) ei,phip
return
end
program main
real*8 ei,dei,phip,phiold
ei=0.02
dei=0.001
call intgrt(ei,phip)
phiold=phip
10 continue
ei=ei+dei
call intgrt(ei,phip)
if (phip*phiold .lt. 0) then
ei=ei-dei
dei=dei/2
end if
if (dabs(dei) .gt. 1.e-6) goto 10
print*,'eigenvalue=',ei,'function=',phip
stop
end 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询