Stabilize algorithm by enforcing real parts

This commit is contained in:
Ian Jauslin 2022-05-25 21:42:21 -04:00
parent a55065f474
commit 5d92b56c01

View File

@ -495,7 +495,8 @@ int ns_T(
fftw_execute(fft2.fft_plan);
// write to ifft
for(i=0;i<N1*N2;i++){
ifft.fft[i]=fft1.fft[i]*fft2.fft[i];
// control numerical truncation by taking imaginary part (fft1 and fft2 should be purely imaginary)
ifft.fft[i]=-(__imag__ fft1.fft[i])*(__imag__ fft2.fft[i]);
}
// F(py/|p|*u)*F(qx*|q|*u)
@ -519,7 +520,8 @@ int ns_T(
fftw_execute(fft2.fft_plan);
// write to ifft
for(i=0;i<N1*N2;i++){
ifft.fft[i]=ifft.fft[i]-fft1.fft[i]*fft2.fft[i];
// control numerical truncation by taking imaginary part (fft1 and fft2 should be purely imaginary)
ifft.fft[i]=ifft.fft[i]+(__imag__ fft1.fft[i])*(__imag__ fft2.fft[i]);
}
// inverse fft