Skip to content

Commit 419c39d

Browse files
committed
add a few small QoL things that, not previously incorporated from #89
1 parent 5d7eab6 commit 419c39d

2 files changed

Lines changed: 44 additions & 10 deletions

File tree

src/symmetry_analysis.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,18 @@ and are otherwise initialized by the function.
8888
8989
The symmetry eigenvalues are returned as a matrix, with rows running over the elements of
9090
`ops` and columns running over the bands of `ptbm`.
91+
92+
!!! note
93+
The inputs `ops`, `k`, and `lg` must be provided in a primitive setting. See
94+
Crystalline.jl's `primitivize`.
9195
"""
9296
function symmetry_eigenvalues(
9397
ptbm::ParameterizedTightBindingModel{D},
9498
ops::AbstractVector{SymOperation{D}},
9599
k::ReciprocalPointLike{D},
96-
sgreps::AbstractVector{SiteInducedSGRepElement{D}} = sgrep_induced_by_siteir.(
97-
Ref(ptbm.tbm.cbr),
98-
ops,
99-
),
100+
sgreps::AbstractVector{SiteInducedSGRepElement{D}} = begin
101+
sgrep_induced_by_siteir.(Ref(ptbm.tbm.cbr), ops)
102+
end,
100103
) where D
101104
length(k) == D || error("dimension mismatch")
102105
length(sgreps) == length(ops) || error("length of `sgreps` must match length of `ops`")

test/symmetry_analysis.jl

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,43 @@ using SymmetricTightBinding
44
using Crystalline
55
using Crystalline: free
66

7+
# ---------------------------------------------------------------------------------------- #
8+
9+
@testset "Symmetry analysis (documentation example)" begin
10+
# Example 1
11+
sgnum = 17 # plane group p6mm
12+
brs = calc_bandreps(sgnum, Val(2)) # band representations
13+
cbr = @composite brs[5] # (2b|A₁) EBR
14+
tbm = tb_hamiltonian(cbr) # tight-binding model (nearest neigbors)
15+
ptbm = tbm([0, 1]) # zero self-energy, nonzero nearest-neighbor hopping
16+
ns = collect_compatible(ptbm)
17+
@test only(ns) == SymmetryVector(cbr) == SymmetryVector(CompositeBandRep(ptbm))
18+
19+
# Example 2
20+
cbr′ = @composite brs[3] + brs[5] # (2a|A₁) + (3c|B₂)
21+
tbm′ = tb_hamiltonian(cbr′)
22+
ptbm′ = tbm′([2.5, 0, 0.2, 0, -1, 0])
23+
ns′ = collect_compatible(ptbm′)
24+
@test length(ns′) == 1 # bands are overlapping and not separable
25+
@test only(ns′) == SymmetryVector(cbr′)
26+
27+
ptbm′′ = tbm′([2.5, 0, 0.2, 0, -1, .5]) # turn on hybridization and split bands
28+
ns′′ = collect_compatible(ptbm′′)
29+
@test length(ns′′) == 2 # bands are overlapping and not separable
30+
@test ns′′[1] brs[[3, 5]]
31+
@test ns′′[2] brs[[3, 5]]
32+
@test sum(ns′′) == SymmetryVector(cbr′)
33+
end
34+
35+
# ---------------------------------------------------------------------------------------- #
36+
37+
# Construct a tb-model for every EBR and verify that `collect_compatible` returns a set of
38+
# symmetry vectors whose sum is equal to the underlying EBR's: note that we cannot generally
39+
# require that `collect_compatible` returns a _single_ symmetry vector equaling the EBR's
40+
# symmetry vector, since the EBR might be decomposable (either into fragile or genuinely
41+
# topological EBRs): i.e., we don't know if the model is a single connected band or not,
42+
# only what the "sum" of symmetry vectors will be.
43+
744
function _test_symmetry_analysis(brs, i, αβγ; rng_seed=1234)
845
coefs = zeros(length(brs))
946
coefs[i] = 1
@@ -17,12 +54,6 @@ function _test_symmetry_analysis(brs, i, αβγ; rng_seed=1234)
1754
end
1855

1956
@testset "Symmetry analysis (full scan over EBRs)" begin
20-
# construct a tb-model for every EBR and verify that `collect_compatible` returns a set
21-
# of symmetry vectors whose sum is equal to the underlying EBR's: note that we cannot
22-
# generally require that `collect_compatible` returns a _single_ symmetry vector
23-
# equaling the EBR's symmetry vector, since the EBR might be decomposable (either into
24-
# fragile or genuinely topological EBRs): i.e., we don't know if the model is a single
25-
# connected band or not, only what the "sum" of symmetry vectors will be
2657
for D in 1:3
2758
αβγ = D == 1 ? [.1] : D == 2 ? [.1, .2] : [.1, .2, .3] # for `pin_free!`
2859
for sgnum in MAX_SGNUM[D]

0 commit comments

Comments
 (0)