quspin.tools.misc.project_op
- quspin.tools.misc.project_op(Obs, proj, dtype=<class 'numpy.complex128'>)[source]
Projects observable onto symmetry-reduced subspace.
This function takes an observable Obs and a reduced basis or a projector proj, and projects Obs onto that reduced basis.
- Parameters:
- Obs:obj:
Operator to be projected, either a numpy.ndarray or a hamiltonian object.
- proj:obj:
Either one of the following:
basis object with the basis of the Hilbert space after the projection.
numpy.ndarray: a matrix which contains the projector.
Projectors can be calculated conveniently using the function method basis.get_proj().
- dtypetype, optional
Data type of output. Default is numpy.complex128.
- Returns:
- dict
Dictionary with keys
“Proj_Obs”: projected observable Obs.
Examples
The following example shows how to project an operator \(H_1=\sum_j hS^x_j + g S^z_j\) from the symmetry-reduced basis to the full basis.
1from quspin.basis import spin_basis_1d # Hilbert space spin basis 2from quspin.tools.measurements import project_op 3import numpy as np # generic math functions 4 5# 6L = 12 # syste size 7# coupling strenghts 8h = 0.8945 # x-field strength 9g = 0.945 # z-field strength 10# create site-coupling lists 11x_field = [[h, i] for i in range(L)] 12z_field = [[g, i] for i in range(L)] 13# create static and dynamic lists 14static_1 = [["x", x_field], ["z", z_field]] 15dynamic = [] 16# create spin-1/2 basis 17basis = spin_basis_1d(L, kblock=0, pblock=1) 18# set up Hamiltonian 19H1 = hamiltonian(static_1, dynamic, basis=basis, dtype=np.float64) 20# compute eigensystem of H1 21E1, V1 = H1.eigh() 22psi1 = V1[:, 14] # pick any state as initial state 23# 24# project Hamiltonian from `kblock=0` and `pblock=1` onto full Hilbert space 25proj = basis.get_proj(np.float64) # calculate projector 26H1_full = project_op(H1, proj, dtype=np.float64)["Proj_Obs"] 27print( 28 "dimenions of symmetry-reduced and full Hilbert spaces are %i and %i." 29 % (H1.Ns, H1_full.Ns) 30)