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
, in units of Å.
xtal = Crystal("IRMOF-1.cif")
distance(xtal.atoms.coords, xtal.box, 1, 2, false)
# output
18.538930020700434
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)
# output
15.096469110488975
distance
also works on Atoms
and Charges
.
distance(xtal.atoms, xtal.box, 3, 5, true)
# output
16.90555095103936
Detailed 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