|
x0=0
y0=1
xf=1
nn=100
h=(xf-x0)/nn
x=x0
y=y0
c
100 continue
call rk5(x,y,xx,yy)
c
if(x.lt. xf)
x=x+h
go to 100
end if
stop
end
c
c...This subroutine solves nonlienar ODE using the fifth order Rounge-Kutta Method
c suggested bby Butcher - J. Australian Math. Soc., Vol. 4, 1964, o.179.
c
subroutine rk5 (xi,yi,h,yy)
ek1=h*feval(u[i],v[i],t[i]);
em1=h*geval(u[i],v[i],t[i]);
ek2=h*feval(u[i]+k1/3.0,v[i]+m1/3.0,t[i]+h/3.0);
em2=h*geval(u[i]+k1/3.0,v[i]+m1/3.0,t[i]+h/3.0);
ek3=h*feval(u[i]+k1/6.0+k2/6.0,v[i]+m1/6.0+m2/6.0,t[i]+h/3.0);
em3=h*geval(u[i]+k1/6.0+k2/6.0,v[i]+m1/6.0+m2/6.0,t[i]+h/3.0);
ek4=h*feval(u[i]+k1/8.0+3.0*k3/8.0,v[i]+m1/8.0+3.0*m3/8.0,t[i]+h/2.0);
em4=h*geval(u[i]+k1/8.0+3.0*k3/8.0,v[i]+m1/8.0+3.0*m3/8.0,t[i]+h/2.0);
ek5=h*feval(u[i]+k1/2.0-3.0*k3/2.0+2.0*k4,v[i]+m1/2.0-3.0*m3/2.0+2.0*m4,t[i]+h);
em5=h*geval(u[i]+k1/2.0-3.0*k3/2.0+2.0*k4,v[i]+m1/2.0-3.0*m3/2.0+2.0*m4,t[i]+h);
E1=(2.0*k1-9.0*k3+8.0*k4-k5)/30.0;
E2=(2.0*m1-9.0*m3+8.0*m4-m5)/30.0;
u[i+1]=u[i]+(k1+4.0*k4+k5)/6.0;
v[i+1]=v[i]+(m1+4.0*m4+m5)/6.0;
t[i+1]=t[i]+h;
c
x1=xi
y1=yi
call func(x1,y1,f1)
ek1=h*f1
x2=xi+h/4
y2=yi+ek1/4
call func(x2,y2,f2)
ek2=h*f2
c
x3=xi+h/4
y3=yi+ek1/8+ek2/8
call func(x3,y3,f3)
ek3=h*f2
c
x4=xi+h/2
y4=yi-ek2/2+ek3
call func(x4,y4,f4)
ek4=h*f4
c
x5=xi+3.*h/4.
y5=yi+3.*ek1/16.+9.*ek4/16.
call func(x5,y5,f5)
ek5=h*f5
c
x6=xi+h
y6=yi-3.*ek1/7.+2.*ek2/7.+12.*ek3/7.-12.*ek4/7.+8.*ek6/7.
call func(x6,y6,f6)
ek6=h*f6
c
yy=yi+(7.*ek1+32.*ek3+12.*ek4+32.*ek5+7.*ek6)
return
end
subroutine func(x,y,f,g)
c
c...This subroutine claculates the value of f(x,y)
c
f=x
return
end |
评分
-
1
查看全部评分
-
|