Skip to content

Comments

add semi-automated support for spatial and temporal decoherence#41

Closed
tpchuckles wants to merge 2 commits intosimplifyCalculatorWorker2from
decoherence
Closed

add semi-automated support for spatial and temporal decoherence#41
tpchuckles wants to merge 2 commits intosimplifyCalculatorWorker2from
decoherence

Conversation

@tpchuckles
Copy link
Collaborator

do not merge this before PR #39

background

see issue #40

In multislice simulations, we see Fresnel fringes which we don't see IRL, because the gun technically emits a spectrum of wavelengths (temporal decoherence) whereas we model one wavelength, and because the gun is not a point source and there are lens instabilities (spatial decoherence).

you get around this by simulating a range or wavelengths or a range of aberrations and then do an incoherent sum (getting rid of phase info).

changes

To support this, I add a dimension to Probe._array: summable,positional,x,y, so we can easily run multiple different probe configurations (e.g., different wavelengths, or different defocuses or aberrations). Propagate flattens these first two indices, so the traditional positional,x,y indexing for math and caching still works. of course, things like wavelength and eV are now arrays of wavelengths and eVs, so there were some slight math tweaks to handle this.

I also took this opportunity to move the probe position shifting inside of Probe.applyShift instead of using the external function create_batched_probes. Now the probe tracks its own positions, instead of the calculator needing to track and pass through to WFData and HAADFData. this is not universally cleaned up though: WFData still takes probe_xs as an argument for example (TODO, later though).

i then add the new functions: addTemporalDecoherence and addSpatialDecoherence, which sets up the gaussian spread of wavelengths or defocuses. note: in STEM, spatial decoherence means the probe is defocused, but in TEM, the beam is not focused, and "defocus" really means the lens is not projecting the image plane onto your detector. ergo, we have another addSpatialDecoherence function for your exit_wave, which calls WFData.propagate_free_space instead of Probe.defocus

testing

19_coherence.py is added, which demos manual stacking of multiple probes, or the use of the new functions (which should yield the same result). It also demos decoherence in STEM (applied to the probe) and TEM (applied post-sample).

a test case is also added to 18_caching.py, to ensure there is no cross-talk between otherwise-identical simulations with or without decoherence.

…coherence applyShifts, new example 19_coherence.py in tests.
@h-walk
Copy link
Owner

h-walk commented Jan 9, 2026

Changes already merged to dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants