Function compute_spectrum_kykx does not accepts a field with complex data type
Created originally on Bitbucket by calpe (Miguel Calpe)
#!python
"""
issue_fluidfft_spectrum_kykx_for_complex_field.py
==================================================
29/11/2018
Issue:
------
Function compute_spectrum_kykx does not accepts a
field with complex data type.
TypeError:
---------
TypeError Traceback (most recent call last)
~/issue_fluidfft_spectrum_kykx.py in <module>()
23
24 # Compute spectra ky kx
---> 25 a_fft = oper.compute_spectrum_kykx(a_complex)
~/Dev/fluidfft/fluidfft/fft2d/operators.py in compute_spectrum_kykx(self, energy_fft)
558 E_kykx[: self.nkyE, : self.nkxE] = E_kykxtmp[: self.nkyE, : self.nkxE]
559 E_kykx[1 : self.nkyE2, :] += E_kykxtmp[self.nkyE : self.nky_seq, :][
--> 560 ::-1
561 ]
562 elif self.is_transposed:
TypeError: Cannot cast ufunc add output from dtype('complex128') to dtype('float64') with casting rule 'same_kind'
"""
import numpy as np
from math import pi
from fluidfft.fft2d.operators import OperatorsPseudoSpectral2D
# Parameters
nx = ny = 32
Lx = Ly = 2 * pi
# Create instance operators
oper = OperatorsPseudoSpectral2D(nx, ny, Lx, Ly)
# Create vector field complex
a_complex = np.empty([nx, ny//2 + 1], dtype="complex")
# Compute spectra ky kx
a_fft = oper.compute_spectrum_kykx(a_complex)