pbc_diff

sknano.core.crystallography.pbc_diff(fcoords1, fcoords2)[source] [edit on github][source]

Return the ‘fractional distance’ between two sets of fractional coordinates, accounting for periodic boundary conditions.

Modified implementation of pymatgen.util.coord_utils.pbc_diff

Parameters:fcoords2 (fcoords1,) – Fractional coordinates. Either a single coord or any array of coords.
Returns:fdiff – Array of difference in fractional coordinates fcoords1 - fcoords2, accounting for periodic boundary conditions. Each coordinate must have the property that abs(fc) <= 0.5.
Return type:ndarray

Examples

>>> from sknano.core.crystallography import pbc_diff
>>> fc1 = [0.1, 0.1, 0.1]; fc2 = [0.3, 0.5, 0.9];
>>> pbc_diff(fc1, fc2)
[-0.2, -0.4, 0.2]
>>> fc3 = [0.9, 0.1, 1.01]; fc4 = [0.3, 0.5, 0.9];
>>> pbc_diff(fc3, fc4)
[-0.4, -0.4, 0.11]