# Can create uncharged operators and states with "conserve\_qns=true"

**URL:** <https://itensor.discourse.group/t/can-create-uncharged-operators-and-states-with-conserve-qns-true/1361>\
**Category:** ITensor Julia Questions\
**Tags:** julia\
**Created:** [December 15, 2023, 5:35am UTC](https://itensor.discourse.group/t/can-create-uncharged-operators-and-states-with-conserve-qns-true/1361 "2023-12-15T05:35:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hans20253](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@hans20253](https://itensor.discourse.group/u/hans20253)\
**Post date:** [December 15, 2023, 5:35am UTC](https://itensor.discourse.group/t/can-create-uncharged-operators-and-states-with-conserve-qns-true/1361/1 "2023-12-15T05:35:15Z")

</div>

I noticed the following way to create \sigma^x does not flag any errors (I’m using v0.3.34),

```auto
s = siteinds("S=1/2",1;conserve_qns=true)
X = op("S+",s[1])+op("S-",s[1])

```

I found that `flux(X)` is equal to 2 which would suggest that only the top right entry should be non-zero (like S^+) but I mapped this to a dense array and I get the correct expression for X. I get no errors when performing multiplication or acting on other states. This also works when you increase the number of qubits.

I can also create the (unnormalized) |+\rangle eigenstate of X in a similar fashion by doing:

```auto
psi = state("Up",s[1])+state("Dn",s[1])

```

This also throws no error as well and `flux(psi)` equals 1.

**Q** : Why does this work?

---

<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:31pm UTC](https://itensor.discourse.group/t/can-create-uncharged-operators-and-states-with-conserve-qns-true/1361/2 "2023-12-15T15:31:02Z")

</div>

Only some operations check for consistent fluxes, but also only if debug checks are enabled. So if you do:

```julia
ITensors.enable_debug_checks()
flux(X)

```

then it will error saying the flux is not well defined.

We made some judgement call on a case-by-case basis about which functions check for consistent fluxes (and sometimes only when debug checks are enabled) based on performance, for example if checking the flux could have similar cost to the operation itself.

In the case of adding two ITensors, if you are adding up tensors with very small blocks, checking the flux could cost as much as adding the two ITensors.

---

<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:33pm UTC](https://itensor.discourse.group/t/can-create-uncharged-operators-and-states-with-conserve-qns-true/1361/3 "2023-12-15T15:33:06Z")

</div>

Also even with debug checks disabled, you can explicitly check that the flux is consistent with `ITensors.checkflux(X)`.
