State Construction with conserve_qns = true

Hey all,

I am running a TEBD code and I have incurred a bug. The error flagged is as follows: LoadError: Eigen currently only supports block diagonal matrices.

The core of the bug is because of the following:

I first construct a product state of two bell states (up to normalization),

\ket{\psi_0} = (\ket{\upuparrows} + \ket{\downdownarrows}) \otimes (\ket{\upuparrows}+\ket{\downdownarrows})

My code seems to behave so far. However, when I act on this state by applying Z gates to construct the following state

\ket{\psi_1} = (\ket{\upuparrows} - \ket{\downdownarrows}) \otimes (\ket{\upuparrows}-\ket{\downdownarrows}),

it spits out the error I mentioned on the first line of the post. I also tried to construct the state in a brute force way just to be sure:

let 
    s = siteinds("S=1/2", 4, conserve_qns = true)
    upupupup = productMPS(s, ["Up", "Up", "Up", "Up"])
    upupdndn = productMPS(s, ["Up", "Up", "Dn", "Dn"])
    dndnupup = productMPS(s, ["Dn", "Dn", "Up", "Up"])
    dndndndn = productMPS(s, ["Dn", "Dn", "Dn", "Dn"])
    bellproduct = upupupup-upupdndn-dndnupup+dndndndn
    @show bellproduct
    @show flux(upupupup-upupdndn-dndnupup+dndndndn)
end 

I run into the same error (ie Eigen currently only supports block diagonal matrices.) on the line bellproduct = upupupup-upupdndn-dndnupup+dndndndn . I think this has to do with me enforcing conserve_qns = true.

I have a couple of questions:

  1. I get how the flux of the first state \ket{\psi_0} is 4 (using this) . But why is the flux not evaluating the total Sz of the state and instead something else altogether that I do not understand.

  2. Why is there an error as soon as I construct state \ket{\psi_1} ?

Please let me know!

The state upupupup has a flux of 4 but upupdndn has a flux of 0, so that’s probably why you are getting that error (it’s not well defined to add MPS with different fluxes).

But then why does upupupup+upupdndn+dndnupup+dndndndn (ie constructing $$\ket{\psi_0}$$ work well? I do the same thing there right?

I’m not sure, that may be an accident that it works.

Hi kk85,
If you add the line ITensors.enable_debug_checks() to the top of your example code, you get a more helpful error message. The message is ERROR: LoadError: Fluxes not all equal.

So it confirms what Matt said about these states not all having the same fluxes (in this case meaning not the same total S^z). With sites that conserve QN’s, it’s not allowed to add states with different total QN (different total QN flux).

If you are working with or creating states which don’t have a well-defined total S^z, trying to conserve it isn’t going to help anyway (i.e. isn’t going to be possible to make your code run faster or anything) so most likely you should just not use it.