How to construct chiral operators by local wave functions in one-dimensional chiral system?

,

Hello everyone!

Here I have a one-dimensional system with two sublattices in each unit cell which posses chiral symmetry. That is

\Gamma H\Gamma=-H

H is the hamiltonian of the one-dimensional system, and \Gamma is a local, unitary and Hermitian operator.
One can construct chiral operators by projectors to sublattice A and B.

\Gamma =\hat{P}_A-\hat{P}_B=\sum_i^{N}(\ket{\psi}_{ia}\bra{\psi}_{ia}-\ket{\psi}_{ib}\bra{\psi}_{ib})

I construct a 2N-long one-dimensional sites, in which N is the number of unit cells and odd sites represent sublattice A and even sites represent sublattice B.

My question is how to construct an MPO by local state of MPS psi[i] in purpose to do measurements like mean chiral displacement.

I have tried the following way.

julia> function Gamma(psi,N)
                   GammaOp=ITensor()
                   for i=1:N
                       GammaOp+=psi[2*i-1]*psi[2*i-1]'
                       GammaOp-=psi[2*i]*psi[2*i]'
                   end

                   return GammaOp
               end
Gamma (generic function with 1 method)

julia> Gamma(psi,3)
ERROR: DimensionMismatch: cannot subtract ITensors with different numbers of indices
Stacktrace:
 [1] -(A::ITensor, B::ITensor)
   @ ITensors C:\Users\Wang\.julia\packages\ITensors\4aoLl\src\itensor.jl:1840
 [2] Gamma(psi::MPS, N::Int64)
   @ Main .\REPL[54]:5
 [3] top-level scope
   @ REPL[55]:1

Also, I want to ask how to convert a local wavefunction of MPS to a matrix.
Function matrix() indeed works for the first and last site of MPS, but not other sites.

julia> matrix(psi[1])
5×1 Matrix{Float64}:
0.0
1.0
0.0
0.0
0.0

julia> matrix(psi[2])
ERROR: DimensionMismatch:
Stacktrace:
[1] matrix(T::ITensor)
  @ ITensors C:\Users\Wang\.julia\packages\ITensors\4aoLl\src\tensor_operations\permutations.jl:182
[2] top-level scope
  @ REPL[57]:1

Thank you so much !