crystal_torture:
crystal_torture is a Python, Fortran and OpenMP crystal structure analysis module. The module contains a set of classes that enable:
- a crystal structure to be converted into a graph for network analysis.
- connected clusters of crystal sites (nodes) to be retrieved and output.
- periodicity of connected clusters of crystal sites to be determined.
- relative path tortuosity to traverse a crystal within a connected cluster to be calculated for each site.
Ionic diffusion through crystalline solids depends not only on the dynamics of ions within the crystal, but also the connectivity of the transport network. Understanding how the connectivity of diffusion pathways in crystal structures is affected by changes in chemistry is necessary for understanding how chemical modifications change ionic conductivities, for example the doping of solid electrolytes.
crystal-torture provides a Python API for interrogating network connectivity and diffusion pathways in partially blocked crystal structures. It can be used as a tool for materials scientists to quickly build up network connectivity statistics in order to determine the viability of potential ionic conductors, and how chemical modification affects network connectivity, before the use of more computationally expensive approaches modelling the full dynamics.
Features
- Fast Performance: Fortran extensions with OpenMP parallelisation for computationally intensive operations
- Fallback Support: Pure Python implementations available when Fortran extensions unavailable
- Modern Build System: Uses meson-python for reliable cross-platform builds
- Comprehensive Testing: Extensive test suite covering both Fortran and Python code paths
- Type Hints: Modern Python with type annotations for better development experience
Installation
crystal_torture requires Python 3.10 or above.
From PyPI (Recommended)
For most users, installation from PyPI will provide pre-compiled packages:
pip install crystal-torture
From Source
Building from source enables Fortran extensions for optimal performance. This requires a Fortran compiler and build tools:
System Dependencies
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install gfortran build-essential
macOS (with Homebrew):
brew install gfortran
Windows: Install a Fortran compiler such as MinGW-w64 or use Windows Subsystem for Linux.
Installation
git clone https://github.com/connorourke/crystal_torture
cd crystal_torture
pip install . --use-pep517
Development Installation
git clone https://github.com/connorourke/crystal_torture
cd crystal_torture
pip install ."[dev]" --use-pep517
Fortran Extensions
Performance Note: The Fortran extensions provide significant performance improvements for large systems. If Fortran compilation fails, some functions will fall back to Python implementations, while others (like torture_fort()) will require using the Python equivalent (torture_py()).
To verify Fortran extensions loaded successfully:
from crystal_torture import tort, dist
print(f"Fortran tort available: {tort.tort_mod is not None}")
print(f"Fortran dist available: {dist._DIST_AVAILABLE}")
Quick Start
from crystal_torture.pymatgen_interface import graph_from_file
# Load structure and create graph
graph = graph_from_file("my_structure.cif", rcut=4.0, elements={"Li"})
# Analyse tortuosity (uses Fortran if available)
graph.torture() # or graph.torture_py() for pure Python
# Get results
percolating_fraction = graph.return_frac_percolating()
for cluster in graph.minimal_clusters:
print(f"Cluster size: {cluster.size}, Tortuosity: {cluster.tortuosity}")
Tests
crystal_torture is automatically tested on each commit via GitHub Actions across Python 3.10-3.13, but tests can be run manually:
# Run all tests
pytest
# Run with coverage
pytest --cov=crystal_torture
# Run specific test file
pytest tests/test_node.py -v
Examples
Examples on how to use crystal_torture can be found in a Jupyter notebook in the examples directory crystal_torture_examples.ipynb
Documentation
Documentation can be found here
Dependencies
Runtime Dependencies
numpy>=1.19.0pymatgen>=2022.0.0
Build Dependencies (for source installation)
meson-python>=0.12.0gfortran(Fortran compiler)ninja(build tool)- OpenMP (optional, for parallelisation)
Development Dependencies
pytest>=6.0pytest-covcoverageddt
Performance
The Fortran extensions with OpenMP provide substantial performance improvements over pure Python implementations, particularly for large crystal structures with many atoms.
Contributing
Bug Reports and Feature Requests
If you think you have found a bug, please report it on the Issue Tracker. This is also the place to propose ideas for new features or ask questions about the design of crystal_torture. Poor documentation is considered a bug, but please be as specific as possible when asking for improvements.
Code Contributions
We welcome your help in improving and extending the package with your own contributions. This is managed through GitHub pull requests; for external contributions we prefer the "fork and pull" workflow, while core developers use branches in the main repository:
- First open an Issue to discuss the proposed contribution. This discussion might include how the changes fit crystal_torture's scope and a general technical approach.
- Make your own project fork and implement the changes there. Please keep your code style compliant with PEP8.
- Add or update tests for your changes.
- Open a pull request to merge the changes into the main project. A more detailed discussion can take place there before the changes are accepted.
Development Setup
git clone https://github.com/connorourke/crystal_torture
cd crystal_torture
pip install ."[dev]" --use-pep517
pytest # Run tests to verify installation
Citation
If you use crystal_torture in your research, please cite:
@article{ORourke2019,
title = {crystal-torture: A crystal tortuosity module},
volume = {4},
ISSN = {2475-9066},
url = {http://dx.doi.org/10.21105/joss.01306},
DOI = {10.21105/joss.01306},
number = {38},
journal = {Journal of Open Source Software},
publisher = {The Open Journal},
author = {O'Rourke, Conn and Morgan, Benjamin},
year = {2019},
month = jun,
pages = {1306}
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Version
Current version: 1.2.0
Changelog
- v1.2.0: Modern meson-python build system, improved Fortran integration, Python 3.10+ support
- v1.1.x: Previous stable releases with setuptools build system
Metadata
Release files for crystal-torture 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| crystal_torture-1.2.0.tar.gz | 7.4 MB | With provenance | Details for crystal_torture-1.2.0.tar.gz |
Built distributions (wheels)
Total release size: 18.7 MB
Release files / crystal_torture-1.2.0.tar.gz
| Download URL | crystal_torture-1.2.0.tar.gz |
|---|---|
| Size | 7.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8469e53ba2f610a4a95a4c0e6ec711012d2801972db3af8d283fe7595a8a7382
|
|
BLAKE2b-256 checksum How to use checksums |
5493f6a5566fc4321736ca470aba170f09bae1c82f036f0e0e682a81df9a28d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | crystal_torture-1.2.0-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
75f9d0680ec4f7e21eff54c3c67ac7b03f0a515cd2a16a3389bdac5315a0c8f2
|
|
BLAKE2b-256 checksum How to use checksums |
b3eb9f1a1965dffc0da058319a627ff9e6a422fa84cbd29d76e22adc8baaa46b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | crystal_torture-1.2.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 947.0 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3fe8b3773c7603f7415571f630de994ab363e5934f0367c34a40712cfacd76f9
|
|
BLAKE2b-256 checksum How to use checksums |
81bdd9236338643089558e68681b1e397ca7a30033585aa32ca989e5f7d98f4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp312-cp312-macosx_10_9_x86_64.whl
| Download URL | crystal_torture-1.2.0-cp312-cp312-macosx_10_9_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.12 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
9b24bba8ea630fe0eff00caf43f5927647e96ec379d39c760508652675719d26
|
|
BLAKE2b-256 checksum How to use checksums |
73fb3b28acc1f9a1848cceec61b38490aad2468aa91fbf8c6b9b588c5da1ae4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | crystal_torture-1.2.0-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
724148a425cf03a211c9772144aa3b5a776fcf1e6c1cd9360d08ea6c1dc6a0d8
|
|
BLAKE2b-256 checksum How to use checksums |
08b2fd865a54134130732da04ee520d45f92df6c94d08b60bbb3343f75e3d927
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | crystal_torture-1.2.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 947.0 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f811133ab8ebaa1e12527b22496de6466415c4732cdd1fb568fea325fecf1090
|
|
BLAKE2b-256 checksum How to use checksums |
26f6acf21ca97ebdb274c1722e8f5bb31d0be8b261d639584e68e7eece37f3a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | crystal_torture-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
1a7cfe8935e3b2a34c933a1208ec7dfcbdeab21cb85447a50cbc3d7942e2c921
|
|
BLAKE2b-256 checksum How to use checksums |
cd85172193c504e8eda099e669e96bf1db144a5790d9b7e41726d99a133cad5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | crystal_torture-1.2.0-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6757fea38836645714e8626d0fecb8ea7e7d28284674ce21cc8f073c583f26a3
|
|
BLAKE2b-256 checksum How to use checksums |
b4824ed3630f7fe8b6afb324b7d1fe2edbc78ff32251bad8fd50c3130dd6e5d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | crystal_torture-1.2.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 947.0 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3524b72e9a4a44fb347e5535256bfece01a79c494d487aa9e3d992fb2ae3a811
|
|
BLAKE2b-256 checksum How to use checksums |
989c5feefb65ab514e66b9cb14c04e5a3acecca8ce1d1cfd5c78be4ae7f7869d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logRelease files / crystal_torture-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | crystal_torture-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
5a4122a838a67fc1f1433e84d95ef994133ef0fa8c087f43d98bb563fc86c9df
|
|
BLAKE2b-256 checksum How to use checksums |
9af4b26c5c62e7ef94ad418d3ebf8cc3b31ca4fd23b1f811902ab9cae3b39506
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logSecurity for crystal-torture 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 10 files in this release have been uploaded with provenance metadata.
Attestation for crystal_torture-1.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.