Skip to content

Commit

Permalink
EBR decomposition working
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelgda committed Nov 4, 2024
1 parent 9d61172 commit fa7ed13
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
24 changes: 16 additions & 8 deletions irrep/bandstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,13 +1133,20 @@ def print_symmetry_indicators(self):
print(f"\tDefinition: ({definition_str}) mod {si_table[indicator]['mod']}")

def print_ebr_decomposition(self):
import ebrs
from .ebrs import (
compose_irrep_string,
compute_topological_classification_vector,
ORTOOLS_AVAILABLE,
compute_ebr_decomposition,
get_ebr_names_and_positions,
compose_ebr_string
)
from .utility import vector_pprint

def print_symmetry_info():
basis_labels = ebr_data["basis"]["irrep_labels"]
print(
f"Irrep decomposition at high-symmetry points:\n\n{ebrs.compose_irrep_string(irrep_counts)}"
f"Irrep decomposition at high-symmetry points:\n\n{compose_irrep_string(irrep_counts)}"
f"\n\nIrrep basis:\n{vector_pprint(basis_labels, fmt='s')}"
f"\n\nSymmetry vector:\n{vector_pprint(symmetry_vector, fmt='d')}"
f"\n\nSmith singular values:\n{vector_pprint(smith_diagonal, fmt='d')}"
Expand Down Expand Up @@ -1168,19 +1175,19 @@ def print_symmetry_info():
_,
smith_diagonal,
nontrivial
) = ebrs.compute_topological_classification_vector(irrep_counts, ebr_data)
) = compute_topological_classification_vector(irrep_counts, ebr_data)

if nontrivial:
print("The set of bands is classified as TOPOLOGICAL\n")
print_symmetry_info()
elif not ebrs.ORTOOLS_AVAILABLE:
elif not ORTOOLS_AVAILABLE:
print(
"There exists integer-valued solutions to the EBR decomposition "
"problem. Install OR-Tools to compute them."
)
print_symmetry_info()
else:
solutions, is_positive = ebrs.compute_ebr_decomposition(ebr_data, symmetry_vector)
solutions, is_positive = compute_ebr_decomposition(ebr_data, symmetry_vector)

if is_positive:
print("The set of bands is toplogically TRIVIAL")
Expand All @@ -1197,9 +1204,10 @@ def print_symmetry_info():
"of EBRs that reproduce the bands. Some possibilities are:"
)

ebr_list = ebrs.get_ebr_names_and_positions(ebr_data)
for sol in solutions:
print(ebrs.compose_ebr_string(sol, ebr_list))
ebr_list = get_ebr_names_and_positions(ebr_data)
for i, sol in enumerate(solutions):
print("Solution", i + 1, "\n")
print(compose_ebr_string(sol, ebr_list), "\n")


def check_multiplicity(multi):
Expand Down
2 changes: 1 addition & 1 deletion irrep/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def cli(
bandstr.write_characters()

if ebr_decomposition:
bandstr.print(ebr_decomposition)
bandstr.print_ebr_decomposition()

if symmetry_indicators:
bandstr.print_symmetry_indicators()
Expand Down
9 changes: 4 additions & 5 deletions irrep/ebrs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Module to compute EBR decompositions.
"""
import numpy as np
from irreptables import load_ebr_data
from .utility import vector_pprint

# Actual EBR decomposition requires OR-Tool's SAT problem solver.
try:
Expand Down Expand Up @@ -210,8 +208,9 @@ def compose_ebr_string(vec, ebrs):
string representing the EBR decomposition in readable form
"""
s = ""
for ebr, multip in zip(ebrs, vec):
label, wp = ebr
s += f"{multip} [ {label} @ {wp} ] + "
for ebr, multi in zip(ebrs, vec):
if multi != 0:
label, wp = ebr
s += f"{multi} x [ {label} @ {wp} ] + "

return s[:-2]

0 comments on commit fa7ed13

Please sign in to comment.