Finding sum of expectation values

How do I use this algorithm? What does that parameter do?
Post Reply
mariocat
Posts: 12
Joined: 10 Mar 2025, 09:17

Finding sum of expectation values

Post by mariocat »

Hello, I am trying to evaluate these quantities here: \(N_a=<\sum_{i}b_{i}^{\dagger}b_{i+1}> ; N_d= <\sum_{i}(b_{i}^{\dagger})^{2}(b_{i+1})^{2}>\)
I have obtained the operators \(b_{i}^{\dagger}; b_{i+1}\) using

Python: Select all

ops = ['Bd'] * model_params['L']
and

Python: Select all

opss=['B']*model_params['L']


And to find \(N_a\) I wrote

Python: Select all

def Na(psi):
    K = 0.0
    L = psi.L
    for i in range(L - 1):                       
        corr = psi.correlation_function("Bd", "B",
                                        sites1=[i],
                                        sites2=[i + 1])[0, 0]
        K += corr                                
    return K.real                                
K = Na(psi)
But I do not know how to evaluate \(N_d\), do you have any ideas? Thanks a lot!
User avatar
Johannes
Site Admin
Posts: 471
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Finding sum of expectation values

Post by Johannes »

Just plug in "Bd Bd" and "B B", i.e. write psi.correlation_function("Bd Bd", "B B", sites1=[i], sites2=[i + 1])[0, 0]

In general, the get_op function used from correlation_function and friends to translate the name into actual tensors accepts space-separated combinations of local operator names to represent (matrix) products of the corresponding local operators.
Post Reply