Efficient subvolume beam simulation
We should implement a method where we extract a full-thickness subvolume from the full potential before running multislice for a single beam. This should greatly increase the speed we simulate individual beams. The assumption, which may be hard to check efficiently at runtime, is that the wavefunction even after scattering is confined to a narrow window around the beam axis, so that computations outside that window are wasted as the wavefunction will be very near zero anyway. Simulating a subvolume replaces those zeros with a periodic tiling of the wavefunction, and a corresponding periodic tiling of the potential subvolume. If our assumption is satisfied, then after simulation of the small exit wave, the true exit wave on the full-size grid could be acquired (for integer multiple full sizes) by placing the small-grid Fourier components every "mth" frequency then convolving by a sinc function. That is essentially sinc interpolation for upscaling the complex CBED. We currently use linear interpolation of cbed intensities in order to resize to match the detector geometry anyway, so I propose that we just continue using that.
Plan
This can be implemented as an option in the Multislice
class which will perform the subvolume extraction and beam position adjustment (relative to the subvolume), then pass to multislice_direct
. The resulting exit wavefunction in reciprocal space will have smaller shape than the full XY shape, but Microscope.resample_cbed
should handle that gracefully as it only depends on the real space voxel spacing.
Another issue is what size should probe_f
be? We should initialize it based on subvolume shape, not overall image extent. We could implement a simulation_plane_shape
attribute or method in Multislice
and use that at probe initialization instead of directly relying on the potential's size.