Site dependent Customized Operator

Hi,

  1. I want to introduce new operators in sitetype=“Electron” to find out the two point correlation. But the operator is different on alternate site. The question is how to define site dependent operators?

  2. How to take product of two operators?

  3. How to see the matrix form of the inbuilt operators (let’s say “Cup” or “Cdn”). I can check them elementwise but if at once I want see the whole matrix (4*4), how to do that?

Thank you…

  1. I would recommend just specifying the operator and then choosing the correct sites it runs over. For example if using correlation_matrix has a keyword argument sites.
  2. There are lots of ways to this, can you be more specific on what kinds of operators and what you want to use them for?
  3. If you want to see the matrix form, you can see the source code here ITensors.jl/src/lib/SiteTypes/src/sitetypes/electron.jl at main · ITensor/ITensors.jl · GitHub
    Or you can use @show
julia> @show op("Cup",sites[1])
op("Cup", sites[1]) = ITensor ord=2
Dim 1: (dim=4|id=964|"Electron,Site,n=1")'
Dim 2: (dim=4|id=964|"Electron,Site,n=1")
NDTensors.Dense{Float64, Vector{Float64}}
 4×4
 0.0  1.0  0.0  0.0
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  1.0
 0.0  0.0  0.0  0.0
ITensor ord=2 (dim=4|id=964|"Electron,Site,n=1")' (dim=4|id=964|"Electron,Site,n=1")
NDTensors.Dense{Float64, Vector{Float64}}

The arrangement of the data might not be how you like it though, so you can specify the index ordering and convert the ITensor to an array as well

julia>  array(op("Cup",sites[1]),sites[1],sites[1]')
4×4 Matrix{Float64}:
 0.0  0.0  0.0  0.0
 1.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0
 0.0  0.0  1.0  0.0

Regarding 1, about making totally site-dependent operators, you can always just make them “by hand” by doing something like this:

matrix_elements = [a b; c d]
operator = ITensor(matrix_elements, sites[j] , sites[j]')

That would make an ITensor with whichever entries you like that is like the operators returned by our op function. The downside is that it does not, however, let you use such an operator in our OpSum system.

If you do need site-dependent operators in OpSum or something like correlation_matrix or expect, can you give a small example of what you are trying to do?

Thank you very much ryanlevy for your replies.

  1. I quite did not understand your answer because of my lack of information may be . Let me rephrase my question.
    Lets say, I have a chain with customized operator like AAAAAAA… where A=Ao(at odd site) and A=Ae(at even site).
    So is there a way like simple condition problem.
    (if site = odd
    A = Ao
    else
    A= Ae
    end). to define the operators ??

The suggestion you have recommended, can you please provide simple code over it because I did not use “sites” argument for “correlation_matrix” before??

  1. In case of “Electron site type”, if I want to see the multiplication of lets say cup*cup , how to do that?

  2. I understood it.

Thank you very much

Thanks Miles for your reply.

I am working with sitetype = “Electron”. I am adding one operator(A) in it. I want to find out correlation_matrix(psi,“A”,“A”). In this A=Ao at odd site and A=Ae at even site. So how do I do that?

Hi!
1)You can define a custom operator that differ between even and odd site. Maybe something like this will work.

function ITensors.op(::OpName"c_custom", ::SiteType"Electron", s1::Index)

    # Get the site location
    loc=parse(Int, match(r"n=(\d+)", string(tags(s1)))[1])
    if(loc%2==0)
        return op("Cdagup", s1)
    else
        return op("Cup", s1)
    end

end


let 
    N = 10
    sites = siteinds("Electron",N)
    psi=randomMPS(sites)

    opM=op("c_custom",sites[6])
    @show(opM)

    corr_mat = correlation_matrix(psi, "c_custom", "c_custom"; sites=4:7);
    @show(stdout,"text/plain",corr_mat)

    
end

Here, sites tell you for which sites the correlation matrix need to be calculated.
I am not sure if there is an inbuilt function to get the location from the siteindex object. This uses some regex to obtain site location from tag. Also, I am not exactly sure whether the inbuilt correlation_matrix will handle the JW strings for this custom operator properly. Please do a check with ED.

Did you mean to ask that you have some custom operator in place of Cup? You can define that operator too in a similar fashion by setting the appropriate elements in an itensor.

  1. It may depend on your purpose. I guess by multiplication you meant on the same site (matrix multiplication) and not Kronecker Product. If you want to simply see the elements, you can just convert the operators to a matrix and take their product.
matrix(op("Cup",sites[6]))*matrix(op("Cup",sites[6]))

Note the exact representation depends on basis ordering.

The approach by @sandipanmanna should work. Though it is not an ideal approach, but definitely makes sense.

I think this is just a case we had not planned for with the correlation_matrix function, and in the future we may want to offer an interface where the user can provide a function that the code will call to construct an operator which can be custom for each site.

Another approach that could work well for you is simply to open up the source code for the correlation_matrix function, make a new function based on it, and modify it to suit your purpose.