diff --git a/Project.toml b/Project.toml index 58b50cd..f72ff54 100644 --- a/Project.toml +++ b/Project.toml @@ -1,8 +1,7 @@ name = "SimpleQuantum" uuid = "7c07e4e5-e402-48af-840a-a11b8ea3e28c" authors = ["Tomas Polakovic and contributors"] -version = "0.2.3" - +version = "0.2.4" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" @@ -15,6 +14,7 @@ Match = "7eb4fadd-790c-5f42-8a69-bfa0b872bfbf" RangeHelpers = "3a07dd3d-1c52-4395-8858-40c6328157db" SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +SymmetryReduceBZ = "49a35663-c880-4242-bebb-1ec8c0fa8046" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [compat] diff --git a/src/SimpleQuantum.jl b/src/SimpleQuantum.jl index 09a5e5b..a1acc66 100644 --- a/src/SimpleQuantum.jl +++ b/src/SimpleQuantum.jl @@ -10,6 +10,7 @@ using Colors using GLMakie using Accessors using Combinatorics +using SymmetryReduceBZ include("crystal.jl") include("interface.jl") diff --git a/src/crystal.jl b/src/crystal.jl index 0e5ae23..5ac7b5e 100644 --- a/src/crystal.jl +++ b/src/crystal.jl @@ -204,30 +204,7 @@ end Calculates the point symmetry group operations of `c`. """ function getPG(c::Crystal) - D = ndims(c) - # TODO: I think Minkowski reduction might be good here. - R = c.lattice.R |> Matrix - iR = SMatrix{D,D}(inv(R)) - norms = mapslices(norm, R; dims=1) - vol = c.lattice.V - ls = round.(norms) .+ 1 - verts = (Iterators.product(ntuple(i -> -ls[i]:ls[i], D)...) - .|> collect - |> x -> reshape(x, :, 1) - |> combinedims)[:,:,1] - out = SMatrix{D,D}[] - for perm ∈ permutations(1:size(verts, 2), D) - vs = R * verts[:, perm] - _norms = mapslices(norm, vs; dims=1) - _vol = abs(det(vs)) - if all(norms ≈ _norms) & all(vol ≈ _vol) - op = SMatrix{D,D}(vs * iR) - if all(op' * op ≈ I) - append!(out, [op]) - end - end - end - out + SymmetryReduceBZ.Symmetry.calc_pointgroup(c.lattice.R) end """ diff --git a/src/interface.jl b/src/interface.jl index 2a89e5f..6a0d526 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -1,24 +1,24 @@ -struct ReciprocalPath - ks::Vector{Union{<:Real, Vector{<:Real}}} - kp::Vector{<:Real} - kl::Vector{Pair{Symbol, <:Real}} -end +###################################################################################### +abstract type GenericHamiltonian end -abstract type ReciprocalHamiltonian end +# function Base.ndims(t::T) where {T <: GenericHamiltonian} +# error(typeof(t), " needs to have `ndims` defined.") +# end -function Base.ndims(t::T) where {T <: ReciprocalHamiltonian} - e = typeof(t) - throw(ArgumentError("$e needs to have `ndims` defined.")) +function getH(t::T) where {T <: GenericHamiltonian} + error(typeof(t), " needs to have `getH` defined.") end -function getH(t::T) where {T <: ReciprocalHamiltonian} - e = typeof(t) - throw(ArgumentError("$e needs to have `getH` defined.")) +abstract type ReciprocalHamiltonian <: GenericHamiltonian end + +function (h::ReciprocalHamiltonian)(k) + getH(h)(k) end -struct ReciprocalBandProblem - h::ReciprocalHamiltonian - kp::ReciprocalPath +struct ReciprocalPath + ks::Vector{Union{<:Real, Vector{<:Real}}} + kp::Vector{<:Real} + kl::Vector{Pair{Symbol, <:Real}} end function ReciprocalPath(kpositions::Vector, kstep::Real) @@ -26,20 +26,19 @@ function ReciprocalPath(kpositions::Vector, kstep::Real) ReciprocalPath(k.path, k.plength, k.ppoints) end -function (h::ReciprocalHamiltonian)(k) - getH(h)(k) +struct ReciprocalBandProblem + h::ReciprocalHamiltonian + kp::ReciprocalPath end -function (rp::ReciprocalPath)(h::ReciprocalHamiltonian) +function (h::ReciprocalHamiltonian)(rp::ReciprocalPath) ReciprocalBandProblem(h, rp) end -function (h::ReciprocalHamiltonian)(rp::ReciprocalPath) +function (rp::ReciprocalPath)(h::ReciprocalHamiltonian) ReciprocalBandProblem(h, rp) end -# abstract type Solution end - """ BandSolution