Honeycomb Lattice in k-space

using LinearAlgebra
using Plots
using LatticeTools

simplifyname(s::AbstractString) = (
    s
    |> (x-> replace(x, r"<sup>(.+?)</sup>" => s"\1"))
    |> (x-> replace(x, r"<sub>(.+?)</sub>" => s"[\1]"))
)

function makewithin(extent::AbstractVector{<:Real})
    a, b, c, d = extent
    (x::Real, y::Real) -> ((a <= x <= b) && (c <= y <= d))
end
mkpath("example_little_symmetry_kspace_honeycomb")
"example_little_symmetry_kspace_honeycomb"

Honeycome Lattice

Define UnitCell

latticevectors = [1 -0.5; 0 sqrt(3)*0.5];
unitcell = makeunitcell(latticevectors; SiteType=String);
addsite!(unitcell, "A", carte2fract(unitcell, [0.5, 0.5 / sqrt(3)]));
addsite!(unitcell, "B", carte2fract(unitcell, [0.5, -0.5 / sqrt(3)]));

Plot Lattice

let bravais_lattice = [], a_sites = [], b_sites = []
    extent = [-2, 2, -2, 2]
    within = makewithin(extent)
    for i1 in -5:5, i2 in -5:5
        R = latticevectors * [i1, i2]
        within(R...) && push!(bravais_lattice, R)
        for (orb_name, orb_fc) in unitcell.sites
            orb_cc = fract2carte(unitcell, orb_fc)
            r = R + orb_cc
            within(r...) && push!(orb_name == "A" ? a_sites : b_sites, r)
        end
    end
    bravais_lattice = hcat(bravais_lattice...)
    a_sites = hcat(a_sites...)
    b_sites = hcat(b_sites...)

    img = plot(aspect_ratio=1)
    scatter!(bravais_lattice[1,:], bravais_lattice[2,:], color="black", markershape=:circle, markersize=3, label="Bravais")
    scatter!(a_sites[1,:], a_sites[2,:], color="red", markerstrokewidth=0, markersize=5, label="A")
    scatter!(b_sites[1,:], b_sites[2,:], color="blue", markerstrokewidth=0, markersize=5, label="B")
    xlims!(extent[1], extent[2])
    ylims!(extent[3], extent[4])
    savefig(img, "example_little_symmetry_kspace_honeycomb/realspace.svg")
end
/home/runner/.julia/packages/GR/RlE5Y/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

√3 × √3 Supercell

Make Superlattice

