https://github.com/muexly/pbc_distance_calculator

https://github.com/muexly/pbc_distance_calculator

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.9%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: MUEXLY
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 35.2 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • Open Issues: 2
  • Releases: 0
Created about 2 years ago · Last pushed about 2 years ago
Metadata Files
Readme License

README.md

pbcdistancecalculator

This Python package computes pairwise distances in a simulation box accounting for periodic boundary conditions.

The only inputs are the positions of each particle and the simulation supercell matrix.

To install:

bash pip install pbc_distance_calculator

Example usage:

```python from numpy.typing import NDArray from pbcdistancecalculator import getpairwisedistances

array of shape (N, 3) where N is the number of particles

positions: NDArray = ...

array of shape (3, 3)

cell_matrix: NDArray = ...

array of shape (N, N)

element (i, j) is minimum image distance between i and j

pairwisedistances: NDArray = getpairwisedistances(positions, cellmatrix) ```

The above script performs the calculation in a vectorized form, computing every pairwise distance at once. To do it serially instead:

```python from numpy.typing import NDArray from pbcdistancecalculator import getpairwisedistance

arrays of shape (1, 3) or (3, 1)

firstposition: NDArray = ... secondposition: NDArray = ...

array of shape (3, 3)

cell_matrix: NDArray = ...

minimum image distance

pairwisedistance: float = getpairwisedistance( firstposition - secondposition, cellmatrix ) ```

In both functions, you can also specify different engines to compute the distances. This is especially advantageous for large systems, where you can specify jax.numpy or torch as an engine. For example:

```python import torch from pbcdistancecalculator import getpairwisedistances

...

torch.setdefaultdevice("cuda") pairwisedistances = getpairwisedistances( positions, cellmatrix, engine=torch ) ```

which will calculate the pairwise distances using the CUDA-backend of PyTorch. Note that the only engine installed by default is numpy, so make sure to separately install jax or torch if you want to use these modules.

Note that the cell matrix, is, in general:

$$ \begin{pmatrix} \mathbf{a} & \mathbf{b} & \mathbf{c} \end{pmatrix} $$

where $\mathbf{a}$, $\mathbf{b}$, and $\mathbf{c}$ are the lattice vectors of the supercell. Note that this definition works for any set of lattice parameters! So, no matter how weird your crystal, this package should work. If there are any problems, feel free to open an issue 🙂.

Owner

  • Name: MUEXLY
  • Login: MUEXLY
  • Kind: organization

GitHub Events

Total
  • Fork event: 1
Last Year
  • Fork event: 1

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 16 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 9
  • Total maintainers: 1
pypi.org: pbc-distance-calculator

A package for computing distances accounting for periodic boundary conditions

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 16 Last month
Rankings
Dependent packages count: 9.5%
Average: 36.2%
Dependent repos count: 62.8%
Maintainers (1)
Last synced: 10 months ago

Dependencies

.github/workflows/workflow.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • pypa/gh-action-pypi-publish release/v1 composite
requirements.txt pypi
  • numpy *
  • setuptools *
setup.py pypi