# Mixed site set with conserved total quantum number

**URL:** <https://itensor.discourse.group/t/mixed-site-set-with-conserved-total-quantum-number/1800>\
**Category:** DMRG and Numerical Methods\
**Tags:** dmrg, mps, qn\
**Created:** [June 12, 2024, 10:56am UTC](https://itensor.discourse.group/t/mixed-site-set-with-conserved-total-quantum-number/1800 "2024-06-12T10:56:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anaskura](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/anaskura/32/268_2.png) [@anaskura](https://itensor.discourse.group/u/anaskura)\
**Post date:** [June 12, 2024, 10:56am UTC](https://itensor.discourse.group/t/mixed-site-set-with-conserved-total-quantum-number/1800/1 "2024-06-12T10:56:39Z")

</div>

Hi there!

I have a question about Mixed state that involve electrons and spin-1/2. I have a system with electrons and one spin-1/2. I would like to conserve fermion parity for electrons only and for the whole system z component of total spin S^z\_{tot}= S\_{el}^z + S\_{S=1/2}^z.

When setting conserve\_sz = true separately for electrons and S=1/2 site , does the code conserve Sz for each of these sectors separately or it coserves total Sz of the whole system?

This is how I define sites and then to fix Sz sector I initialise the MPS with corresponding spin configuration, but I am not sure if this conserves total\_sz, at least when I later evolve my state with the Hamiltonian there is no difference between “conserved\_sz = true” and “conserved\_sz = false” cases.

```julia

  function create_sites(N)
    sites = Vector{Index}(undef,N)
    Nimp = Int64((N+1)/2)
    for n=1:N
      if n < Nimp || n > Nimp
        sites[n] = siteind("Electron"; addtags="n=$n",conserve_nfparity=true, conserve_sz = true)
      else
        sites[n] = siteind("S=1/2"; addtags="n=$n",conserve_sz = true)
      end
    end
    return sites, Nimp
  end  

```

Thanks in advance!

---

<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:** [June 12, 2024, 3:17pm UTC](https://itensor.discourse.group/t/mixed-site-set-with-conserved-total-quantum-number/1800/2 "2024-06-12T15:17:54Z")

</div>

It’s a good question.

1. First, a small Julia thing is that instead of writing `Int((N+1)/2)` what you are really trying to do there is integer division. For this you can use the `÷` operator (type `\div` then hit tab to make this) or you can call `div(N+1,2)` to call the same function.

2. Then, to your Sz question, the way our system works is that quantum numbers are given names which are strings such as “NfParity” and “Sz”. When you set `conserve_sz=true` in each siteinds call, our system defaults to using the name “Sz” for both the “S=1/2” and “Electron” site types. So then these two sources of Sz will be treated the same and allowed to mix together, with the result that only the total Sz = Sz\_electron + Sz\_spin will be conserved, not separately.

A good way to check what quantum numbers have been associated to your sites (degrees of freedom) is to print out some of the site indices. When I do this with your above code I get a printout like:

```auto
(dim=4|id=157|"Electron,Site,n=3") <Out>
 1: QN(("NfParity",0,-2),("Sz",0)) => 1
 2: QN(("NfParity",1,-2),("Sz",1)) => 1
 3: QN(("NfParity",1,-2),("Sz",-1)) => 1
 4: QN(("NfParity",0,-2),("Sz",0)) => 1
(dim=4|id=480|"Electron,Site,n=4") <Out>
 1: QN(("NfParity",0,-2),("Sz",0)) => 1
 2: QN(("NfParity",1,-2),("Sz",1)) => 1
 3: QN(("NfParity",1,-2),("Sz",-1)) => 1
 4: QN(("NfParity",0,-2),("Sz",0)) => 1
(dim=2|id=179|"S=1/2,Site,n=5") <Out>
 1: QN("Sz",1) => 1
 2: QN("Sz",-1) => 1
(dim=4|id=785|"Electron,Site,n=6") <Out>
 1: QN(("NfParity",0,-2),("Sz",0)) => 1
 2: QN(("NfParity",1,-2),("Sz",1)) => 1
 3: QN(("NfParity",1,-2),("Sz",-1)) => 1
 4: QN(("NfParity",0,-2),("Sz",0)) => 1

```

And from the above you can see that the spin site and electron site both contain spin quantum numbers with the same name of “Sz”, so those will be conserved only in total, and not separately.

If you did however want to conserve them separately, we have optional keywords that let you customize the name of the quantum numbers. Let me know if you want to do that, otherwise you should be good to go.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/d3072b13e047cd06df7f3981547c0917d940dfa4.png) [@system](https://itensor.discourse.group/u/system)\
**Post date:** [June 22, 2024, 3:18pm UTC](https://itensor.discourse.group/t/mixed-site-set-with-conserved-total-quantum-number/1800/3 "2024-06-22T15:18:51Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
