Skip to main content

site-analysis

Build Status Documentation Status PyPI version DOI status

site-analysis is a Python module for analysing molecular dynamics simulations of solid-state ion transport, by assigning positions of mobile ions to specific “sites” within the host structure.

The code uses pymatgen Structure objects as its input format for MD trajectories. Any trajectory source that can produce pymatgen structures can be used as input.

The code can use the following definitions for assigning mobile ions to sites:

  1. Spherical cutoff: Atoms occupy a site if they lie within a spherical cutoff from a fixed position.
  2. Voronoi decomposition: Atoms are assigned to sites based on a Voronoi decomposition of the lattice into discrete volumes.
  3. Polyhedral decomposition: Atoms are assigned to sites based on occupation of polyhedra defined by the instantaneous positions of lattice atoms.
  4. Dynamic Voronoi sites: Sites using Voronoi decomposition but with centres calculated dynamically based on framework atom positions.

Quick Start

from site_analysis.builders import TrajectoryBuilder
from pymatgen.io.vasp import Xdatcar

# Load MD trajectory as a list of pymatgen Structure objects.
# Here we load from a VASP XDATCAR file, but any source of
# pymatgen Structure objects can be used as input.
xdatcar = Xdatcar("example_data/XDATCAR")
md_structures = xdatcar.structures

# Define sites and track Li+ ion movements between them
trajectory = (TrajectoryBuilder()
              .with_structure(md_structures[0])  # Use first frame as reference
              .with_mobile_species("Li")
              .with_spherical_sites(centres=[[0.25, 0.25, 0.25],
                                             [0.75, 0.25, 0.25]],
                                    radii=1.5)
              .build())

trajectory.trajectory_from_structures(md_structures)

# Get site occupancies over time
print(trajectory.atoms_trajectory)  # Which site each atom occupies
print(trajectory.sites_trajectory)  # Which atoms in each site

For detailed examples and tutorials, see the documentation.

Executable Jupyter notebook tutorials are available in the tutorials/ directory. These are not included when installing via pip — to run them locally, clone the repository:

git clone https://github.com/bjmorgan/site-analysis.git
cd site-analysis/tutorials
jupyter notebook

Installation

Standard Installation

pip install site-analysis

For faster polyhedral site analysis, install with numba acceleration:

pip install site-analysis[fast]

Development Installation

For development or to access the latest features:

# Clone the repository
git clone https://github.com/bjmorgan/site-analysis.git
cd site-analysis

# Install in development mode with dev dependencies
pip install -e ".[dev]"

Documentation

Complete documentation, including tutorials, examples, and API reference, is available at Read the Docs.

Testing

Automated testing of the latest build happens on GitHub Actions.

To run tests locally:

# Using pytest (recommended)
pytest

# Using unittest
python -m unittest discover

The code requires Python 3.12 or above.

Contributing

Bug reports, feature requests, and pull requests are welcome. See CONTRIBUTING.md for guidelines.

Citation

If you use site-analysis in your research, please cite the paper published in the Journal of Open Source Software:

@article{Morgan2026,
  doi = {10.21105/joss.09606},
  url = {https://doi.org/10.21105/joss.09606},
  year = {2026},
  publisher = {The Open Journal},
  volume = {11},
  number = {122},
  pages = {9606},
  author = {Benjamin J. Morgan},
  title = {site-analysis: A Python package for site-projection analysis of molecular dynamics trajectories},
  journal = {Journal of Open Source Software}
}

To cite the specific version of the software you used, please also cite its release on Zenodo, where each version has its own DOI.

Metadata

Release files for site-analysis 1.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for site-analysis 1.9.0
File Size Uploaded Provenance
site_analysis-1.9.0.tar.gz 133.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for site-analysis 1.9.0
File Interpreter ABI Platform
site_analysis-1.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 211.5 kB

Release files / site_analysis-1.9.0.tar.gz

Download URL site_analysis-1.9.0.tar.gz
Size 133.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d55bb6dc3bda74ded50b71c4e55680023f49323c4cd33c0607f257cbb73f6108
BLAKE2b-256 checksum
How to use checksums
ca496261cea63a3cf10b435bb0bb311359696f3ee572b4f3742ae4e9006c9071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / site_analysis-1.9.0-py3-none-any.whl

Download URL site_analysis-1.9.0-py3-none-any.whl
Size 78.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
393db6bc5b56c6fb27ff1cd2d024c750d3bad72f57cd7cda02272f940fe09659
BLAKE2b-256 checksum
How to use checksums
a46277851a94c1352dbf6c7c9381599330bda1aac905e86497ea4434dbfaa0a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Security for site-analysis 1.9.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 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for site_analysis-1.9.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 Oct 5, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page