# How to call standard functions with quantum number preserving MPSs

**URL:** <https://itensor.discourse.group/t/how-to-call-standard-functions-with-quantum-number-preserving-mpss/238>\
**Category:** ITensor Julia Questions\
**Created:** [July 7, 2022, 9:27pm UTC](https://itensor.discourse.group/t/how-to-call-standard-functions-with-quantum-number-preserving-mpss/238 "2022-07-07T21:27:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![metapuff](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@metapuff](https://itensor.discourse.group/u/metapuff)\
**Post date:** [July 7, 2022, 9:27pm UTC](https://itensor.discourse.group/t/how-to-call-standard-functions-with-quantum-number-preserving-mpss/238/1 "2022-07-07T21:27:55Z")

</div>

I have been running into a few trivial issues with quantum number conservation which I am not sure how to fix by looking at the documentation. Say I have some spin-1 sites `sites = siteinds("S=1",N,conserve_sz=true)`, and I define a wavefunction by e.g. `psi = productMPS(sites,["Up" for i=1:N])`. A lot of the usual MPS operations, such as `expect(psi,"Sz")`, `orthogonalize!(psi,n)`, `correlation_matrix(psi,"Sz","Sz")`, etc, are throwing a method error:

` **ERROR:** MethodError: no method matching block(::Index{Vector{Pair{QN, Int64}}}, ::UInt64)`

This same error comes up when running DMRG with an initial state with definite flux like the psi defined above (of course using a Hamiltonian that preserves S^z). Does the above error mean that one needs to somehow `strip away’ the QN information when using these functions?

Thanks!

---

<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:** [July 7, 2022, 10:12pm UTC](https://itensor.discourse.group/t/how-to-call-standard-functions-with-quantum-number-preserving-mpss/238/2 "2022-07-07T22:12:37Z")

</div>

Thanks for the question. All of those functions you mentioned should work perfectly even for that type of MPS (with QN conserving tensors). For example, all of the code pasted below worked for me just now when I tested it.

Are you making some change to your wavefunction before you call those MPS operations on it? What version of ITensors.jl are you using and is it the latest one?

Here is the sample code that worked ok for me:

```auto
using ITensors

let
  N = 10
  sites = siteinds("S=1",N,conserve_sz=true)
  psi = productMPS(sites,["Up" for i=1:N])

  orthogonalize!(psi,N)
  orthogonalize!(psi,1)

  @show expect(psi,"Sz")
  C = correlation_matrix(psi,"Sz","Sz")
  display(C)

  return
end

```

---

<div class="post-metadata">

**Author:** ![metapuff](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@metapuff](https://itensor.discourse.group/u/metapuff)\
**Post date:** [July 7, 2022, 11:27pm UTC](https://itensor.discourse.group/t/how-to-call-standard-functions-with-quantum-number-preserving-mpss/238/3 "2022-07-07T23:27:00Z")

</div>

Ah, thank you, it was indeed a version problem. I had been using v0.3.10, back from April. Didn’t realize that things were changing that quickly — thanks!

---

<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:** [July 7, 2022, 11:44pm UTC](https://itensor.discourse.group/t/how-to-call-standard-functions-with-quantum-number-preserving-mpss/238/4 "2022-07-07T23:44:01Z")

</div>

Glad that fixed it!
