wulfric.crystal.get_distance#

wulfric.crystal.get_distance(cell, atoms, atom1, atom2, R=(0, 0, 0)) float[source]#

Computes distance between atom1 (from (0,0,0)) and atom2 (from (i,j,k)).

Parameters:
cell(3, 3) array-like,

Matrix of a cell, rows are interpreted as vectors.

atomsdict

Dictionary with N atoms. Expected keys:

  • "positions" : (N, 3) array-like Positions of the atoms in the basis of lattice vectors (cell). In other words - relative coordinates of atoms.

atom1int

Index of the first atom in atoms["positions"].

atom2int

Index of the second atom in atoms["positions"].

R(3,) tuple of int, default (0, 0, 0)

Radius vector of the unit cell for atom2 (i,j,k).

Returns:
distancefloat

Distance between atom1 in (0,0,0) cell and atom2 in R cell.

Examples

>>> import wulfric
>>> cell = [[1, 0, 0], [0, 2, 0], [0, 0, 3]]
>>> atoms = {"positions": [[0.5, 0, 0], [0, 0, 0.5]]}
>>> round(
...     wulfric.crystal.get_distance(
...         cell, atoms, atom1=0, atom2=1, R=(0, 0, 0)
...     ),
...     8,
... )
1.58113883
>>> round(
...     wulfric.crystal.get_distance(
...         cell, atoms, atom1=0, atom2=1, R=(1, 0, 0)
...     ),
...     8,
... )
1.58113883
>>> round(
...     wulfric.crystal.get_distance(
...         cell, atoms, atom1=0, atom2=1, R=(1, 0, -3)
...     ),
...     8,
... )
7.51664819