Issue with Missing Subscripts on Fermionic Operators in all_coupling_terms().to_TermList() Output

How do I use this algorithm? What does that parameter do?
Post Reply
Gun
Posts: 3
Joined: 05 May 2024, 13:55

Issue with Missing Subscripts on Fermionic Operators in all_coupling_terms().to_TermList() Output

Post by Gun »

Hi everyone.

I am new to TeNPy and currently working on a project involving spin-half fermions. I’ve come across an issue with the output format from the all_coupling_terms().to_TermList() when using the add_coupling function for defining hopping terms.

Description of the Issue:

The output seems to correctly incorporate Jordan-Wigner strings and represents the intended couplings, but I noticed that the fermionic creation operator Cdd does not display subscripts in some cases where I would expect them. For example, I see Cdd JW_0 Cd_1 instead of the expected Cdd_0 JW_0 Cd_1 and similarly, Cdd JW_1 Cd_2 instead of Cdd_1 JW_1 Cd_2. Interestingly, the 'N' operators do have the correct subscripts.

This inconsistency has left me unsure whether this is just a cosmetic issue in the printout or if it suggests a deeper issue with how the model setup or the library handles fermionic terms (or my understanding of the output :) ). Could this lack of subscripts affect the accuracy or functionality of simulations run with this model?

Below I have provided example of a code.


Code:

Code: Select all

import numpy as np
from tenpy.models.lattice import Chain
from tenpy.models.model import CouplingMPOModel

class test(CouplingMPOModel):
    default_lattice = Chain
    force_default_lattice = True

    def init_sites(self, model_params):
        return site.SpinHalfFermionSite(cons_N=None,cons_Sz=None)
    def init_terms(self, model_params):
        J = 1.
        lambd=model_params.get('lambd',0) #get the lambda value from parameters
        self.add_coupling(lambd, 0, 'Cdd', 0, 'Cd', [1],plus_hc=True)
        self.add_coupling(1,0,'Nd',0,'Nd',[1],plus_hc=False)
test = test({'lambd':5,'L':3})
print(test.all_coupling_terms().to_TermList())
Output:

Code: Select all

5.00000 * Cdd JW_0 Cd_1 +
5.00000 * JW Cd_0 Cdd_1 +
1.00000 * Nd_0 Nd_1 +
5.00000 * Cdd JW_1 Cd_2 +
5.00000 * JW Cd_1 Cdd_2 +
1.00000 * Nd_1 Nd_2
Gun
Posts: 3
Joined: 05 May 2024, 13:55

Re: Issue with Missing Subscripts on Fermionic Operators in all_coupling_terms().to_TermList() Output

Post by Gun »

Hi again,

I wanted to provide additional information. I have encountered a similar problem when using the add_multi_coupling function for defining four-point interactions.

More relevant to my project I am trying to implement intearctions of the form:

\(f^\dagger_{i\downarrow}f_{i\uparrow}f^\dagger_{i+1\uparrow}f_{i+1\downarrow}\)

The corresponding Python code snippet using add_multi_coupling is:

Code: Select all

        self.add_multi_coupling(1,[('Cdd',0,0),('Cu',0,0),('Cdu',1,0),('Cd',1,0)],plus_hc=False)
However, when I print the coupling terms for L=3L=3 in a chain geometry, the output I receive is:

Code: Select all

1.00000 * Cdd Cu_0 Cdu Cd_1 +
1.00000 * Cdd Cu_1 Cdu Cd_2 +
1.00000 * Cdd Cu_2 Cdu Cd_3 +
1.00000 * Cdd Cu_3 Cdu Cd_4
Thank you!
User avatar
Johannes
Site Admin
Posts: 435
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Issue with Missing Subscripts on Fermionic Operators in all_coupling_terms().to_TermList() Output

Post by Johannes »

The subscript notation is a bit misleading here, because it suggests that it only applies to the next operator.
Really, you should read those operators to be grouped like this:

Code: Select all

1.00000 * (Cdd Cu)_0 (Cdu Cd)_1 +
1.00000 * (Cdd Cu)_1 (Cdu Cd)_2 +
1.00000 * (Cdd Cu)_2 (Cdu Cd)_3 +
1.00000 * (Cdd Cu)_3 (Cdu Cd)_4
To understand that reasoning, you should know that the get_op method, which translates the strings of operator names to npc Arrays, takes whitespace concatenated operators as products of local operators multiplied together - as you would by hand when you write them.
User avatar
Johannes
Site Admin
Posts: 435
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Issue with Missing Subscripts on Fermionic Operators in all_coupling_terms().to_TermList() Output

Post by Johannes »

I've quickly fixed that formatting to include brackets in 9739ac3a4e26cbbfada009ec6bef6c3d7286a0a8
Gun
Posts: 3
Joined: 05 May 2024, 13:55

Re: Issue with Missing Subscripts on Fermionic Operators in all_coupling_terms().to_TermList() Output

Post by Gun »

Thanks for the quick fix. Now I am sure I have the correct operators!
Post Reply