I'm trying to implement DMRG on a Hamiltonian with multiple fermion species and multiple conserved charges. After mapping my model to spins-1/2, and assuming for this example there are three species, I can write the following code:

Python: Select all

```
L = 2 # Length of the lattice
Nf = 3 # Number of fermion families
N = 2*L*Nf # The total number of sites is twice (fermions+anti-fermions)
conserve = model_params.get('conserve', 'Sz')
sort_charge = model_params.get('sort_charge', True)
siteA = SpinHalfSite(conserve=conserve, sort_charge=sort_charge)
siteB = SpinHalfSite(conserve=conserve, sort_charge=sort_charge)
siteC = SpinHalfSite(conserve=conserve, sort_charge=sort_charge)
set_common_charges([siteA, siteB, siteC],new_charges='independent') # Have the 'Sz' of each fermion family separate
lat = Chain(N//Nf, [siteA, siteB, siteC], bc_MPS='finite', bc='periodic', order='folded') # Define a 1D chain with each site being composed of the three fermion types
```

Python: Select all

```
term_list = TermList([[("Sp",0),("Sigmaz",1),("Sigmaz",2),("Sm",3)],[("Sm",0),("Sigmaz",1),("Sigmaz",2),("Sp",3)]], [0.5,0.5])
H = MPOGraph.from_term_list(term_list, lat.mps_sites(), bc='finite', insert_all_id=True).build_MPO()
```

Python: Select all

```
File ~/opt/anaconda3/envs/base310/lib/python3.10/site-packages/tenpy/networks/terms.py:275, in <listcomp>(.0)
273 N = len(term)
274 overall_sign = 1
--> 275 terms_commute = [(op, i, sites[i % L].op_needs_JW(op)) for op, i in term]
276 # perform bubble sort on terms_commute and keep track of the sign
277 if N > 100: # bubblesort is O(N^2), assume that N is small
278 # N = 1000 takes ~1s, so 100 should be fine...
AttributeError: 'list' object has no attribute 'op_needs_JW'
```

`lat.mps_sites()`

) is now a list of lists (`[[siteA, siteB, siteC],...]`

), and not just a single site type (if I code the same problem assuming a single fermion family with global Sz conserved charge, like `Chain(N, siteA, bc_MPS='finite', bc='periodic', order='folded')`

, I don't get this problem).If tried modifying how I specify the

`term_list`

object specifying the position of the sublist in the `lat.mps_sites()`

list, like soPython: Select all

```
term_list = TermList([[("Sp",[0,0]),("Sigmaz",[0,1]),("Sigmaz",[0,2]),("Sm",[1,0])],[("Sm",[0,0]),("Sigmaz",[0,1]),("Sigmaz",[0,2]),("Sp",[1,0])]], [0.5,0.5])
```

Thank you