# State Construction with conserve\_qns = true

**URL:** <https://itensor.discourse.group/t/state-construction-with-conserve-qns-true/1364>\
**Category:** DMRG and Numerical Methods\
**Created:** [December 15, 2023, 2:51pm UTC](https://itensor.discourse.group/t/state-construction-with-conserve-qns-true/1364 "2023-12-15T14:51:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kk85](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@kk85](https://itensor.discourse.group/u/kk85)\
**Post date:** [December 15, 2023, 2:51pm UTC](https://itensor.discourse.group/t/state-construction-with-conserve-qns-true/1364/1 "2023-12-15T14:51:28Z")

</div>

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:

```auto
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](https://itensor.org/docs.cgi?page=book/block_sparse&vers=cppv3)) . 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!

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [December 15, 2023, 3:49pm UTC](https://itensor.discourse.group/t/state-construction-with-conserve-qns-true/1364/2 "2023-12-15T15:49:17Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![kk85](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@kk85](https://itensor.discourse.group/u/kk85)\
**Post date:** [December 15, 2023, 3:57pm UTC](https://itensor.discourse.group/t/state-construction-with-conserve-qns-true/1364/3 "2023-12-15T15:57:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [December 15, 2023, 4:00pm UTC](https://itensor.discourse.group/t/state-construction-with-conserve-qns-true/1364/4 "2023-12-15T16:00:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [December 15, 2023, 8:34pm UTC](https://itensor.discourse.group/t/state-construction-with-conserve-qns-true/1364/5 "2023-12-15T20:34:21Z")

</div>

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.
