Examples

Creating a Cell

To create a Cell, we first need to create a Lattice. There are multiple ways of doing it. For example, if we know the six lattice constants, we can do

julia> using CrystallographyBase, Unitful, UnitfulAtomic
julia> lattice₁ = Lattice(4u"nm", 180u"bohr", 3u"angstrom", 90, 90, 90)Lattice{Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}} 4.0e-9 m 0.0 m 0.0 m 0.0 m 9.525189796254e-9 m 0.0 m 0.0 m 0.0 m 3.0e-10 m

Or, equivalently,

julia> lattice₁ == Lattice([
           4u"nm" 0u"m" 0.0u"cm"
           0u"cm" 180.0u"bohr" 0u"m"
           0u"bohr" 0u"nm" (3//1)*u"angstrom"
       ])true

Then we can add atoms and their positions (in crystal coordinates):

julia> lattice₂ = [
           -3.0179389205999998 -3.0179389205999998 0.0000000000000000
           -5.2272235447000002 5.2272235447000002 0.0000000000000000
           0.0000000000000000 0.0000000000000000 -9.7736219469000005
       ]3×3 Matrix{Float64}:
 -3.01794  -3.01794   0.0
 -5.22722   5.22722   0.0
  0.0       0.0      -9.77362
julia> positions = [[2 / 3, 1 / 3, 1 / 4], [1 / 3, 2 / 3, 3 / 4]]2-element Vector{Vector{Float64}}: [0.6666666666666666, 0.3333333333333333, 0.25] [0.3333333333333333, 0.6666666666666666, 0.75]
julia> atoms = [1, 1]2-element Vector{Int64}: 1 1
julia> cell = Cell(lattice₂, positions, atoms)Cell{Float64, Float64, Int64} lattice: -3.0179389206 -3.0179389206 0.0 -5.2272235447 5.2272235447 0.0 0.0 0.0 -9.7736219469 2 atomic positions: 0.6666666666666666 0.3333333333333333 0.25 0.3333333333333333 0.6666666666666666 0.75 2 atoms: 1 1

Reciprocal space

To get the reciprocal lattice, we run reciprocal:

julia> reciprocal(lattice₁)ReciprocalLattice{Unitful.Quantity{Float64, 𝐋^-1, Unitful.FreeUnits{(m^-1,), 𝐋^-1, nothing}}}
 2.4999999999999997e8 m^-1  0.0 m^-1  0.0 m^-1
 0.0 m^-1  1.0498478470143168e8 m^-1  0.0 m^-1
 0.0 m^-1  0.0 m^-1  3.333333333333333e9 m^-1
Note

Never use ReciprocalLattice directly unless you know what you are doing!

Supercell generation

We can specify the replication factors in each direction in the following ways:

julia> super(lattice₁, [2, 3, 4])Lattice{Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}
 8.0e-9 m  0.0 m  0.0 m
 0.0 m  2.8575569388762e-8 m  0.0 m
 0.0 m  0.0 m  1.2e-9 m
julia> super(lattice₁, 3)Lattice{Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}} 1.2000000000000002e-8 m 0.0 m 0.0 m 0.0 m 2.8575569388762e-8 m 0.0 m 0.0 m 0.0 m 9.0e-10 m
julia> super(cell, [2, 3, 4])Cell{Float64, Float64, Int64} lattice: -6.0358778412 -9.0538167618 0.0 -10.4544470894 15.681670634100001 0.0 0.0 0.0 -39.0944877876 48 atomic positions: 0.3333333333333333 0.1111111111111111 0.0625 0.8333333333333333 0.1111111111111111 0.0625 0.3333333333333333 0.4444444444444444 0.0625 0.8333333333333333 0.4444444444444444 0.0625 0.3333333333333333 0.7777777777777778 0.0625 0.8333333333333333 0.7777777777777778 0.0625 0.3333333333333333 0.1111111111111111 0.3125 0.8333333333333333 0.1111111111111111 0.3125 0.3333333333333333 0.4444444444444444 0.3125 0.8333333333333333 0.4444444444444444 0.3125 0.3333333333333333 0.7777777777777778 0.3125 0.8333333333333333 0.7777777777777778 0.3125 0.3333333333333333 0.1111111111111111 0.5625 0.8333333333333333 0.1111111111111111 0.5625 0.3333333333333333 0.4444444444444444 0.5625 0.8333333333333333 0.4444444444444444 0.5625 0.3333333333333333 0.7777777777777778 0.5625 0.8333333333333333 0.7777777777777778 0.5625 0.3333333333333333 0.1111111111111111 0.8125 0.8333333333333333 0.1111111111111111 0.8125 0.3333333333333333 0.4444444444444444 0.8125 0.8333333333333333 0.4444444444444444 0.8125 0.3333333333333333 0.7777777777777778 0.8125 0.8333333333333333 0.7777777777777778 0.8125 0.16666666666666666 0.2222222222222222 0.1875 0.6666666666666666 0.2222222222222222 0.1875 0.16666666666666666 0.5555555555555555 0.1875 0.6666666666666666 0.5555555555555555 0.1875 0.16666666666666666 0.8888888888888888 0.1875 0.6666666666666666 0.8888888888888888 0.1875 0.16666666666666666 0.2222222222222222 0.4375 0.6666666666666666 0.2222222222222222 0.4375 0.16666666666666666 0.5555555555555555 0.4375 0.6666666666666666 0.5555555555555555 0.4375 0.16666666666666666 0.8888888888888888 0.4375 0.6666666666666666 0.8888888888888888 0.4375 0.16666666666666666 0.2222222222222222 0.6875 0.6666666666666666 0.2222222222222222 0.6875 0.16666666666666666 0.5555555555555555 0.6875 0.6666666666666666 0.5555555555555555 0.6875 0.16666666666666666 0.8888888888888888 0.6875 0.6666666666666666 0.8888888888888888 0.6875 0.16666666666666666 0.2222222222222222 0.9375 0.6666666666666666 0.2222222222222222 0.9375 0.16666666666666666 0.5555555555555555 0.9375 0.6666666666666666 0.5555555555555555 0.9375 0.16666666666666666 0.8888888888888888 0.9375 0.6666666666666666 0.8888888888888888 0.9375 48 atoms: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
julia> super(cell, 3)Cell{Float64, Float64, Int64} lattice: -9.0538167618 -9.0538167618 0.0 -15.681670634100001 15.681670634100001 0.0 0.0 0.0 -29.3208658407 54 atomic positions: 0.2222222222222222 0.1111111111111111 0.08333333333333333 0.5555555555555555 0.1111111111111111 0.08333333333333333 0.8888888888888888 0.1111111111111111 0.08333333333333333 0.2222222222222222 0.4444444444444444 0.08333333333333333 0.5555555555555555 0.4444444444444444 0.08333333333333333 0.8888888888888888 0.4444444444444444 0.08333333333333333 0.2222222222222222 0.7777777777777778 0.08333333333333333 0.5555555555555555 0.7777777777777778 0.08333333333333333 0.8888888888888888 0.7777777777777778 0.08333333333333333 0.2222222222222222 0.1111111111111111 0.4166666666666667 0.5555555555555555 0.1111111111111111 0.4166666666666667 0.8888888888888888 0.1111111111111111 0.4166666666666667 0.2222222222222222 0.4444444444444444 0.4166666666666667 0.5555555555555555 0.4444444444444444 0.4166666666666667 0.8888888888888888 0.4444444444444444 0.4166666666666667 0.2222222222222222 0.7777777777777778 0.4166666666666667 0.5555555555555555 0.7777777777777778 0.4166666666666667 0.8888888888888888 0.7777777777777778 0.4166666666666667 0.2222222222222222 0.1111111111111111 0.75 0.5555555555555555 0.1111111111111111 0.75 0.8888888888888888 0.1111111111111111 0.75 0.2222222222222222 0.4444444444444444 0.75 0.5555555555555555 0.4444444444444444 0.75 0.8888888888888888 0.4444444444444444 0.75 0.2222222222222222 0.7777777777777778 0.75 0.5555555555555555 0.7777777777777778 0.75 0.8888888888888888 0.7777777777777778 0.75 0.1111111111111111 0.2222222222222222 0.25 0.4444444444444444 0.2222222222222222 0.25 0.7777777777777778 0.2222222222222222 0.25 0.1111111111111111 0.5555555555555555 0.25 0.4444444444444444 0.5555555555555555 0.25 0.7777777777777778 0.5555555555555555 0.25 0.1111111111111111 0.8888888888888888 0.25 0.4444444444444444 0.8888888888888888 0.25 0.7777777777777778 0.8888888888888888 0.25 0.1111111111111111 0.2222222222222222 0.5833333333333334 0.4444444444444444 0.2222222222222222 0.5833333333333334 0.7777777777777778 0.2222222222222222 0.5833333333333334 0.1111111111111111 0.5555555555555555 0.5833333333333334 0.4444444444444444 0.5555555555555555 0.5833333333333334 0.7777777777777778 0.5555555555555555 0.5833333333333334 0.1111111111111111 0.8888888888888888 0.5833333333333334 0.4444444444444444 0.8888888888888888 0.5833333333333334 0.7777777777777778 0.8888888888888888 0.5833333333333334 0.1111111111111111 0.2222222222222222 0.9166666666666666 0.4444444444444444 0.2222222222222222 0.9166666666666666 0.7777777777777778 0.2222222222222222 0.9166666666666666 0.1111111111111111 0.5555555555555555 0.9166666666666666 0.4444444444444444 0.5555555555555555 0.9166666666666666 0.7777777777777778 0.5555555555555555 0.9166666666666666 0.1111111111111111 0.8888888888888888 0.9166666666666666 0.4444444444444444 0.8888888888888888 0.9166666666666666 0.7777777777777778 0.8888888888888888 0.9166666666666666 54 atoms: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

If only one integer is provided, it will be used in all three spatial directions.