Custom Hamiltonian with multiple fermions and conserved charges

How do I use this algorithm? What does that parameter do?
Post Reply
marcilla
Posts: 1
Joined: 11 Jun 2024, 15:35

Custom Hamiltonian with multiple fermions and conserved charges

Post by marcilla »

Hello,

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
The problem appears when I constuct the Hamiltonian (which has both local and non-local terms, involving sites far away). For example, if I want to add a term that looks like \(\frac{1}{2}(\sigma^+_0 \sigma^z_1 \sigma^z_2 \sigma^-_3+h.c.)\), using tenpy.networks.mpo.MPOGraph.from_term_list,

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()
I get the following error

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'
and it's probably because sites (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 so

Python: 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])
but it didn't solve the issue. Is there a way to solve this problem?
Thank you
User avatar
Johannes
Site Admin
Posts: 456
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Custom Hamiltonian with multiple fermions and conserved charges

Post by Johannes »

Not sure if this is still relevant or solved by now, but anyways:
the issue here is that the tenpy.models.lattice.Chain expects that it has a single-site unit cell only.

Try using a more general lattice that allows for multiple sites in the MPS unit cell.
The "correct" or recommend way in this case would probably be a tenpy.models.lattice.MultiSpeciesLattice, i.e. something like

Python: Select all

lat = MultiSpeciesLattice(Chain(L, None, ...), [siteA, siteB, siteC])
, see tenpy.models.lattice.MultiSpeciesLattice.

You could also initialize this with the standard CouplingMPOModels's init_lattice if the sites returned by self.init_sites() returns a tuple of both sites and species names.

Alternatively, you could use e.g. the tenpy.models.lattice.NLegLadder directly - of course, you need to be careful, what the "nearest neighbors" etc mean in this case, but that's something you should think about anyways.
Post Reply