Coverage for kwant/rmt.py : 78%

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-2013 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.
"""Return the value of time-reversal symmetry squared (1, 0, or -1)""" raise ValueError('Non-existent symmetry class.') else:
"""Return the value of particle-hole symmetry squared (1, 0, or -1)""" raise ValueError('Non-existent symmetry class.') else:
"""Return 1 if the system has chiral symmetry, and 0 otherwise.""" else:
'AII': [[0, 1j], [-1j, 0]], 'CII': [[0, 0, 1j, 0], [0, 0, 0, 1j], [-1j, 0, 0, 0], [0, -1j, 0, 0]], 'DIII': [[0, 1j], [-1j, 0]]} 'CII': [[0, 0, 1j, 0], [0, 0, 0, -1j], [-1j, 0, 0, 0], [0, 1j, 0, 0]], 'D': [[1]], 'DIII': [[0, 1], [1, 0]], 'BDI': [[1]]}
"""Make a n * n random Gaussian Hamiltonian.
Parameters ---------- n : int Size of the Hamiltonian. It should be even for all the classes except A, D, and AI, and in class CII it should be a multiple of 4. sym : one of 'A', 'AI', 'AII', 'AIII', 'BDI', 'CII', 'D', 'DIII', 'C', 'CI' Altland-Zirnbauer symmetry class of the Hamiltonian. v : float Variance every degree of freedom of the Hamiltonian. The probaility distribution of the Hamiltonian is `P(H) = exp(-Tr(H^2) / 2 v^2)`. rng: int or rng (optional) Seed or random number generator. If no 'rng' is provided the random number generator from numpy will be used.
Returns ------- h : numpy.ndarray A numpy array drawn from a corresponding Gaussian ensemble.
Notes ----- The representations of symmetry operators are chosen according to Phys. Rev. B 85, 165409.
Matrix indices are grouped first according to orbital number, then sigma-index, then tau-index.
Chiral (sublattice) symmetry C always reads: H = -tau_z H tau_z. Time reversal symmetry T reads: AI: H = H^*. BDI: H = tau_z H^* tau_z. CI: H = tau_x H^* tau_x. AII, CII: H = sigma_y H^* sigma_y. DIII: H = tau_y H^* tau_y. Particle-hole symmetry reads: C, CI: H = -tau_y H^* tau_y. CII: H = -tau_z sigma_y H^* tau_z sigma_y. D, BDI: H = -H^*. DIII: H = -tau_x H^* tau_x.
This implementation should be sufficiently efficient for large matrices, since it avoids any matrix multiplication. """ raise ValueError('Unknown symmetry type.') ' chosen symmetry class.') else:
raise ValueError('Matrix dimension should be a multiple of 4 in' 'symmetry class CII.')
# define random number generator
# Generate a Gaussian matrix of appropriate dtype. else:
# Ensure Hermiticity.
# Ensure Chiral symmetry.
# Ensure the necessary anti-unitary symmetry. sigma_z)
"""Make a n * n matrix belonging to a symmetric circular ensemble.
Parameters ---------- n : int Size of the matrix. It should be even for the classes C, CI, CII, AII, DIII (either T^2 = -1 or P^2 = -1). sym : one of 'A', 'AI', 'AII', 'AIII', 'BDI', 'CII', 'D', 'DIII', 'C', 'CI' Altland-Zirnbauer symmetry class of the matrix. charge : int or None Topological invariant of the matrix. Should be one of 1, -1 in symmetry classes D and DIII, should be from 0 to n in classes AIII and BDI, and should be from 0 to n / 2 in class CII. If charge is None, it is drawn from a binomial distribution with p = 1 / 2. rng: int or rng (optional) Seed or random number generator. If no 'rng' is passed, the random number generator provided by numpy will be used.
Returns ------- s : numpy.ndarray A numpy array drawn from a corresponding circular ensemble.
Notes ----- The representations of symmetry operators are chosen according to Phys. Rev. B 85, 165409, except class D.
Matrix indices are grouped first according to channel number, then sigma-index.
Chiral (sublattice) symmetry C always reads: s = s^+. Time reversal symmetry T reads: AI, BDI: r = r^T. CI: r = -sigma_y r^T sigma_y. AII, DIII: r = -r^T. CII: r = sigma_y r^T sigma_y. Particle-hole symmetry reads: CI: r = -sigma_y r^* sigma_y C, CII: r = sigma_y r^* sigma_y D, BDI: r = r^*. DIII: -r = r^*.
This function uses QR decomposition to probe symmetric compact groups, as detailed in arXiv:math-ph/0609050. For a reason as yet unknown, scipy implementation of QR decomposition also works for symplectic matrices. """
raise ValueError('Unknown symmetry type.')
# Prepare a real, complex or symplectic Gaussian matrix # Real case. # Complex case. # Symplectic case. else: # p(sym) == -1
# Generate a random matrix with proper electron-hole symmetry. # This matrix is a random element of groups O(N), U(N), or USp(N). raise RuntimeError('QR decomposition symmetry failure.')
# Ensure proper topological invariant in classes D and DIII. if charge not in (-1, 1): raise ValueError('Impossible value of topological invariant.') det = np.linalg.det(s) if sym == 'DIII': det *= (-1) ** (n // 2) if (charge > 0) != (det > 0): idx = np.arange(n) idx[-1] -= 1 idx[-2] += 1 s = s[idx]
# Add the proper time-reversal symmetry:
# Add the chiral symmetry: elif (0 <= charge <= n) and int(charge) == charge: diag = np.array(charge * [-1] + (n - charge) * [1]) else: raise ValueError('Impossible value of topological invariant.') else: elif (0 <= charge <= n // 2) and int(charge) == charge: charge *= 2 diag = np.array(charge * [-1] + (n - charge) * [1]) else: raise ValueError('Impossible value of topological invariant.')
|