Metadata-Version: 2.5
Name: diffBloch
Version: 0.2.0rc1
Summary: Differentiable Bloch-wave electron-diffraction structure refinement
Project-URL: Homepage, https://diffBloch.com
Project-URL: Documentation, https://differentiable-electron-crystallography.github.io/diffBloch/
Project-URL: Source, https://github.com/Differentiable-Electron-Crystallography/diffBloch
Project-URL: Issues, https://github.com/Differentiable-Electron-Crystallography/diffBloch/issues
Author-email: Tiarnan Doherty <Td404@cam.ac.uk>, Shreshth Malik <shreshth_malik@yahoo.co.uk>, Benjamin Colmey <benjamincolmey@gmail.com>, Iain Maitland <iain@iainmaitland.com>
License-Expression: MIT
License-File: LICENSE
Keywords: automatic-differentiation,bloch-wave,crystallography,electron-crystallography,electron-diffraction,pytorch,structure-refinement
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Chemistry
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: diffpy-structure>=3.2
Requires-Dist: gemmi>=0.7.5
Requires-Dist: matplotlib>=3.7
Requires-Dist: numpy>=2.5.2
Requires-Dist: pydantic>=2.7
Requires-Dist: pyyaml>=6.0
Requires-Dist: scipy>=1.11
Requires-Dist: torch>=2.13.0
Provides-Extra: comet
Requires-Dist: comet-ml>=3.58.4; extra == 'comet'
Provides-Extra: wandb
Requires-Dist: wandb>=0.28.2; extra == 'wandb'
Description-Content-Type: text/markdown

# diffBloch

![Coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fdifferentiable-electron-crystallography.github.io%2FdiffBloch%2Fcoverage-endpoint.json)
![Python](https://img.shields.io/badge/Python-3.12%2B-3776AB?logo=python&logoColor=white)
![PyTorch](https://img.shields.io/badge/PyTorch-EE4C2C?logo=pytorch&logoColor=white)
![NumPy](https://img.shields.io/badge/NumPy-013243?logo=numpy&logoColor=white)
![Pydantic](https://img.shields.io/badge/Pydantic-E92063?logo=pydantic&logoColor=white)
![uv](https://img.shields.io/badge/uv-DE5FE9?logo=uv&logoColor=white)
![Ruff](https://img.shields.io/badge/Ruff-D7FF64?logo=ruff&logoColor=black)
![mypy](https://img.shields.io/badge/mypy-strict-blue)
[![License: MIT](https://img.shields.io/badge/License-MIT-97ca00)](LICENSE)
[![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-0969da?logo=sphinx&logoColor=white)](https://diffbloch.com/)

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


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

## Quickstart

Prerequisite: install [uv](https://docs.astral.sh/uv/getting-started/installation/) and
[Git LFS](https://git-lfs.com/) for the bundled `.cif_pets` experimental data and plan-checkpoint `.npz`
checkpoints, then sync the project environment from the repository root:

```bash
git lfs install
git lfs pull
uv sync --dev
```

Run CLI commands through `uv run` unless you have separately installed the `diffbloch` console script
on your shell `PATH`.

```bash
# Run the optimizer and update trainable structural parameters:
uv run diffbloch run refine examples/Colmey_et_al_2026/data/quartz-no-abs
```

## 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).

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://differentiable-electron-crystallography.github.io/diffBloch/anchor-trend-dark.svg">
  <img alt="Mean R_obs of the quartz e2e test for every merge to main" src="https://differentiable-electron-crystallography.github.io/diffBloch/anchor-trend.svg">
</picture>

## 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
