I got the following question by email:

I encountered some difficulties when setting conserved quantities. I filled two types of bosons in a two-dimensional bosonsite, and I want to control the filling numbers for each boson. Usually, I control the filling number by controlling their chemical potential, for example, for a two-dimensional bosonsite with Lx=20 and Ly=4, the upper part with Lx=20 and Ly=2 is set to chemical potential \(\mu_{up}\), and the other part is set to \(\mu_{down}\).

However, controlling the filling through chemical potential is always inconvenient. The spinhalf model in the fermion system can directly achieve different fillings between different fermions through Sz conservation. But the boson system in the two-dimensional bosonsite is difficult to transform to spinhalf model through the Jordan Wigner transformation. So I want to ask if there are any good ways to control the filling number of different bosons separately or set their corresponding particle number conservation, and if you could help me?

## controlling particle number of independent species

### Re: controlling particle number of independent species

I'm not sure what your Hamiltonian is, here - do you have boson hopping between the upper and lower part where you set \(\mu_{up}\) and \(\mu_{down}\), respectively, or is there only a density-density interaction?

You can only use charge conservation to preserve the respective fillings if H commutes with

In other words, you should have a Hamiltonian (omitting pre-factors for the different terms) of the form

\[H = \sum_{<i,j>, i,j \in A} b^\dagger_i b_j + \sum_{<i,j>, i,j \in B} b^\dagger_i b_j + \sum \mathrm{interactions~with~}n_i\mathrm{~or~}n_i n_j\]

where A and B are the regions of the different species - but you can't have terms of the form

\[ \sum_{i \in A, j \in B} b^\dagger_i b_j\].

If you have that form, you can indeed conserve the particle number (or Sz, if you write it with spins) of the individual regions.

To acchieve that, you typically need to call tenpy.networks.site.set_common_charges in the Model's

The default init_lattice will initialize such a MultiSpeciesLattice, if the init_sites returns a tuple of (sites, species_names) instead of just the sites.

You can only use charge conservation to preserve the respective fillings if H commutes with

`N_up = sum_{i in upper region} n_i[inline] and [inline]N_down = sum_{i in down region} n_i `

, respectively.In other words, you should have a Hamiltonian (omitting pre-factors for the different terms) of the form

\[H = \sum_{<i,j>, i,j \in A} b^\dagger_i b_j + \sum_{<i,j>, i,j \in B} b^\dagger_i b_j + \sum \mathrm{interactions~with~}n_i\mathrm{~or~}n_i n_j\]

where A and B are the regions of the different species - but you can't have terms of the form

\[ \sum_{i \in A, j \in B} b^\dagger_i b_j\].

If you have that form, you can indeed conserve the particle number (or Sz, if you write it with spins) of the individual regions.

To acchieve that, you typically need to call tenpy.networks.site.set_common_charges in the Model's

`init_sites()`

which you define, and then use a tenpy.models.lattice.MultiSpeciesLattice, see details in the examples there.The default init_lattice will initialize such a MultiSpeciesLattice, if the init_sites returns a tuple of (sites, species_names) instead of just the sites.

### Re: controlling particle number of independent species

Dear Johannes，hello！

I have call https://tenpy.readthedocs.io/en/latest/ ... on_charges

，which is simple and faster, but I am a bit confused about the index of lattice sites. I want to calculate something similar to Corr=psi.term_rorrelation_function_right（[("Bd", 0), ("B", 1)],[("B", 20), ("Bd", 21)],i_L=0,）.The correlation function includes two sitess from spin up and two from spin down. I have set the relevant indexes according to my understanding, but the calculation result is not what I want. So, may I ask if you can provide assistance?

Thank you

I have call https://tenpy.readthedocs.io/en/latest/ ... on_charges

，which is simple and faster, but I am a bit confused about the index of lattice sites. I want to calculate something similar to Corr=psi.term_rorrelation_function_right（[("Bd", 0), ("B", 1)],[("B", 20), ("Bd", 21)],i_L=0,）.The correlation function includes two sitess from spin up and two from spin down. I have set the relevant indexes according to my understanding, but the calculation result is not what I want. So, may I ask if you can provide assistance?

Thank you

### Re: controlling particle number of independent species

You have to be a bit more specific - your question is very generic, so I can only guess what your problem might be...

What's your lattice, how did you get the 0, 1 and 20, 21 indices in your question?

I would assume that you would rather want something like
this gives you 4 expectation values at once, with the last one equivalent to
Which sites in the original lattice do you think the indices 0, 1, 20, 21 correspond to?

Take a look at the Into about lattices to get an idea about the ordering of the MPS.

Run this for your example model, i.e. plot the order there - is it what you expected?

If you provide explicit example code of (the relevant parts of) how you define the model, I might at least have a chance to help...

What's your lattice, how did you get the 0, 1 and 20, 21 indices in your question?

I would assume that you would rather want something like

Python: Select all

`Corr=psi.term_rorrelation_function_right（[("Bd", 0), ("B", 1)],[("B", 0), ("Bd", 1)],i_L=0,i_R=[14,16,18,20])`

Python: Select all

`psi.expectation_value_term([("Bd", 0), ("B", 1),("B", 20), ("Bd", 21)])`

Take a look at the Into about lattices to get an idea about the ordering of the MPS.

Run this for your example model, i.e. plot the order there - is it what you expected?

If you provide explicit example code of (the relevant parts of) how you define the model, I might at least have a chance to help...

### Re: controlling particle number of independent species

I'm very sorry for not explaining my question clearly, you still provided me with a lot of help. First, I confirmed the sites index, through
I have clearly identified the sites index of the site_up and site_down.

The problem I described earlier was that I originally created a BosonSite on a two-dimensional lattice. The upper part Lx * 2 is spin up, the downer part Lx * 2 is spin down.Then I can calculate multi body correlation function $<B_ {0}Bd_ {2}Bd_ {4}B_ {6}>$, where B is the annihilation operator, the subscript is the site of my two-dimensional model,0 , 4 for spin up and 2 , 6 for spin down.When I use set_common_charges,now I can define two BosonSite as site_up and site_down.I still want to calculate the multi body correlation function.I calculated $<B_ {0}Bd_ {1}Bd_ {4}B_ {5}>$ ,it's not I want.Your answer reminded me that I need to select the value j: 4 res: (0.09795509015378684+0.054567706218236623j) corresponding to j=4 from a series of correlation functions,so it is what I want!

Thank you very much!The ideas you provide are of great help in solving the problem.

Python: Select all

```
fig, ax = plt.subplots(figsize=(10, 10))
lat = M.lat
lat.plot_sites(ax)
lat.plot_coupling(ax)
lat1.plot_order(ax, linestyle=':')
ax.set_aspect(1.)
ax.set_title("order = 'default'", fontsize=14)
```

The problem I described earlier was that I originally created a BosonSite on a two-dimensional lattice. The upper part Lx * 2 is spin up, the downer part Lx * 2 is spin down.Then I can calculate multi body correlation function $<B_ {0}Bd_ {2}Bd_ {4}B_ {6}>$, where B is the annihilation operator, the subscript is the site of my two-dimensional model,0 , 4 for spin up and 2 , 6 for spin down.When I use set_common_charges,now I can define two BosonSite as site_up and site_down.I still want to calculate the multi body correlation function.I calculated $<B_ {0}Bd_ {1}Bd_ {4}B_ {5}>$ ,it's not I want.Your answer reminded me that I need to select the value j: 4 res: (0.09795509015378684+0.054567706218236623j) corresponding to j=4 from a series of correlation functions,so it is what I want!

Thank you very much!The ideas you provide are of great help in solving the problem.