wulfric.crystal.get_vector#

wulfric.crystal.get_vector(cell, atoms, atom1, atom2, R=(0, 0, 0), return_relative=False) ndarray[source]#

Computes a vector from atom1 (from (0,0,0)) to 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).

return_relativebool, default False

Whether to return vector relative to the cell.

Returns:
v(3,) numpy.ndarray

Vector from atom1 in (0,0,0) cell to 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]]}
>>> wulfric.crystal.get_vector(cell, atoms, atom1=0, atom2=1, R=(0, 0, 0))
array([-0.5,  0. ,  1.5])
>>> wulfric.crystal.get_vector(cell, atoms, atom1=0, atom2=1, R=(1, 0, 0))
array([0.5, 0. , 1.5])
>>> wulfric.crystal.get_vector(cell, atoms, atom1=0, atom2=1, R=(1, 0, -3))
array([ 0.5,  0. , -7.5])
>>> wulfric.crystal.get_vector(
...     cell, atoms, atom1=0, atom2=1, R=(1, 0, -3), return_relative=True
... )
array([ 0.5,  0. , -2.5])