pypty.multislice_core¶
multislice
¶
Simulate multislice wave propagation using a classic split-step integrator (2nd order precision with respect to slice thickness if beam is optimized).
| PARAMETER | DESCRIPTION |
|---|---|
full_probe
|
Probe wavefunction with shape [N_batch, y,x, modes]
TYPE:
|
this_obj_chopped
|
Object slices with shape [N_batch, y,x, z, modes].
TYPE:
|
num_slices
|
Number of object slices.
TYPE:
|
n_obj_modes
|
Number of object modes.
TYPE:
|
n_probe_modes
|
Number of probe modes.
TYPE:
|
this_distances
|
Slice thicknesses.
TYPE:
|
this_wavelength
|
Electron wavelength.
TYPE:
|
q2
|
Spatial frequency grids.
TYPE:
|
qx
|
Spatial frequency grids.
TYPE:
|
qy
|
Spatial frequency grids.
TYPE:
|
exclude_mask
|
Mask to exclude undesired frequencies.
TYPE:
|
is_single_dist
|
If True, use the same distance for all slices.
TYPE:
|
this_tan_x
|
Beam tilts with shape N_batch
TYPE:
|
this_tan_y
|
Beam tilts with shape N_batch
TYPE:
|
damping_cutoff_multislice
|
Damping frequency cutoff.
TYPE:
|
smooth_rolloff
|
Rolloff rate for the damping filter.
TYPE:
|
master_propagator_phase_space
|
Full propagator in Fourier space (optional).
TYPE:
|
half_master_propagator_phase_space
|
Half-step propagator (optional).
TYPE:
|
mask_clean
|
Clean propagation mask.
TYPE:
|
waves_multislice
|
This array contains interediate exit-waves
TYPE:
|
wave
|
This array contains final exit-wave
TYPE:
|
default_float
|
Numerical types.
TYPE:
|
default_complex
|
Numerical types.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
waves_multislice
|
Multislice stack of propagated waves.
TYPE:
|
wave
|
Final exit wave.
TYPE:
|
multislice_grads
¶
Compute gradients for classic multislice propagation model (object, probe, and tilts).
| PARAMETER | DESCRIPTION |
|---|---|
dLoss_dP_out
|
Gradient of the loss with respect to the final propagated wave.
TYPE:
|
waves_multislice
|
Intermediate wave stack from the forward multislice pass.
TYPE:
|
this_obj_chopped
|
4D sliced object [batch, y, x, z, modes].
TYPE:
|
object_grad
|
Gradient accumulator for object slices.
TYPE:
|
tilts_grad
|
Accumulator for tilt gradients.
TYPE:
|
is_single_dist
|
If True, slice distances are constant.
TYPE:
|
this_distances
|
Per-slice thicknesses.
TYPE:
|
exclude_mask
|
Frequency mask for FFT operations.
TYPE:
|
this_wavelength
|
Probe wavelength (Å).
TYPE:
|
q2
|
Spatial frequency grids.
TYPE:
|
qx
|
Spatial frequency grids.
TYPE:
|
qy
|
Spatial frequency grids.
TYPE:
|
this_tan_x
|
Beam tilt values per batch.
TYPE:
|
this_tan_y
|
Beam tilt values per batch.
TYPE:
|
num_slices
|
Number of slices.
TYPE:
|
n_obj_modes
|
Number of object modes.
TYPE:
|
tiltind
|
Index in tilt update array.
TYPE:
|
master_propagator_phase_space
|
Full Fourier propagation kernel.
TYPE:
|
this_step_tilts
|
Whether tilt gradient is updated.
TYPE:
|
damping_cutoff_multislice
|
Damping cutoff for high-frequency noise.
TYPE:
|
smooth_rolloff
|
Width of damping transition.
TYPE:
|
tilt_mode
|
Mode selector for tilt optimization.
TYPE:
|
compute_batch
|
Current batch size.
TYPE:
|
mask_clean
|
FFT domain mask.
TYPE:
|
this_step_probe
|
Whether to compute probe gradient.
TYPE:
|
this_step_obj
|
Whether to compute object gradient.
TYPE:
|
this_step_pos_correction
|
(Unused) Flag for positional corrections.
TYPE:
|
masked_pixels_y
|
Indices for applying gradients to global object.
TYPE:
|
masked_pixels_x
|
Indices for applying gradients to global object.
TYPE:
|
default_float
|
Floating-point type.
TYPE:
|
default_complex
|
Complex type.
TYPE:
|
helper_flag_4
|
If True, return probe gradient; else return None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
object_grad
|
Gradient for object slices.
TYPE:
|
interm_probe_grad
|
Gradient for input probe (if helper_flag_4 is True).
TYPE:
|
tilts_grad
|
Updated tilt gradient.
TYPE:
|
scatteradd
¶
Adds batched object updates to their respective positions in the full object array. This wrapper is needed to support older CuPy versions.
| PARAMETER | DESCRIPTION |
|---|---|
full
|
Full object gradient array.
TYPE:
|
masky
|
Index array for the y-axis.
TYPE:
|
maskx
|
Index array for the x-axis.
TYPE:
|
chop
|
Batched gradients to scatter-add.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
|