Distances
The distance between two Atoms
in a Crystal
is central to many operations within Xtals.jl
. The distance
function calculates the Cart
esian 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.distance
— Functionr = 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
orCart>:Coords
)atoms::Atoms
: atomscharges::charges
: atomsbox::Box
: unit cell informationi::Int
: index of the first particlej::Int
: Index of the second particleapply_pbc::Bool
:true
if we wish to apply periodic boundary conditions,false
otherwise