Square terms in the Hamiltonian

Hi guys,

I am trying to make a MPO using OpSum() for my desired Hamiltonian, but we have a square term in our Hamiltonian as bellow.

H = \sum_{j=1}^{N} [a^-_j \otimes a^+_j - a^+_j \otimes a^-_j]^2

I know how to compute the bracket expression, my question is just about square computation.


using ITensors
N = 10;
sites = siteinds("Fermion",N);
ampo = OpSum();
for j=1:N
    ampo += "C",j,"Cdag",j
    ampo -= "Cdag",j,"C",j
end

So now my question is that
In general, how could we compute any square terms in the Hamiltonian using ITensor.jl?

Thanks

Hi Amin, thanks for the question. You can square operator that act on the same sites like this:

os = OpSum()
os += "A * B",j

where “A” and “B” are two operator names and you want them to both act on site j. There isn’t support for squaring expressions involving operators acting on different sites within OpSum as far as I know, but it doesn’t look like you need that in your case anyway.

Does that answer the question in your case? I notice your operators have superscripts a^- and a^+ so they might be different from the “C” operator for spinless fermions, which is what “Fermion” sites represent? Just asking to make sure.

Hi Miles,
Thanks for your prompt reply.

Before addressing my main problem, I should mention you’re right, maybe I have to change my site’s type!?
Our system is a 1-D lattice whose sites contain two fermions (particle and antiparticle) that after using Jordan-Wigner transformation I reach the Hamiltonian (that I wrote above) .So In this case I’m not sure which one I should use, “Fermion” or “Electron” site?

Now for the first part of the question, I appreciate your suggestions but I get error when I use your trick. Please let me know did I get your point correctly or not by another simple example as below.
Let’s work on simple Hamiltonian like:

\sum_{j=1}^{N} [\sigma_j^x \otimes \sigma_j^z - \sigma_j^z \otimes \sigma_j^x]^2

In this case, considering your response I should select A and B as follow

A = [(\sigma_j^x \otimes \sigma_j^z) -(\sigma_j^z \otimes \sigma_j^x)] \\ B = [(\sigma_j^x \otimes \sigma_j^z) - (\sigma_j^z \otimes \sigma_j^x)]

By making this choice I will get some errors.
How can I handle the minus sign in the middle of expression?

Here I have two sample codes, the first one does not make any errors but it’s not my subject, and the other one that is my desired expression makes some errors

using ITensors
N = 4;
sites = siteinds("S=1/2",N)
ampo = OpSum()
for j in 1:N
    ampo += "Sx*Sz",j
    ampo -= "Sz*Sx",j
end
H = MPO(ampo, sites)
psi0 = randomMPS(sites,10)
sweep = Sweeps(3)
setmaxdim!(sweep,10,10,20)
setcutoff!(sweep,1E-10)
energy, psi = dmrg(H,psi0,sweep)

No error.

using ITensors
N = 4;
sites = siteinds("S=1/2",N)
ampo = OpSum()
for j in 1:N
    ampo += "((Sx*Sz)-(Sz*Sx)) * ((Sx*Sz)-(Sz*Sx))"
end
H = MPO(ampo, sites)
psi0 = randomMPS(sites,10)
sweep = Sweeps(3)
setmaxdim!(sweep,10,10,20)
setcutoff!(sweep,1E-10)
energy, psi = dmrg(H,psi0,sweep)

And this is its error type
``MethodError: no method matching +(::OpSum, ::String)"

Sorry about this long message.
Thank you in advance for your time

Hi, so I guess I’m confused by the notation \sigma^x_j \otimes \sigma^z_j. If the operators act on the same site j then are you wanting to take a regular operator or matrix product like \sigma^x_j \sigma^z_j ? Or are you wanting a tensor product \sigma^x_j \otimes \sigma^z_{j'}, which would be between two operators acting on different sites or vector spaces labeled j and j'? Basically are your operators acting on the same site or different sites?

Hi, in my case both operators \sigma_j^x and \sigma_j^z are acting on the same site.
They act on the same site but on different subspaces (one of them acts on particle, and the other one acts on antiparticle). So my local Hilbert space is 4. Therefore in matrix representation we need a 4 \times 4 matrix for each site.

My notation \sigma_j^x \otimes \sigma_j^x means tensor product of two operators but on the same site.

Thanks

Thanks for clarifying, and that makes perfect sense. So looking at the other part of your followup, I see the issue: when I mentioned that OpSum allows expressions like “Sx * Sz”, those are the only expressions it allows within strings. More complicated algebra like adding and subtracting operators isn’t supported within those operator name strings (for that we would need to implement a whole symbolic algebra system).

So to input an operator like A_j B_j - C_j D_j you can do:

ampo += "A * B",j
ampo += -1,"C * D",j

where you do the addition or subtraction outside the strings, by adding terms into the OpSum with the coefficients you want.


Regarding the question of what kind of local Hilbert space you need, I would say that neither “Fermion” nor “Electron” by themselves are a perfect fit. But the simplest thing you could do without needing to define a custom Hilbert space is to treat even sites of your system as particle sites and odd sites as antiparticle sites and then use the “Fermion” site type which represents a spinless fermion on each site (local dimension 2). The advantage of this is you could use all of the predefined operators for the “Fermion” site type. As a bonus it also might simplify some of your operators like a^+_j a^-_j since they would now act on different sites a^+_j a^-_j \rightarrow c_i c_{i+1}.

1 Like

Hi
Your solution was so useful, also thanks for your suggestion about choosing lattice sites as “Fermion” type.

1 Like