|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
关于Lorenz系统的控制,驱动系统方程是:
dx1/dt=10*(x2-x1),
dx2/dt=28*x1-x2-x1*x3,
dx3/dt=-8*x3/3+x1*x2;
响应系统方程是:
dy1/dt=10*(y2-y1)
dy2/dt=28*y1-y2-y1*y3
dy3/dt=-8*y3/3+y1*y2+k1*e.
其中dk1/dt=-10*e^2; e=y3-x3。
我用fortran编这个程序,但是结果溢出(出现NaN),下面是我的程序(fortran编写的,四阶Longe-Kutta积分),不知道错在哪里,请高手指教,谢谢!
program Lorenz
implicit none
real*8:: o1,o2,o3,o4,p1,p2,p3,p4,q1,q2,q3,q4
real*8:: r1,r2,r3,r4,s1,s2,s3,s4,t1,t2,t3,t4
real*8:: u1,u2,u3,u4
real*8:: x1,x2,x3,y1,y2,y3
real*8:: e1,e2,e3
real*8:: h,t,k1,u
real*8:: f1,f2,f3,g1,g2,g3,v
integer:: i,n
open(9,file="adaptive.txt")
h=0.01d0
n=10000
x1=0.1
x2=-0.2
x3=0.3
y1=1.0
y2=2.0
y3=3.0
k1=-1.0
do i=1,n
t=h*i
o1=h*f1(x1,x2,x3)
p1=h*f2(x1,x2,x3)
q1=h*f3(x1,x2,x3)
r1=h*g1(y1,y2,y3)
s1=h*g2(y1,y2,y3)
t1=h*g3(y1,y2,y3,k1,x3)
u1=h*v(x3,y3)
o2=h*f1(x1+0.5*o1,x2+0.5*p1,x3+0.5*q1)
p2=h*f2(x1+0.5*o1,x2+0.5*p1,x3+0.5*q1)
q2=h*f3(x1+0.5*o1,x2+0.5*p1,x3+0.5*q1)
r2=h*g1(y1+0.5*r1,y2+0.5*s1,y3+0.5*t1)
s2=h*g2(y1+0.5*r1,y2+0.5*s1,y3+0.5*t1)
t2=h*g3(y1+0.5*r1,y2+0.5*s1,y3+0.5*t1,k1+0.5*u1,x3+0.5*q1)
u2=h*v(x3+0.5*q1,y3+0.5*t1)
o3=h*f1(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0+y1*y2+k1*(y3-x3)
end
function v(x3,y3)
real*8:: v,x3,y3
v=-10.0*(y3-x3)**2
end |
|