Lattice

Index

Documentation

CrystalBase.cart_to_fracFunction
cart_to_frac(lattice, vec)
cart_to_frac(lattice, vecs)

Convert Cartesian to fractional coordinates based on lattice vectors.

Arguments

  • lattice: lattice vectors.
    • For lattice vectors, the unit is usually in angstrom.
    • For reciprocal lattice vectors, the unit is usually in 1/angstrom.
  • vec: a vector or a list of vectors in Cartesian coordinates.

Examples

lattice = [[0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]];
positions = [[2.1, 1.9, 1.0], [21.0, 19.0, 10.0]];
frac_to_cart(lattice, cart_to_frac(lattice, positions[1])) ≈ positions[1]
# output
true
frac_to_cart(lattice, cart_to_frac(lattice, positions)) ≈ positions
# output
true
source
CrystalBase.frac_to_cartFunction
frac_to_cart(lattice, vec)
frac_to_cart(lattice, vecs)

Convert fractional to Cartesian coordinates based on lattice vectors.

Arguments

  • lattice: lattice vectors.
    • For lattice vectors, the unit is usually in angstrom.
    • For reciprocal lattice vectors, the unit is usually in 1/angstrom.
  • vec: a vector or a list of vectors in fractional coordinates.

Examples

lattice = [[0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]];
positions = [[0.1, 0.2, 0.3], [1.0, 2.0, 3.0]];
frac_to_cart(lattice, positions[1])
# output
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
 2.1
 1.9
 1.0
frac_to_cart(lattice, positions)
# output
2-element Vector{StaticArraysCore.SVector{3, Float64}}:
 [2.1, 1.9, 1.0]
 [21.0, 19.0, 10.0]
source
CrystalBase.lattice_vectorsMethod
lattice_vectors(lattice)

Return (real or reciprocal) lattice vectors from Mat3 matrix columns.

Examples

lattice = mat3([0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]);
lattice_vectors(lattice)
# output
3-element Vector{StaticArraysCore.SVector{3, Float64}}:
 [0.0, 1.0, 2.0]
 [3.0, 0.0, 4.0]
 [5.0, 6.0, 0.0]
source
CrystalBase.real_latticeMethod
real_lattice(recip_lattice)

Compute real-space lattice vectors from reciprocal lattice vectors.

Arguments

Reciprocal lattice vectors, can be

  • a matrix (each column is a reciprocal lattice vector)
  • a vector of reciprocal lattice vectors
  • or anything mat3 accepts

Returns

Real-space lattice vectors as Mat3 matrix.

Examples

b1, b2, b3 = [0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]
real_lattice(b1, b2, b3)
# output
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 -2.69279   1.3464     0.448799
  2.24399  -1.122      0.673198
  2.0196    0.560999  -0.336599
recip_lattice = [b1, b2, b3];
real_lattice(recip_lattice)
# output
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 -2.69279   1.3464     0.448799
  2.24399  -1.122      0.673198
  2.0196    0.560999  -0.336599
recip_lattice = mat3(b1, b2, b3);
real_lattice(recip_lattice)
# output
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 -2.69279   1.3464     0.448799
  2.24399  -1.122      0.673198
  2.0196    0.560999  -0.336599
reciprocal_lattice(real_lattice(recip_lattice)) ≈ recip_lattice
# output
true
source
CrystalBase.real_lattice_vectorsMethod
real_lattice_vectors(lattice)
real_lattice_vectors(a1, a2, a3)

Return real-space lattice vectors from reciprocal lattice.

This returns vectors instead of Mat3 matrix (see real_lattice for that).

Arguments

Reciprocal lattice vectors, can be

  • a matrix (each column is a reciprocal lattice vector)
  • a vector of reciprocal lattice vectors
  • or anything mat3 accepts

Examples

