quspin.tools.block_tools.block_diag_hamiltonian

quspin.tools.block_tools.block_diag_hamiltonian(blocks, static, dynamic, basis_con, basis_args, dtype, basis_kwargs={}, get_proj_kwargs={}, get_proj=True, check_symm=True, check_herm=True, check_pcon=True)[source]

Block-diagonalises a Hamiltonian obeying a symmetry.

The symmetry blocks are created via the argument ‘blocks’.

Parameters:
blockslist/tuple/iterator

Contains the symmetry blocks to construct the Hamiltonian with, as dictionaries.

staticlist

Static operator list used to construct the block Hamiltonians. Follows hamiltonian format.

dynamiclist

Dynamic operator list used to construct the block Hamiltonians. Follows hamiltonian format.

basis_conbasis

Basis constructor used to build the basis objects to create the block diagonal Hamiltonians.

basis_argstuple

This argument is passed as the first argument for basis_con. Contains all required arguments for the basis.

dtype‘type’

The data type (e.g. numpy.float64) to construct the Hamiltonian with.

get_projbool, optional

Flag which tells the function to calculate and return the projector to the symmetry-block subpace requested. Default is ‘True’.

basis_kwargsdict, optional

Dictionary of keyword arguments to add when calling basis constructor.

get_proj_kwargsdict, optional

Dictionary of keyword arguments for basis.get_proj() and basis.project_from().

check_symmbool, optional

Enable/Disable symmetry check of the operators for the first Hamiltonian constructed.

check_hermbool, optional

Enable/Disable hermiticity check of the operators for the first Hamiltonian constructed.

check_pconbool, optional

Enable/Disable particle conservation check of the operators for the first Hamiltonian constructed.

Returns:
tuple
Pscipy.sparse.csr

Projector to the symmetr-block subspace (e.g. Fourier transform in case of momentum blocks).

Hobj

hamiltonian object in block diagonal form.

Raises:
ValueError

If blocks is not a list of hamiltonian objects or a list of dictionaries containing the symmetry sectors.

Examples

The example below demonstrates how to to use the block_diag_hamiltonian() function to block-diagonalise the single-particle Hamiltonian

\[H=\sum_j (J+(-1)^j\delta J)b^\dagger_{j+1} b_j + \mathrm{h.c.} + \Delta(-1)^j b^\dagger_j b_j\]

with respect to translation symemtry. The Fourier transform is computed along the way.

 1from quspin.basis import boson_basis_1d  # Hilbert space fermion basis
 2from quspin.tools.block_tools import block_diag_hamiltonian  # block diagonalisation
 3import numpy as np  # generic math functions
 4
 5##### define model parameters #####
 6L = 6  # system size
 7J = 1.0  # uniform hopping contribution
 8deltaJ = 0.1  # bond dimerisation
 9Delta = 0.5  # staggered potential
10##### construct single-particle Hamiltonian #####
11# define site-coupling lists
12hop = [[-J - deltaJ * (-1) ** i, i, (i + 1) % L] for i in range(L)]  # PBC
13stagg_pot = [[Delta * (-1) ** i, i] for i in range(L)]
14# define static and dynamic lists
15static = [["+-", hop], ["-+", hop], ["n", stagg_pot]]
16dynamic = []
17# define basis
18basis = boson_basis_1d(L, Nb=1, sps=2)
19# build real-space Hamiltonian in full basis
20H = hamiltonian(static, dynamic, basis=basis, dtype=np.float64)
21# diagonalise real-space Hamiltonian
22E, V = H.eigh()
23print(np.around(H.toarray(), 2))
24##### compute Fourier transform and block-diagonal momentum-space Hamiltonian #####
25# define momentm blocks and basis arguments
26blocks = [
27    dict(Nb=1, sps=2, kblock=i, a=2) for i in range(L // 2)
28]  # only L//2 distinct momenta
29basis_args = (L,)
30# construct block-diagonal Hamiltonian
31FT, Hblock = block_diag_hamiltonian(
32    blocks,
33    static,
34    dynamic,
35    boson_basis_1d,
36    basis_args,
37    np.complex128,
38    get_proj_kwargs=dict(pcon=True),
39)
40# diagonalise momentum-space Hamiltonian
41Eblock, Vblock = Hblock.eigh()
42print(np.around(Hblock.toarray(), 2))