correlation matrix of custom operators

Hello,

this is my first post so forgive me all the mistakes. I am reaching out to you because I can not get the custom operator working.

I have run a test code by defining the operator the same as "Cdagup" and "Cup"


function ITensors.op(::OpName"c_dagup", ::SiteType"Electron", s1::Index)
    return op("Cdagup", s1)
end

function ITensors.op(::OpName"c_up", ::SiteType"Electron", s1::Index)
    return op("Cup", s1)
end

and then I calculated

a_matrix=correlation_matrix(psi, "Cdagup", "Cup")

and

b_matrix=correlation_matrix(psi, "c_dagup", "c_up")

only the diagonal matrix elements are the same for the above two matrices.

Do you have any idea why this occurs?

Thanks in advance for any help,
Lucy

Hi Lucy, thanks for the question. While I’m not immediately sure why you’re seeing that difference, one strong possibility is that you will also need to define a special method called has_fermion_string for these specific operators to tell our OpSum system to treat these specially, since they anticommute as operators.

If you take a look at this file in the ITensor source code:
https://github.com/ITensor/ITensors.jl/blob/main/src/physics/site_types/electron.jl
you’ll see at the very bottom how those has_fermion_string functions are defined.

Please try defining them for your new operators and I’d be curious to hear if you now get the same result.

Following your suggestion, now I get the same result. Thank you so much for your prompt reply.

But I have another problem: what if the operator that I define is neither a fermion nor a boson?

Glad it worked.

I think I see what you’re asking, but the need for the fermion string is not really about whether the operator is a fermion or boson, per se, but more about whether the operator anticommutes with other operators in some “non-local” way. We could discuss some other examples if we need to.

The other notion, of an operator being “bosonic” isn’t really about bosons or even particles at all, but just the idea of an operator acting non-trivially on a certain vector space that makes up part of a larger vector space. In physics jargon, such an operator acts non-trivially on a “site” or small group of sites then as the identity (or trivially) on all the other sites. Basically it is just a “regular” local operator.

So all familiar spin operators (Sz, S+, S-, etc.) are “bosonic” as well as all local quantum gates (Hadamard, etc.) and so on. Also operators consisting of an even number of fermionic \hat{c} or \hat{c}^\dagger operators are “bosonic”, for example the number or density operator \hat{n} = \hat{c}^\dagger \hat{c}.

1 Like