The Spatial Box
Within Xtals.jl
, the 3D space in which all Coords
are located is the Box
. Each Crystal
has its own Box
, equivalent to the unit cell of a material, containing as attributes the unit cell edge lengths (a
b
c
), crystallographic dihedral angles (α
β
γ
), volume, conversion factors for translating between Frac
tional and Cart
esian coordinates, and the reciprocal (Fourier transform) vectors for the Bravais lattice.
Defining a Box
A Box
is most conveniently constructed from its basic spatial data (a
b
c
α
β
γ
). For example, given the unit cell of Co-MOF-74, we can define its Box
:
a = 26.13173 # Å
b = 26.13173
c = 6.722028
α = π / 2 # radians
β = π / 2
γ = 2 * π / 3
box = Box(a, b, c, α, β, γ)
A Box
may also be defined by providing only the Frac
tional-to-Cart
esian conversion matrix:
box = Box([26.1317 -13.0659 0; 0 22.6307 0; 0 0 6.72203])
To quickly get a simple unit-cubic Box
, use the unit_cube
function.
@info unit_cube()
#┌ Info: Bravais unit cell of a crystal.
#│ Unit cell angles α = 90.000000 deg. β = 90.000000 deg. γ = 90.000000 deg.
#│ Unit cell dimensions a = 1.000000 Å. b = 1.000000 Å, c = 1.000000 Å
#└ Volume of unit cell: 1.000000 ų
Transforming Coordinates
Conversions are provided for switching between Frac
tional and Cart
esian Coords
using the Box
(works for Atoms
and Charges
, too).
xtal = Crystal("Co-MOF-74.cif")
Cart(xtal.atoms.coords, xtal.box)
#Cart([-5.496156112249995 7.181391379950001 … 15.131970232450003 2.4686645331000063;
# 22.270234304380295 2.8331425940892103 … 0.7607701110682343 22.13256395706254;
# 1.231811631 0.32198514120000005 … 6.2082409932000004 2.2119953472])
Replicating a Box
For simulations in larger volumes than a single crystallograhic unit cell, the Box
may be replicated along each or any of the three crystallographic axes. See replicate
.
replicated_box = replicate(box, (2, 2, 2))
Exporting a Box
For visualization of the unit cell boundaries, the Box
may be written out to a .vtk
file for use in Visit.
write_vtk(box, "box.vtk"; verbose=true)
Detailed Docs
Xtals.Box
— Typebox = Box(a, b, c, α, β, γ, volume, f_to_c, c_to_f, reciprocal_lattice)
box = Box(a, b, c, α, β, γ)
box = Box(a, b, c) # α=β=γ=π/2 assumed.
box = Box(f_to_c)
Data structure to describe a unit cell box (Bravais lattice) and convert between fractional and Cartesian coordinates.
Attributes
a,b,c::Float64
: unit cell dimensions (units: Angstroms)α,β,γ::Float64
: unit cell angles (units: radians)Ω::Float64
: volume of the unit cell (units: cubic Angtroms)f_to_c::Array{Float64,2}
: the 3x3 transformation matrix used to map fractional
coordinates to cartesian coordinates. The columns of this matrix define the unit cell axes. Columns are the vectors defining the unit cell box. units: Angstrom
c_to_f::Array{Float64,2}
: the 3x3 transformation matrix used to map Cartesian
coordinates to fractional coordinates. units: inverse Angstrom
reciprocal_lattice::Array{Float64, 2}
: the rows are the reciprocal lattice vectors.
This choice was made (instead of columns) for speed of Ewald Sums.
Xtals.unit_cube
— Functionuc = unit_cube()
This function generates a unit cube, each side is 1.0 Angstrom long, and all the corners are right angles.
Xtals.write_vtk
— Functionwrite_vtk(box, filename; verbose=true, center_at_origin=false)
write_vtk(crystal)
Write a Box
to a .vtk file for visualizing e.g. the unit cell boundary of a crystal. If a Crystal
is passed, the Box
of that crystal is written to a file that is the same as the crystal structure filename but with a .vtk extension.
Appends ".vtk" extension to filename
automatically if not passed.
Arguments
box::Box
: a Bravais latticefilename::AbstractString
: filename of the .vtk file output (absolute path)crystal::Crystal
: a crystal structure objectcenter_at_origin::Bool
: center box at origin if true. if false, the origin is the corner of the box.verbose::Bool
: if true, print the name of the written file to the console.