# How to fix the number of fermions in DMRG

**URL:** <https://itensor.discourse.group/t/how-to-fix-the-number-of-fermions-in-dmrg/412>\
**Category:** DMRG and Numerical Methods\
**Tags:** julia, dmrg\
**Created:** [September 22, 2022, 5:07am UTC](https://itensor.discourse.group/t/how-to-fix-the-number-of-fermions-in-dmrg/412 "2022-09-22T05:07:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Verma](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@Verma](https://itensor.discourse.group/u/Verma)\
**Post date:** [September 22, 2022, 5:07am UTC](https://itensor.discourse.group/t/how-to-fix-the-number-of-fermions-in-dmrg/412/1 "2022-09-22T05:07:14Z")

</div>

I want to run DMRG code for quarter filling. I don’t know how to fix the number of fermion. If anyone can give some input on this , it will be helpful to me.  
Thanks

 ![Screenshot from 2022-09-21 19-54-08](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/5101564f4ec7a8ed732c61f51781968fbd744a69.png)

---

<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:** [September 22, 2022, 8:59pm UTC](https://itensor.discourse.group/t/how-to-fix-the-number-of-fermions-in-dmrg/412/2 "2022-09-22T20:59:20Z")

</div>

A good resource for how to fix the number of fermions is this tutorial on quantum number (QN) conserving DMRG:  
[https://itensor.github.io/ITensors.jl/stable/tutorials/QN\_DMRG.html](https://itensor.github.io/ITensors.jl/stable/tutorials/QN_DMRG.html)

Mainly you will need to do these two things:

1. call `siteinds` like this `siteinds("Fermion",N; conserve_qns=true)`
2. initialize your MPS by passing a “state” array which is an array of strings giving a representative state of each site. The number of fermions you put into this state array will always be kept the same throughout the DMRG calculation. The tutorial linked above gives more details and examples about this. The allowed “states” for a “Fermion” site type are “0” or “1” (you can also name them “Emp” and “Occ”).

---

<div class="post-metadata">

**Author:** ![Verma](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@Verma](https://itensor.discourse.group/u/Verma)\
**Post date:** [September 28, 2022, 11:58am UTC](https://itensor.discourse.group/t/how-to-fix-the-number-of-fermions-in-dmrg/412/3 "2022-09-28T11:58:24Z")

</div>

Thanks .
