Fix lyapunov computation

This commit is contained in:
Ian Jauslin 2024-03-12 01:53:48 +01:00
parent 198867751d
commit 0599f69dc7

View File

@ -78,12 +78,22 @@ int lyapunov(
// copy initial condition
copy_u(u, u0, K1, K2);
// initialize Du_prod
int i,j;
for(i=0;i<MATSIZE;i++){
for(j=0;j<MATSIZE;j++){
Du_prod[i*MATSIZE+j]=0.;
}
}
for(i=0;i<MATSIZE;i++){
Du_prod[i*MATSIZE+i]=1.;
}
// store step (useful for adaptive step methods
double prev_step=delta;
double step=delta;
double next_step=step;
int i;
// init average
for (i=0; i<MATSIZE; i++){
lyapunov_avg[i]=0;
@ -231,8 +241,8 @@ int ns_D_step(
// derivative
for (i=0;i<USIZE;i++){
// use row major order
out[2*klookup_sym(lx,ly,K2)*USIZE+2*i]=(__real__ (tmp1[i]-un_next[i]))/epsilon;
out[(2*klookup_sym(lx,ly,K2)+1)*USIZE+2*i]=(__imag__ (tmp1[i]-un_next[i]))/epsilon;
out[2*klookup_sym(lx,ly,K2)*MATSIZE+2*i]=(__real__ (tmp1[i]-un_next[i]))/epsilon;
out[2*klookup_sym(lx,ly,K2)*MATSIZE+2*i+1]=(__imag__ (tmp1[i]-un_next[i]))/epsilon;
}
// derivative in the imaginary direction
@ -252,8 +262,8 @@ int ns_D_step(
// compute derivative
for (i=0;i<USIZE;i++){
// use row major order
out[2*klookup_sym(lx,ly,K2)*USIZE+2*i+1]=(__real__ (tmp1[i]-un_next[i]))/epsilon;
out[(2*klookup_sym(lx,ly,K2)+1)*USIZE+2*i+1]=(__imag__ (tmp1[i]-un_next[i]))/epsilon;
out[(2*klookup_sym(lx,ly,K2)+1)*MATSIZE+2*i]=(__real__ (tmp1[i]-un_next[i]))/epsilon;
out[(2*klookup_sym(lx,ly,K2)+1)*MATSIZE+2*i+1]=(__imag__ (tmp1[i]-un_next[i]))/epsilon;
}
}
}