shape = [2 -1; 1 1]
lattice = makelattice(unitcell, shape)
Lattice{String}(UnitCell{String}([1.0 -0.5; 0.0 0.8660254037844386], Tuple{String,FractCoord}[("A", FractCoord([0, 0] + [0.6666666666666667, 0.3333333333333334])), ("B", FractCoord([0, -1] + [0.33333333333333326, 0.6666666666666665]))], [1.0 0.0; 0.5773502691896258 1.1547005383792517], [6.283185307179586 0.0; 3.627598728468436 7.255197456936872], Dict("B" => 2,"A" => 1)), Hypercube([2 -1; 1 1], Rational{Int64}[1//3 1//3; -1//3 2//3], LatticeTools.var"#wrap#10"{Array{Int64,2},Array{Rational{Int64},2}}([2 -1; 1 1], Rational{Int64}[1//3 1//3; -1//3 2//3])), [[0, 0], [0, 1], [1, 1]], UnitCell{Tuple{String,Array{Int64,1}}}([1.5 -1.5; 0.8660254037844386 0.8660254037844386], Tuple{Tuple{String,Array{Int64,1}},FractCoord}[(("A", [0, 0]), FractCoord([0, 0] + [0.33333333333333337, 0.0])), (("B", [0, 0]), FractCoord([0, -1] + [0.0, 0.6666666666666665])), (("A", [0, 1]), FractCoord([0, 0] + [0.6666666666666667, 0.6666666666666667])), (("B", [0, 1]), FractCoord([0, 0] + [0.3333333333333333, 0.3333333333333333])), (("A", [1, 1]), FractCoord([1, 0] + [0.0, 0.33333333333333337])), (("B", [1, 1]), FractCoord([0, 0] + [0.6666666666666665, 0.0]))], [0.33333333333333326 -0.33333333333333337; 0.5773502691896258 0.5773502691896258], [2.094395102393195 -2.0943951023931957; 3.627598728468436 3.627598728468436], Dict(("B", [1, 1]) => 6,("A", [0, 0]) => 1,("B", [0, 0]) => 2,("A", [0, 1]) => 3,("B", [0, 1]) => 4,("A", [1, 1]) => 5)))

Plot Lattice

let bravais_lattice = [], a_sites = [], b_sites = []
    extent = [-4, 4, -4, 4]
    within = makewithin(extent)

    for i1 in -5:5, i2 in -5:5
        R = lattice.supercell.latticevectors * [i1, i2]
        within(R...) && push!(bravais_lattice, R)
        for (orb_name, orb_fc) in lattice.supercell.sites
            orb_cc = fract2carte(lattice.supercell, orb_fc)
            r = R + orb_cc
            within(r...) && push!(orb_name[1] == "A" ? a_sites : b_sites, r)
        end
    end
    bravais_lattice = hcat(bravais_lattice...)
    a_sites = hcat(a_sites...)
    b_sites = hcat(b_sites...)

    img = plot(aspect_ratio=1)
    scatter!(bravais_lattice[1,:], bravais_lattice[2,:], color="black", markershape=:circle, markersize=3, label="Bravais (supercell)")
    scatter!(a_sites[1,:], a_sites[2,:], color="red", markerstrokewidth=0, markersize=5, label="A")
    scatter!(b_sites[1,:], b_sites[2,:], color="blue", markerstrokewidth=0, markersize=5, label="B")
    xlims!(extent[1], extent[2])
    ylims!(extent[3], extent[4])
    savefig(img, "example_little_symmetry_kspace_honeycomb/realspace-root3xroot3.svg")
end
/home/runner/.julia/packages/GR/RlE5Y/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

Symmetries

tsym = TranslationSymmetry(lattice)
psym = project(PointSymmetryDatabase.get(25), [1 0 0; 0 1 0])
println("point symmetry (Hermann Mauguin): $(psym.hermann_mauguin)")
println("translation symmetry compatible with point symmetry? ", iscompatible(tsym, psym))

println("irreducible representations:")
for tsym_irrep_index in 1:num_irreps(tsym)
    kf = tsym.fractional_momenta[tsym_irrep_index]
    kc = lattice.unitcell.reducedreciprocallatticevectors * kf
    psym_little = little_symmetry(tsym, tsym_irrep_index, psym)
    print("- irrep index: $tsym_irrep_index\n")
    print("  fractional momentum: [")
    for (i, x) in enumerate(kf)
        i != 1 && print(", ")
        print(x)
    end
    print("]\n")
    print("  momentum: [")
    for (i, x) in enumerate(kc)
        i != 1 && print(", ")
        print(x)
    end
    print("]\n")
    print("  is point symmetry compatible with momentum: $(iscompatible(tsym, tsym_irrep_index, psym))\n")
    print("  little point symmetry: $(psym_little.hermann_mauguin)\n")
end
point symmetry (Hermann Mauguin): 6mm
translation symmetry compatible with point symmetry? true
irreducible representations:
- irrep index: 1
  fractional momentum: [0//1, 0//1]
  momentum: [0.0, 0.0]
  is point symmetry compatible with momentum: true
  little point symmetry: 6mm
- irrep index: 2
  fractional momentum: [1//3, 1//3]
  momentum: [0.3333333333333333, 0.5773502691896258]
  is point symmetry compatible with momentum: false
  little point symmetry: 3m
- irrep index: 3
  fractional momentum: [2//3, 2//3]
  momentum: [0.6666666666666666, 1.1547005383792517]
  is point symmetry compatible with momentum: false
  little point symmetry: 3m

Plot Momentum Space

let
    extent = [-1.1, 1.1, -1.4, 1.4]
    within = makewithin(extent)

    reciprocallatticepoints = []
    kpoints = []
    littlegroupnames = String[]
    generatornames = String[]
    kpointnames = String[]

    for tsym_irrep_index in 1:num_irreps(tsym)
        psym_little = little_symmetry(tsym, tsym_irrep_index, psym)
        kf = tsym.fractional_momenta[tsym_irrep_index]
        kc = lattice.unitcell.reducedreciprocallatticevectors * kf
        for i1 in -2:2, i2 in -2:2
            G = lattice.unitcell.reducedreciprocallatticevectors * [i1, i2]
            within(G...) && push!(reciprocallatticepoints, G)
            k = G + kc
            if within(k...)
                push!(kpoints, k)
                push!(littlegroupnames, psym_little.hermann_mauguin)
                push!(generatornames, join(simplifyname.(psym_little.element_names[psym_little.generators]), "\n"))
                push!(kpointnames, "$tsym_irrep_index")
            end
        end
    end
    reciprocallatticepoints = hcat(reciprocallatticepoints...)
    kpoints = hcat(kpoints...)

    img = plot(size=(400, 500), xlims=(extent[1]-0.1, extent[2]+0.1), ylims=(extent[3]-0.1, extent[4]+0.1), aspect_ratio=1)
    scatter!(reciprocallatticepoints[1,:], reciprocallatticepoints[2,:],
             markershape=:circle, markersize=6, markercolor=RGBA(1,1,1,0), markerstrokecolor=RGBA(1,0,0,1), label="reciprocal lattice")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=4, markercolor=RGBA(0,0,1,0.5), markerstrokecolor=RGBA(0,0,1,0.5),
             series_annotations=[Plots.text("k[$x]", 8, :left, :bottom) for x in kpointnames], label="momentum points")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=0, color=RGBA(0,0,0,0),
             series_annotations=[Plots.text("$x ", 8, :right, :top) for x in littlegroupnames], label="")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=0, color=RGBA(0,0,0,0),
             series_annotations=[Plots.text("$x", 6, :left, :top) for x in generatornames], label="")
    savefig(img, "example_little_symmetry_kspace_honeycomb/momentumspace-root3xroot3.svg")
end
/home/runner/.julia/packages/GR/RlE5Y/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

2√3 × 2√3 Supercell

Make Superlattice

shape = [2 2; -2 4]
lattice = makelattice(unitcell, shape)
Lattice{String}(UnitCell{String}([1.0 -0.5; 0.0 0.8660254037844386], Tuple{String,FractCoord}[("A", FractCoord([0, 0] + [0.6666666666666667, 0.3333333333333334])), ("B", FractCoord([0, -1] + [0.33333333333333326, 0.6666666666666665]))], [1.0 0.0; 0.5773502691896258 1.1547005383792517], [6.283185307179586 0.0; 3.627598728468436 7.255197456936872], Dict("B" => 2,"A" => 1)), Hypercube([2 2; -2 4], Rational{Int64}[1//3 -1//6; 1//6 1//6], LatticeTools.var"#wrap#10"{Array{Int64,2},Array{Rational{Int64},2}}([2 2; -2 4], Rational{Int64}[1//3 -1//6; 1//6 1//6])), [[0, 0], [1, 0], [2, 0], [1, 2], [2, 2], [3, 2], [2, 1], [3, 1], [2, 3], [1, -1], [2, -1], [1, 1]], UnitCell{Tuple{String,Array{Int64,1}}}([3.0 0.0; -1.7320508075688772 3.4641016151377544], Tuple{Tuple{String,Array{Int64,1}},FractCoord}[(("A", [0, 0]), FractCoord([0, 0] + [0.16666666666666666, 0.16666666666666669])), (("B", [0, 0]), FractCoord([0, 0] + [0.16666666666666666, 0.0])), (("A", [1, 0]), FractCoord([0, 0] + [0.5, 0.33333333333333337])), (("B", [1, 0]), FractCoord([0, 0] + [0.5, 0.16666666666666666])), (("A", [2, 0]), FractCoord([0, 0] + [0.8333333333333333, 0.5000000000000001])), (("B", [2, 0]), FractCoord([0, 0] + [0.8333333333333333, 0.33333333333333337])), (("A", [1, 2]), FractCoord([0, 0] + [0.16666666666666666, 0.6666666666666669])), (("B", [1, 2]), FractCoord([0, 0] + [0.16666666666666666, 0.5])), (("A", [2, 2]), FractCoord([0, 0] + [0.5, 0.8333333333333335])), (("B", [2, 2]), FractCoord([0, 0] + [0.5, 0.6666666666666666]))  …  (("A", [3, 1]), FractCoord([1, 0] + [0.0, 0.8333333333333335])), (("B", [3, 1]), FractCoord([1, 0] + [0.0, 0.6666666666666667])), (("A", [2, 3]), FractCoord([0, 1] + [0.3333333333333333, 0.0])), (("B", [2, 3]), FractCoord([0, 0] + [0.3333333333333333, 0.8333333333333335])), (("A", [1, -1]), FractCoord([0, 0] + [0.6666666666666666, 0.16666666666666669])), (("B", [1, -1]), FractCoord([0, 0] + [0.6666666666666666, 0.0])), (("A", [2, -1]), FractCoord([1, 0] + [0.0, 0.33333333333333337])), (("B", [2, -1]), FractCoord([1, 0] + [0.0, 0.16666666666666669])), (("A", [1, 1]), FractCoord([0, 0] + [0.3333333333333333, 0.5])), (("B", [1, 1]), FractCoord([0, 0] + [0.3333333333333333, 0.33333333333333337]))], [0.3333333333333333 0.16666666666666669; 0.0 0.2886751345948129], [2.0943951023931953 1.0471975511965979; 0.0 1.813799364234218], Dict(("A", [2, 2]) => 9,("A", [1, 2]) => 7,("A", [1, -1]) => 19,("B", [1, -1]) => 20,("B", [3, 2]) => 12,("A", [1, 0]) => 3,("A", [2, -1]) => 21,("B", [2, 2]) => 10,("B", [1, 2]) => 8,("A", [2, 1]) => 13…)))

Plot Lattice

let bravais_lattice = [], a_sites = [], b_sites = []
    extent = [-8, 8, -8, 8]
    within = makewithin(extent)

    for i1 in -5:5, i2 in -5:5
        R = lattice.supercell.latticevectors * [i1, i2]
        within(R...) && push!(bravais_lattice, R)
        for (orb_name, orb_fc) in lattice.supercell.sites
            orb_cc = fract2carte(lattice.supercell, orb_fc)
            r = R + orb_cc
            within(r...) && push!(orb_name[1] == "A" ? a_sites : b_sites, r)
        end
    end
    bravais_lattice = hcat(bravais_lattice...)
    a_sites = hcat(a_sites...)
    b_sites = hcat(b_sites...)

    img = plot(aspect_ratio=1)
    scatter!(bravais_lattice[1,:], bravais_lattice[2,:], color="black", markershape=:circle, markersize=5, label="Bravais (supercell)")
    scatter!(a_sites[1,:], a_sites[2,:], color="red", markerstrokewidth=0, markersize=3, label="A")
    scatter!(b_sites[1,:], b_sites[2,:], color="blue", markerstrokewidth=0, markersize=3, label="B")
    xlims!(extent[1], extent[2])
    ylims!(extent[3], extent[4])
    savefig(img, "example_little_symmetry_kspace_honeycomb/realspace-2root3x2root3.svg")
end
/home/runner/.julia/packages/GR/RlE5Y/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

Symmetries

tsym = TranslationSymmetry(lattice)
psym = project(PointSymmetryDatabase.get(25), [1 0 0; 0 1 0])
println("point symmetry (Hermann Mauguin): $(psym.hermann_mauguin)")
println("translation symmetry compatible with point symmetry? ", iscompatible(tsym, psym))

println("irreducible representations:")
for tsym_irrep_index in 1:num_irreps(tsym)
    kf = tsym.fractional_momenta[tsym_irrep_index]
    kc = lattice.unitcell.reducedreciprocallatticevectors * kf
    psym_little = little_symmetry(tsym, tsym_irrep_index, psym)
    print("- irrep index: $tsym_irrep_index\n")
    print("  fractional momentum: [")
    for (i, x) in enumerate(kf)
        i != 1 && print(", ")
        print(x)
    end
    print("]\n")
    print("  momentum: [")
    for (i, x) in enumerate(kc)
        i != 1 && print(", ")
        print(x)
    end
    print("]\n")
    print("  is point symmetry compatible with momentum: $(iscompatible(tsym, tsym_irrep_index, psym))\n")
    print("  little point symmetry: $(psym_little.hermann_mauguin)\n")
end
point symmetry (Hermann Mauguin): 6mm
translation symmetry compatible with point symmetry? true
irreducible representations:
- irrep index: 1
  fractional momentum: [0//1, 0//1]
  momentum: [0.0, 0.0]
  is point symmetry compatible with momentum: true
  little point symmetry: 6mm
- irrep index: 2
  fractional momentum: [1//6, 2//3]
  momentum: [0.16666666666666666, 0.8660254037844387]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 3
  fractional momentum: [1//3, 1//3]
  momentum: [0.3333333333333333, 0.5773502691896258]
  is point symmetry compatible with momentum: false
  little point symmetry: 3m
- irrep index: 4
  fractional momentum: [1//2, 0//1]
  momentum: [0.5, 0.2886751345948129]
  is point symmetry compatible with momentum: false
  little point symmetry: mm2
- irrep index: 5
  fractional momentum: [2//3, 2//3]
  momentum: [0.6666666666666666, 1.1547005383792517]
  is point symmetry compatible with momentum: false
  little point symmetry: 3m
- irrep index: 6
  fractional momentum: [5//6, 1//3]
  momentum: [0.8333333333333334, 0.8660254037844388]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 7
  fractional momentum: [0//1, 1//2]
  momentum: [0.0, 0.5773502691896258]
  is point symmetry compatible with momentum: false
  little point symmetry: mm2
- irrep index: 8
  fractional momentum: [1//6, 1//6]
  momentum: [0.16666666666666666, 0.2886751345948129]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 9
  fractional momentum: [1//3, 5//6]
  momentum: [0.3333333333333333, 1.1547005383792517]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 10
  fractional momentum: [1//2, 1//2]
  momentum: [0.5, 0.8660254037844388]
  is point symmetry compatible with momentum: false
  little point symmetry: mm2
- irrep index: 11
  fractional momentum: [2//3, 1//6]
  momentum: [0.6666666666666666, 0.5773502691896258]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 12
  fractional momentum: [5//6, 5//6]
  momentum: [0.8333333333333334, 1.4433756729740648]
  is point symmetry compatible with momentum: false
  little point symmetry: m

Plot Momentum Space

let
    extent = [-1.2, 1.2, -1.6, 1.6]
    extent = [-1.1, 1.1, -1.4, 1.4]
    within = makewithin(extent)

    reciprocallatticepoints = []
    kpoints = []
    littlegroupnames = String[]
    generatornames = String[]
    kpointnames = String[]

    for tsym_irrep_index in 1:num_irreps(tsym)
        psym_little = little_symmetry(tsym, tsym_irrep_index, psym)
        kf = tsym.fractional_momenta[tsym_irrep_index]
        kc = lattice.unitcell.reducedreciprocallatticevectors * kf
        for i1 in -2:2, i2 in -2:2
            G = lattice.unitcell.reducedreciprocallatticevectors * [i1, i2]
            within(G...) && push!(reciprocallatticepoints, G)
            k = G + kc
            if within(k...)
                push!(kpoints, k)
                push!(littlegroupnames, psym_little.hermann_mauguin)
                push!(generatornames, join(simplifyname.(psym_little.element_names[psym_little.generators]), "\n"))
                push!(kpointnames, "$tsym_irrep_index")
            end
        end
    end
    reciprocallatticepoints = hcat(reciprocallatticepoints...)
    kpoints = hcat(kpoints...)

    img = plot(size=(600, 750), xlims=(extent[1]-0.1, extent[2]+0.1), ylims=(extent[3]-0.1, extent[4]+0.1), aspect_ratio=1)
    scatter!(reciprocallatticepoints[1,:], reciprocallatticepoints[2,:],
             markershape=:circle, markersize=6, markercolor=RGBA(1,1,1,0), markerstrokecolor=RGBA(1,0,0,1), label="reciprocal lattice")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=4, markercolor=RGBA(0,0,1,0.5), markerstrokecolor=RGBA(0,0,1,0.5),
             series_annotations=[Plots.text("k[$x]", 8, :left, :bottom) for x in kpointnames], label="momentum points")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=0, color=RGBA(0,0,0,0),
             series_annotations=[Plots.text("$x ", 8, :right, :top) for x in littlegroupnames], label="")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=0, color=RGBA(0,0,0,0),
             series_annotations=[Plots.text("$x", 6, :left, :top) for x in generatornames], label="")
    savefig(img, "example_little_symmetry_kspace_honeycomb/momentumspace-2root3x2root3.svg")
end
/home/runner/.julia/packages/GR/RlE5Y/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

6 × 6 Supercell

Make Superlattice

shape = [6 0; 0 6]
lattice = makelattice(unitcell, shape)
Lattice{String}(UnitCell{String}([1.0 -0.5; 0.0 0.8660254037844386], Tuple{String,FractCoord}[("A", FractCoord([0, 0] + [0.6666666666666667, 0.3333333333333334])), ("B", FractCoord([0, -1] + [0.33333333333333326, 0.6666666666666665]))], [1.0 0.0; 0.5773502691896258 1.1547005383792517], [6.283185307179586 0.0; 3.627598728468436 7.255197456936872], Dict("B" => 2,"A" => 1)), Hypercube([6 0; 0 6], Rational{Int64}[1//6 0//1; 0//1 1//6], LatticeTools.var"#wrap#10"{Array{Int64,2},Array{Rational{Int64},2}}([6 0; 0 6], Rational{Int64}[1//6 0//1; 0//1 1//6])), [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [0, 1], [1, 1], [2, 1], [3, 1]  …  [2, 4], [3, 4], [4, 4], [5, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]], UnitCell{Tuple{String,Array{Int64,1}}}([6.0 -3.0; 0.0 5.196152422706632], Tuple{Tuple{String,Array{Int64,1}},FractCoord}[(("A", [0, 0]), FractCoord([0, 0] + [0.1111111111111111, 0.055555555555555566])), (("B", [0, 0]), FractCoord([0, -1] + [0.055555555555555546, 0.9444444444444444])), (("A", [1, 0]), FractCoord([0, 0] + [0.2777777777777778, 0.055555555555555566])), (("B", [1, 0]), FractCoord([0, -1] + [0.2222222222222222, 0.9444444444444444])), (("A", [2, 0]), FractCoord([0, 0] + [0.4444444444444444, 0.055555555555555566])), (("B", [2, 0]), FractCoord([0, -1] + [0.38888888888888884, 0.9444444444444444])), (("A", [3, 0]), FractCoord([0, 0] + [0.611111111111111, 0.055555555555555566])), (("B", [3, 0]), FractCoord([0, -1] + [0.5555555555555555, 0.9444444444444444])), (("A", [4, 0]), FractCoord([0, 0] + [0.7777777777777778, 0.055555555555555566])), (("B", [4, 0]), FractCoord([0, -1] + [0.7222222222222222, 0.9444444444444444]))  …  (("A", [1, 5]), FractCoord([0, 0] + [0.2777777777777777, 0.8888888888888888])), (("B", [1, 5]), FractCoord([0, 0] + [0.22222222222222213, 0.7777777777777777])), (("A", [2, 5]), FractCoord([0, 0] + [0.44444444444444436, 0.8888888888888888])), (("B", [2, 5]), FractCoord([0, 0] + [0.3888888888888888, 0.7777777777777777])), (("A", [3, 5]), FractCoord([0, 0] + [0.611111111111111, 0.8888888888888888])), (("B", [3, 5]), FractCoord([0, 0] + [0.5555555555555555, 0.7777777777777777])), (("A", [4, 5]), FractCoord([0, 0] + [0.7777777777777777, 0.8888888888888888])), (("B", [4, 5]), FractCoord([0, 0] + [0.7222222222222221, 0.7777777777777777])), (("A", [5, 5]), FractCoord([0, 0] + [0.9444444444444443, 0.8888888888888888])), (("B", [5, 5]), FractCoord([0, 0] + [0.8888888888888887, 0.7777777777777777]))], [0.16666666666666666 0.0; 0.09622504486493762 0.19245008972987526], [1.0471975511965976 0.0; 0.6045997880780726 1.2091995761561452], Dict(("A", [2, 5]) => 65,("B", [0, 5]) => 62,("A", [5, 1]) => 23,("B", [4, 4]) => 58,("B", [1, 5]) => 64,("B", [5, 2]) => 36,("A", [1, 5]) => 63,("B", [3, 1]) => 20,("B", [3, 5]) => 68,("B", [2, 5]) => 66…)))

Plot Lattice

let bravais_lattice = [], a_sites = [], b_sites = []
    extent = [-8, 8, -8, 8]
    within = makewithin(extent)

    for i1 in -5:5, i2 in -5:5
        R = lattice.supercell.latticevectors * [i1, i2]
        within(R...) && push!(bravais_lattice, R)
        for (orb_name, orb_fc) in lattice.supercell.sites
            orb_cc = fract2carte(lattice.supercell, orb_fc)
            r = R + orb_cc
            within(r...) && push!(orb_name[1] == "A" ? a_sites : b_sites, r)
        end
    end
    bravais_lattice = hcat(bravais_lattice...)
    a_sites = hcat(a_sites...)
    b_sites = hcat(b_sites...)

    img = plot(aspect_ratio=1)
    scatter!(bravais_lattice[1,:], bravais_lattice[2,:], color="black", markershape=:circle, markersize=5, label="Bravais (supercell)")
    scatter!(a_sites[1,:], a_sites[2,:], color="red", markerstrokewidth=0, markersize=3, label="A")
    scatter!(b_sites[1,:], b_sites[2,:], color="blue", markerstrokewidth=0, markersize=3, label="B")
    xlims!(extent[1], extent[2])
    ylims!(extent[3], extent[4])
    savefig(img, "example_little_symmetry_kspace_honeycomb/realspace-6x6.svg")
end
/home/runner/.julia/packages/GR/RlE5Y/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

Symmetries

tsym = TranslationSymmetry(lattice)
psym = project(PointSymmetryDatabase.get(25), [1 0 0; 0 1 0])
println("point symmetry (Hermann Mauguin): $(psym.hermann_mauguin)")
println("translation symmetry compatible with point symmetry? ", iscompatible(tsym, psym))

println("irreducible representations:")
for tsym_irrep_index in 1:num_irreps(tsym)
    kf = tsym.fractional_momenta[tsym_irrep_index]
    kc = lattice.unitcell.reducedreciprocallatticevectors * kf
    psym_little = little_symmetry(tsym, tsym_irrep_index, psym)
    print("- irrep index: $tsym_irrep_index\n")
    print("  fractional momentum: [")
    for (i, x) in enumerate(kf)
        i != 1 && print(", ")
        print(x)
    end
    print("]\n")
    print("  momentum: [")
    for (i, x) in enumerate(kc)
        i != 1 && print(", ")
        print(x)
    end
    print("]\n")
    print("  is point symmetry compatible with momentum: $(iscompatible(tsym, tsym_irrep_index, psym))\n")
    print("  little point symmetry: $(psym_little.hermann_mauguin)\n")
end
point symmetry (Hermann Mauguin): 6mm
translation symmetry compatible with point symmetry? true
irreducible representations:
- irrep index: 1
  fractional momentum: [0//1, 0//1]
  momentum: [0.0, 0.0]
  is point symmetry compatible with momentum: true
  little point symmetry: 6mm
- irrep index: 2
  fractional momentum: [1//6, 0//1]
  momentum: [0.16666666666666666, 0.09622504486493763]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 3
  fractional momentum: [1//3, 0//1]
  momentum: [0.3333333333333333, 0.19245008972987526]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 4
  fractional momentum: [1//2, 0//1]
  momentum: [0.5, 0.2886751345948129]
  is point symmetry compatible with momentum: false
  little point symmetry: mm2
- irrep index: 5
  fractional momentum: [2//3, 0//1]
  momentum: [0.6666666666666666, 0.3849001794597505]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 6
  fractional momentum: [5//6, 0//1]
  momentum: [0.8333333333333334, 0.48112522432468824]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 7
  fractional momentum: [0//1, 1//6]
  momentum: [0.0, 0.19245008972987526]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 8
  fractional momentum: [1//6, 1//6]
  momentum: [0.16666666666666666, 0.2886751345948129]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 9
  fractional momentum: [1//3, 1//6]
  momentum: [0.3333333333333333, 0.3849001794597505]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 10
  fractional momentum: [1//2, 1//6]
  momentum: [0.5, 0.4811252243246882]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 11
  fractional momentum: [2//3, 1//6]
  momentum: [0.6666666666666666, 0.5773502691896258]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 12
  fractional momentum: [5//6, 1//6]
  momentum: [0.8333333333333334, 0.6735753140545635]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 13
  fractional momentum: [0//1, 1//3]
  momentum: [0.0, 0.3849001794597505]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 14
  fractional momentum: [1//6, 1//3]
  momentum: [0.16666666666666666, 0.4811252243246882]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 15
  fractional momentum: [1//3, 1//3]
  momentum: [0.3333333333333333, 0.5773502691896258]
  is point symmetry compatible with momentum: false
  little point symmetry: 3m
- irrep index: 16
  fractional momentum: [1//2, 1//3]
  momentum: [0.5, 0.6735753140545635]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 17
  fractional momentum: [2//3, 1//3]
  momentum: [0.6666666666666666, 0.769800358919501]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 18
  fractional momentum: [5//6, 1//3]
  momentum: [0.8333333333333334, 0.8660254037844388]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 19
  fractional momentum: [0//1, 1//2]
  momentum: [0.0, 0.5773502691896258]
  is point symmetry compatible with momentum: false
  little point symmetry: mm2
- irrep index: 20
  fractional momentum: [1//6, 1//2]
  momentum: [0.16666666666666666, 0.6735753140545635]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 21
  fractional momentum: [1//3, 1//2]
  momentum: [0.3333333333333333, 0.769800358919501]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 22
  fractional momentum: [1//2, 1//2]
  momentum: [0.5, 0.8660254037844388]
  is point symmetry compatible with momentum: false
  little point symmetry: mm2
- irrep index: 23
  fractional momentum: [2//3, 1//2]
  momentum: [0.6666666666666666, 0.9622504486493764]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 24
  fractional momentum: [5//6, 1//2]
  momentum: [0.8333333333333334, 1.0584754935143141]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 25
  fractional momentum: [0//1, 2//3]
  momentum: [0.0, 0.769800358919501]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 26
  fractional momentum: [1//6, 2//3]
  momentum: [0.16666666666666666, 0.8660254037844387]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 27
  fractional momentum: [1//3, 2//3]
  momentum: [0.3333333333333333, 0.9622504486493764]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 28
  fractional momentum: [1//2, 2//3]
  momentum: [0.5, 1.058475493514314]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 29
  fractional momentum: [2//3, 2//3]
  momentum: [0.6666666666666666, 1.1547005383792517]
  is point symmetry compatible with momentum: false
  little point symmetry: 3m
- irrep index: 30
  fractional momentum: [5//6, 2//3]
  momentum: [0.8333333333333334, 1.2509255832441892]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 31
  fractional momentum: [0//1, 5//6]
  momentum: [0.0, 0.9622504486493765]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 32
  fractional momentum: [1//6, 5//6]
  momentum: [0.16666666666666666, 1.0584754935143141]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 33
  fractional momentum: [1//3, 5//6]
  momentum: [0.3333333333333333, 1.1547005383792517]
  is point symmetry compatible with momentum: false
  little point symmetry: m
- irrep index: 34
  fractional momentum: [1//2, 5//6]
  momentum: [0.5, 1.2509255832441895]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 35
  fractional momentum: [2//3, 5//6]
  momentum: [0.6666666666666666, 1.347150628109127]
  is point symmetry compatible with momentum: false
  little point symmetry: 1
- irrep index: 36
  fractional momentum: [5//6, 5//6]
  momentum: [0.8333333333333334, 1.4433756729740648]
  is point symmetry compatible with momentum: false
  little point symmetry: m

Plot Momentum Space

let
    extent = [-1.2, 1.2, -1.6, 1.6]
    extent = [-1.1, 1.1, -1.4, 1.4]
    within = makewithin(extent)

    reciprocallatticepoints = []
    kpoints = []
    littlegroupnames = String[]
    generatornames = String[]
    kpointnames = String[]

    for tsym_irrep_index in 1:num_irreps(tsym)
        psym_little = little_symmetry(tsym, tsym_irrep_index, psym)
        kf = tsym.fractional_momenta[tsym_irrep_index]
        kc = lattice.unitcell.reducedreciprocallatticevectors * kf
        for i1 in -2:2, i2 in -2:2
            G = lattice.unitcell.reducedreciprocallatticevectors * [i1, i2]
            within(G...) && push!(reciprocallatticepoints, G)
            k = G + kc
            if within(k...)
                push!(kpoints, k)
                push!(littlegroupnames, psym_little.hermann_mauguin)
                push!(generatornames, join(simplifyname.(psym_little.element_names[psym_little.generators]), "\n"))
                push!(kpointnames, "$tsym_irrep_index")
            end
        end
    end
    reciprocallatticepoints = hcat(reciprocallatticepoints...)
    kpoints = hcat(kpoints...)

    img = plot(size=(800, 1000), xlims=(extent[1]-0.1, extent[2]+0.1), ylims=(extent[3]-0.1, extent[4]+0.1), aspect_ratio=1)
    scatter!(reciprocallatticepoints[1,:], reciprocallatticepoints[2,:],
             markershape=:circle, markersize=6, markercolor=RGBA(1,1,1,0), markerstrokecolor=RGBA(1,0,0,1), label="reciprocal lattice")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=4, markercolor=RGBA(0,0,1,0.5), markerstrokecolor=RGBA(0,0,1,0.5),
             series_annotations=[Plots.text("k[$x]", 8, :left, :bottom) for x in kpointnames], label="momentum points")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=0, color=RGBA(0,0,0,0),
             series_annotations=[Plots.text("$x ", 8, :right, :top) for x in littlegroupnames], label="")
    scatter!(kpoints[1,:], kpoints[2,:],
             markershape=:circle, markersize=0, color=RGBA(0,0,0,0),
             series_annotations=[Plots.text("$x", 6, :left, :top) for x in generatornames], label="")
    savefig(img, "example_little_symmetry_kspace_honeycomb/momentumspace-6x6.svg")
end
/home/runner/.julia/packages/GR/RlE5Y/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS


This page was generated using Literate.jl.