Skip to content

Repository files navigation

diffBloch

Coverage Python PyTorch NumPy Pydantic uv Ruff mypy License: MIT Docs

Differentiable Bloch-wave structure refinement for 3D electron diffraction.

📖 Documentation: https://diffbloch.com/ — Usage guide and API reference.

Quickstart

diffBloch is currently tagged as a release candidate and is under active development; v0.2.0 will be the first stable public release. Install uv, then:

uv tool install diffBloch

Installing using uv tool makes diffBloch available as a CLI command on the system, to get started try:

diffBloch --help

Running diffBloch requires an experiment directory consisting of .cif, .cif_pets and experiment.yml, take a look at the /examples directory with some easy to run sample experiments, and refer to the documentation on required inputs

If you plan on exploring diffBloch more thoroughly, using features that are under development and have not been published to pypi, or developing/contributing, we recommend working from a git checkout instead.

To run diffBloch locally using the git repo, copy and past this into your terminal:

git clone https://github.com/Differentiable-Electron-Crystallography/diffBloch.git
cd ./diffBloch
git lfs install
git lfs pull
uv sync --dev
uv run diffBloch --help

Installation covers installation beyond quickstart.

For Developers

We welcome collaborations and interested parties may contribute to the codebase.

Every merge to main re-runs the end to end (e2e) physics anchors. These correspond to rapid tests of the codebase's key functionalities and integration. Specifically, the measured mean R_obs for the example quartz refinement is expected to remain the same upon changes made to the directory. This Fig. tracks the result of this test upon every merge; the shaded band is the pinned tolerance. A flat line inside the band is the desired outcome, evidence the physics is reproducible commit over commit. Gaps are commits with no valid measurement (the committed checkpoint was stale for that commit's recipe, so the fast anchor could not score it).

Mean R_obs of the quartz e2e test for every merge to main

Citation

If you use diffBloch in your research, please cite it as:

Doherty, T., Malik, S., Colmey, B., Maitland, I. & Midgley, P. (2026). diffBloch, version 0.2.0. https://github.com/Differentiable-Electron-Crystallography/diffBloch

About

Differentiable Bloch wave simulations for electron diffraction refinement

Resources

Stars

26 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages