quspin.operators.commutator

quspin.operators.commutator(H1, H2)[source]

Calculates the commutator of two Hamiltonians \(H_1\) and \(H_2\).

\[[H_1,H_2] = H_1 H_2 - H_2 H_1\]
Parameters:
H1obj

numpy.ndarray or hamiltonian class object to define the Hamiltonian operator as a matrix.

H2obj

numpy.ndarray or hamiltonian class object to define the Hamiltonian operator as a matrix.

Returns:
obj

Commutator: \([H_1,H_2] = H_1 H_2 - H_2 H_1\)

Examples

The following script shows how to compute the commutator of two hamiltonian objects.

 1from quspin.basis import spin_basis_1d  # Hilbert space spin basis
 2from quspin.tools.measurements import diag_ensemble
 3import numpy as np  # generic math functions
 4
 5#
 6L = 12  # syste size
 7# coupling strenghts
 8J = 1.0  # spin-spin coupling
 9h = 0.8945  # x-field strength
10g = 0.945  # z-field strength
11# create site-coupling lists
12J_zz = [[J, i, (i + 1) % L] for i in range(L)]  # PBC
13x_field = [[h, i] for i in range(L)]
14z_field = [[g, i] for i in range(L)]
15# create static and dynamic lists
16static_1 = [["x", x_field], ["z", z_field]]
17static_2 = [["zz", J_zz], ["x", x_field], ["z", z_field]]
18dynamic = []
19# create spin-1/2 basis
20basis = spin_basis_1d(L, kblock=0, pblock=1)
21# set up Hamiltonian
22H1 = hamiltonian(static_1, dynamic, basis=basis, dtype=np.float64)
23H2 = hamiltonian(static_2, dynamic, basis=basis, dtype=np.float64)
24###### calculate commutator
25comm = commutator(H1, H2)