Skip to content

Commit

Permalink
Merge pull request #13 from tpolakovic/sym_int
Browse files Browse the repository at this point in the history
Better symmetry finding and small changes to interface.
  • Loading branch information
tpolakovic authored Jan 24, 2023
2 parents b99dc8b + 5732eac commit 9dfcd4c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name = "SimpleQuantum"
uuid = "7c07e4e5-e402-48af-840a-a11b8ea3e28c"
authors = ["Tomas Polakovic <[email protected]> and contributors"]
version = "0.2.3"

version = "0.2.4"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/SimpleQuantum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using Colors
using GLMakie
using Accessors
using Combinatorics
using SymmetryReduceBZ

include("crystal.jl")
include("interface.jl")
Expand Down
25 changes: 1 addition & 24 deletions src/crystal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down
41 changes: 20 additions & 21 deletions src/interface.jl
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
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)
k = kpath(kpositions, kstep)
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
Expand Down

0 comments on commit 9dfcd4c

Please sign in to comment.