Average energy

This commit is contained in:
Ian Jauslin 2022-05-26 21:11:56 -04:00
parent 77043e249c
commit 777a51be49

View File

@ -99,6 +99,9 @@ int energy(
// copy initial condition
copy_u(u, u0, K1, K2);
// init running average
avg=0;
// iterate
for(t=0;t<nsteps;t++){
ins_step(u, K1, K2, N1, N2, nu, delta, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3);
@ -111,8 +114,13 @@ int energy(
}
}
fprintf(stderr,"%d % .8e % .8e\n",t,t*delta, energy);
printf("%8d % .15e % .15e\n",t,t*delta,energy);
// running average
if(t>0){
avg=avg-(avg-energy)/t;
}
fprintf(stderr,"%d % .8e % .8e % .8e\n",t,t*delta, energy, avg);
printf("%8d % .15e % .15e % .15e\n",t,t*delta,energy,avg);
}
}