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?
How to take product of two operators?
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?
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.
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?
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?
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??
In case of “Electron site type”, if I want to see the multiplication of lets say cup*cup , how to do that?
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.
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.
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.