wulfric.crystal.shift_atoms#

wulfric.crystal.shift_atoms(atoms, gravity_point=(0.5, 0.5, 0.5), cell=None, gp_is_relative=True) None[source]#

Shifts all atoms with the same vector in a way that the gravity_point is located in the middle between minimum and maximum relative coordinates of the atoms, individually for each lattice vector.

I.e. if there is one atom in the cell, then it is placed in the center of the cell for gravity_point = (0.5, 0.5, 0.5).

Modifies given atoms dictionary.

Parameters:
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.

gravity_point(3,) array-like, default (0.5, 0.5, 0.5)

Relative coordinates of the gravity point.

cell(3, 3) array-like, optional

Matrix of a cell, rows are interpreted as vectors. Required if gp_is_relative = False.

gp_is_relativebool, default True

Whether the gravity_point is given in relative coordinates.

Examples

>>> import wulfric
>>> cell = [[2, 0, 0], [0, 2, 0], [0, 0, 2]]
>>> atoms = {
...     "names": ["Cr1", "Cr2"],
...     "positions": [[0.0, 0.0, 0.0], [0.5, 0.5, 1.0]],
... }
>>> wulfric.crystal.shift_atoms(atoms=atoms, gravity_point=(0.5, 0.5, 0.5))
>>> for i in range(len(atoms["names"])):
...     print(atoms["names"][i], atoms["positions"][i])
Cr1 [0.25 0.25 0.  ]
Cr2 [0.75 0.75 1.  ]
>>> wulfric.crystal.shift_atoms(
...     atoms, gravity_point=(1, 1, 1), cell=cell, gp_is_relative=False
... )
>>> for i in range(len(atoms["names"])):
...     print(atoms["names"][i], atoms["positions"][i])
Cr1 [0.25 0.25 0.  ]
Cr2 [0.75 0.75 1.  ]