Bug in symmetry finder
This is a bug in the symmetry finder that we introduced when changing the behaviour of Model
. Model
no longer removes terms with very small matrix coefficients on initialization. This behaviour was assumed at least at one pont in the code. For example here https://gitlab.kwant-project.org/qt/qsymm/blob/f78723c9bc16fa6383562b1ef58b399f8ee01ab0/qsymm/symmetry_finder.py#L490 we compare the sets of keys on two models, which breaks if new keys appear with small coefficients as a result of cancellation. This particular location is easy to fix, but we should scan the code for errors of this kind.
Below is a minimal example showing this bug. The system has 6-fold rotation symmetry around the z-axis, but it is not found. (Interestingly, the continuous rotation symmetry is found.)
ham = """
(C + D1*k_z**2 + D2*(k_x**2+k_y**2))*eye(4)
+ kron(sigma_x,sigma_x)*A2*k_y
+ kron(sigma_x,sigma_y)*(-A2*k_x)
+ kron(sigma_y,eye(2))*A1*k_z
+ kron(sigma_z, eye(2))*(M+B1*k_z**2+B2*(k_x**2+k_y**2))
+ m5*kron(sigma_x,sigma_z)
"""
display(qsymm.sympify(ham))
H = qsymm.Model(ham, momenta=['k_x', 'k_y','k_z'])
# candidates = qsymm.groups.cubic()
candidates = qsymm.groups.hexagonal(dim=3)
qsymm.symmetries(H, candidates, continuous_rotations=True, prettify=True)