Open bpbrown opened 1 year ago
It's unclear what we want to do to change things here. We could stop zeroing the Nyquist mode for ComplexFourier, which is generally what is used with EVPs. But I think we do want to continue dropping the Nyquist mode for RealFourier since otherwise there will be weird matrix shape errors since only the cosine mode is supported there. That would mean real and complex Fourier have different behavior... but maybe that isn't so bad?
For multi-dimensional Eigenvalue Problems solved using our current best-practices approach (see
examples/evp_1d_rayleigh_benard/rayleigh_benard_evp.py
) we run into an edge case withset_modes()
when trying to plot eigenmodes.Best practices are to set up a small dimension in the wave-perturbation direction of size
Nx=2
, and lengthLx = 2 * np.pi / kx
, which puts the mode to be studied in the second index. When we do this, and then useset_state
, the associated fields have values in coefficient space, but the first transform to grid space zeros out all of the data.Here is a minimal example that reproduces this, using Rayleigh-Benard convection with stress-free boundaries (where the modes are analytic).:
The result of this script is:
The correct mode is found (an unstable growing mode), but the eigenfunction is zero when evaluated in grid space and remains that way on return to coeff space.
This is related to zeroing of Nyquist modes.
If
Nx = 4
is used instead ofNx = 2
, then correct behaviour is instead found:Now the eigenmodes are not zeroed on transform, retain the same coeff amplitudes on return to coeff space, and match both eigenvalue and coeff amplitude with the original implementation. The individual eigenmode structures now also match expectations.