Think about what exactly you're trying to calculate.... in your formula, you don't include 1.j*np.pi factors, which you seem to include in the code? I assume you want to include that.
Further, you should expand \[\langle \exp(\sum_{i<j} 1- n_i)\rangle = \langle \prod_{i<j} \exp(1-n_i)\rangle= \langle \exp(1-n_0) \exp(1-n_1) \cdots \exp(1-n_{j-1}) \rangle \]
This means you have operators on *each* site starting from site 0! If you just use
psi.correlation_function(A, B, ..., opstr=None)
, you only get expectation values \(\langle A_i B_j \rangle\), but the
opstr
argument does exactly what you want here, it gives \langle A_i \prod_{i<k<j} ostr_k B_j\rangle. Check the documentation of the
correlation_function, and you should get something like
Python: Select all
exp_op = npc.expm(np.pi*1.j * (site[0].Id - site[0].N))
result = [1, psi.expectation_value_multi_site([exp_op], 0)]
result.extend(psi.correlation_function(exp_op, 'Id', sites1=0, sites2=range(1, psi.L), opstr=exp_op))
Here I handle j=0, 1 separately, because they have only a single site where they apply a nontrivial site...
Alternatively, you could just do (slightly less efficient, but works nevertheless):
Python: Select all
exp_op = npc.expm(np.pi*1.j * (site[0].Id - site[0].N))
result = [1]
for j in range(1,L):
result.append(psi.expectation_value_multi_site([exp_op]*j, 0)]