- Constant thermal diffusivity makes the Fourier spectral method diagonal: each Fourier mode can be evolved by its exact exponential multiplier.
- The smooth initial Gaussian function has rapidly decaying Fourier coefficients, so a moderate grid resolves it well. The Fast Fourier transform provides an efficient change between the spatial grid and those coefficients.
- A discrete Fourier transform describes a periodically repeated array. Opposite edges are identified by periodic boundary conditions; this is a periodically continued plate model, rather than a plate with prescribed cold or insulated edges.
- The initial hot spot is far from those edges. Over the stated short interval its width remains much smaller than the side length, so the periodic images have negligible influence near the centre. At sufficiently long times, periodic diffusion tends to the conserved spatial mean.
For consistency with the supplied wavenumbers, use an FFT grid on a periodic interval: , , and similarly for . In MATLAB, replace the endpoint-inclusive coordinate definitions by
x = (0:nx-1)*Lx/nx; and y = (0:ny-1)*Ly/ny;. The supplied linspace arrays instead have spacing while the Fourier multipliers assume . Including both copies of the periodic endpoint creates a grid inconsistency, separate from high-frequency aliasing.A spatially uniform source changes only the zero Fourier mode. Its exact integrated increment over a time step beginning at isThe unnormalised two-dimensional discrete Fourier transform stores a constant field as in element This replacement uses the original variable names and MATLAB indexing. The uniform forcing of a periodic heat equation is integrated exactly in time here. No source multiplier is applied to the other modes, and the zero-mode homogeneous multiplier equals one. Adding only
(1,1).[ref]fft2 documentation by MathWorks. The forward defining sum has no normalization; the linked inverse definition includes the factor .
Keep the existing homogeneous exponential multiplication and add this source increment to that element:for i = 1:nt
t = (i-1)*dt;
u_hat = u_hat .* exp(-alpha*K2*dt);
dq = exp(-t/10) - exp(-(t+dt)/10);
u_hat(1,1) = u_hat(1,1) + nx*ny*dq;
enddq to the unnormalised coefficient would underestimate the physical temperature increment by the factor .