Skip to main content

A Python module for orchestrating and dispatching large computations across multi-GPU systems using Vulkan.

Project description

VkTM2D

A 2D template matcher written using the vkdispatch library.

Installation

You can install the application using the command:

pip3 install .

Imaging model

The projected potential $v_z(x,y)$ is modeled in one of two ways. It can be calculated from a slice through the Fourier transform of a density map (3D volume) or from a set of (3D) atomic coordinates. In the former case, different orientations are obtained by extracting different slices through the Fourier transform, while in the latter they are obtained by rotating the atomic coordinates, projecting along the $\hat{\mathbf{z}}$ (electron beam propagation) axis, and finally convolving the resulting 2D histogram of coordinates with a gaussian blur. The normalization of the gaussian kernel is set to approximately match a more rigorous calculation of the atomic projected potential in units of VÅ (Kirkland 2020).

From the projected potential, the phase $\phi(x,y)=\sigma_ev_z(x,y)$ that is imparted to the exit wave function is calculated by scaling the projected potential by the interaction parameter $\sigma_e$, which for 300 kV accelerating voltage is approximately 0.652 mrad/VÅ. More generally, it is equal to $me\lambda_e/2\pi\hbar^2$, where $m$ is the electron mass, $e$ is the elementary charge, $\lambda_e$ is the wavelength of the electron, and $\hbar$ is the reduced Planck constant.

It is assumed that the projected potential $\phi$ is real and non-negative, with its 2D Fourier transform corresponding to the structure factor, denoted by $\Phi$:

    \Phi(s_x, s_y) = \mathcal{F}[\phi](s_x, s_y).

Here, the coordinates $(s_x, s_y)$ denote (non-angular) spatial frequency. A spatial frequency $\mathbf{s}=(s_x,s_y)$ intersects the back focal plane at the physical coordinate $(f_\mathrm{OL}\lambda_e s_x, f_\mathrm{OL}\lambda_e s_y)$, where $f_\mathrm{OL}$ is the effective focal length of the objective lens.

The calculation of an image from the projected potential requires a contrast transfer function (CTF), denoted $\mathcal{C}$. The key relationship that enables calculation of an image $\mathfrak{m}(x, y)$ from the structure factor $\Phi$ and the CTF $\mathcal{C}$ is

    \mathfrak{m}(x, y) \propto \mathcal{F}^{-1} [\Phi \cdot \mathcal{C}](x, y).

The CTF is assumed to have the form

    \mathcal{C}(\mathbf{s}) = E_\mathrm{TC}(\mathbf{s}) E_\mathrm{SC}(\mathbf{s}) E_\mathrm{JN}(\mathbf{s}) E_\mathrm{B}(\mathbf{s}) \sin[\chi(\mathbf{s}) - \chi(\mathbf{0}) - \kappa].

In the above, the terms $E_j$ are various envelope functions, $\chi$ is the wavefront aberration, and $\kappa$ is the amplitude contrast, taken to be a small constant such as 0.07.

The temporal coherence envelope function is given by

    E_\mathrm{TC}(\mathbf{s}) = \exp \left(-\frac{1}{2}\sigma_f^2\pi^2\lambda_e ^2|\mathbf{s}|^4\right)

where $\sigma_f$ is the "defocus spread," which is given by

    \sigma_f = C_c\sqrt{ \left(\epsilon \frac{\sigma_{V_0}}{V_0}\right)^2 +  \left(\epsilon \frac{\sigma_{E_0}}{E_0}\right)^2 + \left(2\frac{\sigma_{I_0}}{I_0}\right)^2}

where $\Delta E_0 = 2\sqrt{2\ln 2}\sigma_{E_0}$ is the "energy spread" (typically quoted in FWHM, as opposed to the standard deviation $\sigma_{E_0}$), $C_c$ is the chromatic aberration coefficient, and $E_0$ is the electron energy. Relevant also are the objective lens current fluctuation $\sigma_{I_0}/I_0$ and accelerating voltage fluctation $\sigma_{V_0}/V_0$, which respectively have typical values of 0.1 ppm and 0.07 ppm. All the terms of the $\sigma_j$ denote standard deviations. The parameter $\epsilon$ is a relativistic correction factor given by

    \epsilon = \frac{1 + \frac{E_0}{511 \text{ keV}}}{1 + \frac{E_0}{2\cdot 511 \text{ keV}}}

which is approximately 1.227 at 300 keV.

The spatial coherence envelope is given by

    E_\mathrm{SC}(\mathbf{s}) = \exp\left[-2\sigma_\beta^2\pi^2|\mathbf{s}|^2\left( C_s\lambda_e ^2|\mathbf{s}|^2 - f_0 \right)^2 \right],

in which $C_s$ is the spherical aberration coefficient, $f_0$ is the mean defocus value, and $\sigma_\beta$ is the standard deviation of the distribution of beam angles (assumed to be gaussian, with a typical value of ~2.5 microradian) emerging from the gun.

The Johnson noise envelope is a gaussian envelope due to thermal magnetic field noise in the microscope column, with an associated variance $\sigma_\mathrm{J}^2$. This term is incorporated due to its potentially non-negligible values when using microscopes with relay optics (Axelrod et al., Ultramicroscopy 2023). The functional form of this envelope is

    E_\mathrm{JN}(\mathbf{s}) = \exp \left( -2\pi^2\sigma_J^2 |\mathbf{s}|^2 \right).

A generic B-factor envelope is added for convenience. It has the functional form

    E_\mathrm{B}(\mathbf{s}) = \exp\left(-\frac{1}{4}B|\mathbf{s}|^2\right).

The wavefront aberration is given by

    \chi(\mathbf{s}) = \frac{2\pi}{\lambda_e}\left( \frac{1}{4}C_s\lambda_e^4|\mathbf{s}|^4 - \frac{1}{2}f_0\lambda_e^2|\mathbf{s}|^2 \right) + \eta(\mathbf{s}),

where $f_0>0$ denotes underfocus. The term $\eta(\mathbf{s})$ is the phase shift due to a phase plate. For instance, an ideal Zernike phase plate imparts the phase shift

    \eta(\mathbf{s}) = \frac{\pi}{2}\delta(\mathbf{s})

where $\delta(\mathbf{s})$ is the Dirac delta function.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tm2d-0.1.1.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tm2d-0.1.1-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file tm2d-0.1.1.tar.gz.

File metadata

  • Download URL: tm2d-0.1.1.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tm2d-0.1.1.tar.gz
Algorithm Hash digest
SHA256 69c4834b0f7a6ead085da9053ca86495877f94205f45572f8478e7669dd51327
MD5 a9bbca2104af99420708ad1c1cdc3167
BLAKE2b-256 2e0f1f8849ed6d00e99788bdf89d8329b1171de8faecbd87d6e4aba6ec8e0fe0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tm2d-0.1.1.tar.gz:

Publisher: python-publish.yml on sharhar/tm2d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tm2d-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tm2d-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 32.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tm2d-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2131f975e186cbbebb219ae4cf810884d9751d51adbdc821c490cf999f7c243b
MD5 6c32a8cccfc7c922d29699092406f5f7
BLAKE2b-256 afcb6bd9670d1e5d15b0aa13e1f9fb6c126c59cd8ac8ac72aa6a704da6b0373f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tm2d-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on sharhar/tm2d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page