The procedure of time convergence order is as follows, but this procedure is not wrong, the final calculation can not reach the theoretical second order, only the first order, why?
real lambda=0.5;
real Tf=0.5;
real t0=0;
load “MUMPS_seq”
int m1=16,n1=16;
ofstream error(“time4096,P2,01.13,”+omega+","+lambda+","+Tf+","+m1+","+n1+".txt");
int MM=4;
real[int] b(MM);
b(0)=8;b(1)=16;b(2)=32;b(3)=4096;
mesh Th1=square(m1,n1,[-8+16x,-8+16y]);
fespace Xhf(Th1,P2);
Xhf[int] fepsai2(MM),fedxpsai2(MM),fedypsai2(MM);
for(int mm=1;mm<=MM;mm++)
{
real dt=Tf/b(mm-1);
Xhf psai2,u;
Xhf psai0=(exp(-2x^2-2y^2))(x+1iy)/(x^2+y^2+1);
Xhf psait0=1ipsai0;
Xhf psai1=psai0+dtpsait0;
for(real t=0+dt*2;t<=Tf;t+=dt)
{
problem kg2(psai2,u,solver=sparsesolver,master=-1)=int2d(Th1)(psai2*u/(dt^2))-int2d(Th1)(2*psai1*u/(dt^2))+int2d(Th1)(psai0*u/(dt^2))
+int2d(Th1)(0.5*dx(psai2)*dx(u)+0.5*dy(psai2)*dy(u))+int2d(Th1)(0.5*dx(psai0)*dx(u)+0.5*dy(psai0)*dy(u))
+int2d(Th1)(0.5*psai2*u)+int2d(Th1)(0.5*psai0*u)
+int2d(Th1)(0.5*0*psai2*u)+int2d(Th1)(0.5*0*psai0*u)
+int2d(Th1)(lambda*psai1*conj(psai1)*psai1*u)+on(1,2,3,4,psai2=0);
kg2;
psai0=psai1;
psai1=psai2;
}
fepsai2[mm-1]=psai2;
fedxpsai2[mm-1]=dx(psai2);
fedypsai2[mm-1]=dy(psai2);
}
real[int] L2error(MM-1),H1error(MM-1);
for(int i=0;i<MM-1;i++){
L2error[i]=sqrt(int2d(Th1)(abs(fepsai2[i]-fepsai2[MM-1])^2));
H1error[i]=sqrt(int2d(Th1)(abs(fepsai2[i]-fepsai2[MM-1])^2+abs(fedxpsai2[i]-fedxpsai2[MM-1])^2+abs(fedypsai2[i]-fedypsai2[MM-1])^2));
error<<" L2error"<<L2error[i]<<“H1error”<<H1error[i]<<endl;
}
real[int] CL2error(MM-2),CH1error(MM-2);
for(int n=0;n<MM-2;n++){
CL2error[n]=log(L2error[n]/L2error[n+1])/log(2.);
CH1error[n]=log(H1error[n]/H1error[n+1])/log(2.);
error<<" CL2"<<CL2error[n]<<“CH1”<< CH1error[n]<<endl;
}