Skip to content

Commit

Permalink
Merge pull request #195 from pablosanjose/spectrumphi
Browse files Browse the repository at this point in the history
Implement spectrum(h, phi)
  • Loading branch information
pablosanjose authored May 9, 2022
2 parents 72c03e0 + ecca67d commit 4c0f45c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/bandstructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ $i Subspaces : $(length(s.subs))")
end

"""
spectrum(h; method = LinearAlgebraPackage(), transform = missing)
spectrum(h, φs; method = LinearAlgebraPackage(), transform = missing)
Compute the spectrum of a 0D Hamiltonian `h` (or alternatively of the bounded unit cell of a
finite dimensional `h`) using one of the following `method`s
Compute the spectrum of a Hamiltonian `h` at Bloch phases φs (or at zero if φs is not given)
using one of the following `method`s
method diagonalization function
--------------------------------------------------------------
Expand Down Expand Up @@ -127,9 +127,10 @@ independent copy.
# See also
`bandstructure`, `diagonalizer`
"""
function spectrum(h; method = LinearAlgebraPackage(), transform = missing)

function spectrum(h, φs = zerocell(h); method = LinearAlgebraPackage(), transform = missing)
diag = diagonalizer(h; method = method)
(ϵk, ψk) = diag((), NoUnflatten())
(ϵk, ψk) = diag(φs, NoUnflatten())
s = Spectrum(ϵk, ψk, diag)
transform === missing || transform!(transform, s)
return s
Expand Down
2 changes: 2 additions & 0 deletions src/hamiltonian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ latdim(h::Hamiltonian) = last(dims(h.lattice))

matrixtype(::Hamiltonian{LA,L,M,A}) where {LA,L,M,A} = A

zerocell(h::Hamiltonian) = zerocell(h.lattice)

blockeltype(::Hamiltonian{<:Any,<:Any,M}) where {M} = eltype(M)

# find SMatrix type that can hold all matrix elements between lattice sites
Expand Down
2 changes: 2 additions & 0 deletions src/lattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ function lattice(lat::Lattice; bravais = bravais(lat), kw...)
end
lattice(; kw...) = lat -> lattice(lat; kw...)

zerocell(::Lattice{<:Any,L}) where {L} = zero(SVector{L,Int})

#######################################################################
# Supercell
#######################################################################
Expand Down

0 comments on commit 4c0f45c

Please sign in to comment.