group_by_degeneracy
full name: tenpy.tools.misc.group_by_degeneracy
parent module:
tenpy.tools.misc
type: function
- tenpy.tools.misc.group_by_degeneracy(E, *args, subset=None, cutoff=1e-12)[source]
Find groups of indices for which (energy) values are degenerate.
- Parameters:
values (1D array) – Values (e.g. energies) which need to be close to count as degenerate.
*args (1D array) – Additional vectors (with same length as values), which also need to be close (up to cutoff) to count as degenerate.
subset (1D array) – Optionally selects a subset of the indices
cutoff (float) – Precision up to which values still count as degenerate.
- Returns:
idx_groups (list of tuple of int) – Each tuple group contains indices
i, j, k, ...
for which the values are closer than cutoff, i.e.,|E[j, k, ...] - E[i]| <= cutoff
. Each index appears exactly once (if it is contained in subset)... testsetup :: – from tenpy.tools.misc import *
>>> E = [2., 2.4, 1.9999, 1.8, 2.3999, 5, 1.8]
… # -> 0 1 2 3 4 5 6
>>> k = [0, 1, 2, 2, 1, 2, 1]
>>> group_by_degeneracy(E, cutoff=0.001)
[(0, 2), (1, 4), (3, 6), (5,)]
>>> group_by_degeneracy(E, k, cutoff=0.001) # k and E need to be close
[(0,), (1, 4), (2,), (3,), (5,), (6,)]