Coverage for kwant/physics/symmetry.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Copyright 2011-2016 Kwant authors. # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at # http://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at # http://kwant-project.org/authors.
"""A collection of discrete symmetries and conservation laws.
Parameters ---------- projectors : iterable of rectangular or square sparse matrices Projectors that block-diagonalize the Hamiltonian. time_reversal : square sparse matrix The unitary part of the time-reversal symmetry operator. particle_hole : square sparse matrix The unitary part of the particle-hole symmetry operator. chiral : square sparse matrix The chiral symmetry operator.
Notes ----- Whenever one or more discrete symmetry is declared in conjunction with a conservation law, the symmetry operators and projectors must be declared in canonical form. This means that each block of the Hamiltonian is transformed either to itself by a discrete symmetry or to a single other block.
More formally, consider a discrete symmetry S. The symmetry projection that maps from block i to block j of the Hamiltonian with projectors :math:`P_i` and :math:`P_j` is :math:`S_{ji} = P_j^+ S P_i`. If :math:`S_{ji}` is nonzero, a symmetry relation exists between blocks i and j. Canonical form means that for each j, the block :math:`S_{ji}` is nonzero at most for one i, while all other blocks vanish.
If the operators are not in canonical form, they can be made so by further splitting the Hamiltonian into smaller blocks, i.e. by adding more projectors. """ chiral=None): # Normalize format "sparse matrices.")
for symm in symms]
"should be equal to identity.")
# Auto-compute a missing symmetry. # Product of particle hole with itself to get the sign right. particle_hole).dot(chiral.conj())) chiral).dot(time_reversal))
"{}unitary.".format(name, "anti" * conj)) (conj and almost_identity(-symm_squared))): "{}1.".format(name, "±" * conj))
for p in projectors] projector in projectors)):
# Check that the symmetries and conservation law are in canonical # form. In the projector basis, each discrete symmetry should have # at most one nonzero block per row. np.any(abs(p_hc.dot(symm).dot( (cond_conj(p_j, conj))).data > 1e-7)) for p_j in projectors) 'form: see DiscreteSymmetry ' 'documentation.')
"""Check if a matrix satisfies the discrete symmetries.
Parameters ---------- matrix : sparse or dense matrix If rectangular, it is padded by zeros to be square.
Returns ------- broken_symmetry : string or ``None`` One of "Conservation law", "Time reversal", "Particle-hole", "Chiral": the symmetry broken by the matrix. If the matrix breaks more than one symmetry, returns only the first failed check. """ # Extra transposes are to enforse sparse dot product in case matrix is # dense. else:
self.particle_hole, self.chiral)[item] |