b1, b2, b3 = [0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]
real_lattice_vectors(b1, b2, b3)
# output
3-element Vector{StaticArraysCore.SVector{3, Float64}}:
 [-2.6927937030769655, 2.243994752564138, 2.019595277307724]
 [1.3463968515384828, -1.1219973762820687, 0.5609986881410344]
 [0.4487989505128276, 0.6731984257692414, -0.3365992128846207]
lattice = [b1, b2, b3];
real_lattice_vectors(lattice)
# output
3-element Vector{StaticArraysCore.SVector{3, Float64}}:
 [-2.6927937030769655, 2.243994752564138, 2.019595277307724]
 [1.3463968515384828, -1.1219973762820687, 0.5609986881410344]
 [0.4487989505128276, 0.6731984257692414, -0.3365992128846207]
lattice = mat3(b1, b2, b3);
real_lattice_vectors(lattice)
# output
3-element Vector{StaticArraysCore.SVector{3, Float64}}:
 [-2.6927937030769655, 2.243994752564138, 2.019595277307724]
 [1.3463968515384828, -1.1219973762820687, 0.5609986881410344]
 [0.4487989505128276, 0.6731984257692414, -0.3365992128846207]
source
CrystalBase.reciprocal_latticeFunction
reciprocal_lattice(lattice)
reciprocal_lattice([a1, a2, a3])
reciprocal_lattice(a1, a2, a3)

Compute reciprocal lattice vectors from lattice vectors.

Arguments

lattice vectors, can be

  • a matrix (each column is a lattice vector)
  • a vector of lattice vectors
  • or anything mat3 accepts

Returns

Reciprocal lattice vectors as Mat3 matrix.

Examples

a1, a2, a3 = [0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0];
reciprocal_lattice(a1, a2, a3)
# output
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 -2.69279   1.3464     0.448799
  2.24399  -1.122      0.673198
  2.0196    0.560999  -0.336599
lattice = [a1, a2, a3];
reciprocal_lattice(lattice)
# output
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 -2.69279   1.3464     0.448799
  2.24399  -1.122      0.673198
  2.0196    0.560999  -0.336599
lattice = mat3(a1, a2, a3);
reciprocal_lattice(lattice)
# output
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 -2.69279   1.3464     0.448799
  2.24399  -1.122      0.673198
  2.0196    0.560999  -0.336599
source
CrystalBase.reciprocal_lattice_vectorsMethod
reciprocal_lattice_vectors(lattice)
reciprocal_lattice_vectors(a1, a2, a3)

Return reciprocal lattice vectors from real lattice.

This returns vectors instead of Mat3 matrix (see reciprocal_lattice for that).

Arguments

lattice vectors, can be

  • a matrix (each column is a lattice vector)
  • a vector of lattice vectors
  • or anything mat3 accepts

Examples

a1, a2, a3 = [0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0];
reciprocal_lattice_vectors(a1, a2, a3)
# output
3-element Vector{StaticArraysCore.SVector{3, Float64}}:
 [-2.6927937030769655, 2.243994752564138, 2.019595277307724]
 [1.3463968515384828, -1.1219973762820687, 0.5609986881410344]
 [0.4487989505128276, 0.6731984257692414, -0.3365992128846207]
lattice = [a1, a2, a3];
reciprocal_lattice_vectors(lattice)
# output
3-element Vector{StaticArraysCore.SVector{3, Float64}}:
 [-2.6927937030769655, 2.243994752564138, 2.019595277307724]
 [1.3463968515384828, -1.1219973762820687, 0.5609986881410344]
 [0.4487989505128276, 0.6731984257692414, -0.3365992128846207]
lattice = mat3(a1, a2, a3);
reciprocal_lattice_vectors(lattice)
# output
3-element Vector{StaticArraysCore.SVector{3, Float64}}:
 [-2.6927937030769655, 2.243994752564138, 2.019595277307724]
 [1.3463968515384828, -1.1219973762820687, 0.5609986881410344]
 [0.4487989505128276, 0.6731984257692414, -0.3365992128846207]
source