Examples
Representing Miller and Miller–Bravais indices
This section demonstrates how to create various indices using the package.
julia> using MillerIndices
julia> Miller(1, 2, 3) # Create Miller indices in real space
3-element MillerIndices.Miller: 1 2 3
julia> ReciprocalMiller(1, 2, 3) # Create Miller indices in reciprocal space
3-element MillerIndices.ReciprocalMiller: 1 2 3
julia> MillerBravais(2, -1, -1, 3) # Create Miller–Bravais indices in real space
4-element MillerIndices.MillerBravais: 2 -1 -1 3
julia> ReciprocalMillerBravais(1, 0, -1, 0) # Create Miller–Bravais indices in reciprocal space
4-element MillerIndices.ReciprocalMillerBravais: 1 0 -1 0
Generating indices from strings
Utilize the m_str
macro to rapidly generate indices from a string format.
julia> m"[-1, 0, 1]" # Generate Miller indices from a string
3-element MillerIndices.Miller: -1 0 1
julia> m"<2, -1, -1, 3>" # Generate Miller–Bravais indices from a string
4-element MillerIndices.MillerBravais: 2 -1 -1 3
Converting between Miller and Miller–Bravais indices
Switch between different index notations seamlessly.
julia> MillerBravais(Miller(-1, 0, 1))
4-element MillerIndices.MillerBravais: -2 1 1 3
julia> Miller(MillerBravais(-2, 1, 1, 3))
3-element MillerIndices.Miller: -1 0 1
Finding equivalent directions/planes
Discover how to determine all directions/planes equivalent to a given index by symmetry.
julia> familyof(Miller(-1, 0, 1))
6-element Vector{MillerIndices.Miller}: <-1 0 1> <0 -1 1> <1 1 1> <1 0 1> <0 1 1> <-1 -1 1>
julia> familyof(MillerBravais(-1, -1, 2, 3))
6-element Vector{MillerIndices.MillerBravais}: <-1 -1 2 3> <-1 2 -1 3> <2 -1 -1 3> <1 1 -2 3> <1 -2 1 3> <-2 1 1 3>
Angle calculation
Determine the angle between two vectors using a metric tensor.
Test the angle between $[1 2 1]$ and $[0 0 1]$ directions in gallium nitride:
using CrystallographyBase, Unitful a, c = 3.19u"angstrom", 5.19u"angstrom" g = MetricTensor(a, a, c, 90, 90, 120) θ = anglebtw(Miller(1, 0, 0), Miller(1, 1, 1), g)
The length of the reciprocal lattice vector and the interplanar spacing:
g = inv(MetricTensor(2, 4, 3, 90, 45, 90)) lengthof(ReciprocalMiller(1, 0, 2), g) interplanar_spacing(ReciprocalMiller(1, 0, 2), g)
Calculate the angle between two plane normals:
g = inv(MetricTensor(4, 6, 5, 90, 135, 90)) # Monoclinic 𝐱 = ReciprocalMiller(1, 0, 1) 𝐲 = ReciprocalMiller(-2, 0, 1) anglebtw(𝐱, 𝐲, g)