Distances

The distance between two Atoms in a Crystal is central to many operations within Xtals.jl. The distance function calculates the Cartesian displacement between the Coords (Cart or Frac) of two points, i and j, within a given box.

xtal = Crystal("Co-MOF-74.cif")
distance(xtal.atoms.coords, xtal.box, 1, 2, false) # 23.2 Å

The apply_pbc argument allows for calculation of distances across the periodic boundaries of the box.

distance(xtal.atoms.coords, xtal.box, 1, 2, true) # 3.34 Å

distance also works on Atoms and Charges.

distance(xtal.atoms, xtal.box, 3, 5, true)

docs

Xtals.distanceFunction
r = distance(coords, box, i, j, apply_pbc)
r = distance(atoms, box, i, j, apply_pbc) # atoms i and j
r = distance(charges, box, i, j, apply_pbc) # charges i and j
r = distance(atoms, i, j) # no PBCs, coords must be in Cartesian coords
r = distance(coords, i, j) # no PBCs, coords must be in Cartesian coords

calculate the (Cartesian) distance between particles i and j.

apply periodic boundary conditions if and only if apply_pbc is true.

arguments

  • coords::Coords: the coordinates (Frac>:Coords or Cart>:Coords)
  • atoms::Atoms: atoms
  • charges::charges: atoms
  • box::Box: unit cell information
  • i::Int: index of the first particle
  • j::Int: Index of the second particle
  • apply_pbc::Bool: true if we wish to apply periodic boundary conditions, false otherwise
source