Page 1 of 1

Correlation function

Posted: 13 Apr 2025, 09:59
by mariocat
Hello all, I am trying to implement \(<e^{\sum_{i<j}(\mathbb{1}-n_i)}>\). For instance for \(j=36\). I am trying to do it using Bose-Hubbard model and tried to write it as:

Python: Select all

N=36
model_params = {
        "L": N,
        "t": 1.0,
        "U": 0.0,
        "n_max": 4,
        "bc_MPS": "finite"
    }
model=BoseHubbardModel(model_params)
init_state = ['1'] * model.lat.N_sites
psi = MPS.from_product_state(model.lat.mps_sites(), init_state, bc=model.lat.bc_MPS)
dmrg_params = {"trunc_params": {"chi_max": 150, "svd_min": 1.e-7}, 'max_sweeps': 10, "mixer": True}
info = dmrg.run(psi, model, dmrg_params)
ni = psi.sites[0].N
pi=(-1)*expm(1j*np.pi*(ni))
i=4
ops1=expm(1j*np.pi*('Id'))
ops2=expm(-1*j*np.pi*(ni))
P = psi.correlation_function((ops1),ops(2), sites1=None, sites2= None, opstr=None, str_on_first=True)
But it isnt working, what should I fix?

Re: Correlation function

Posted: 16 Apr 2025, 11:54
by Johannes
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)]

Re: Correlation function

Posted: 17 Apr 2025, 20:40
by mariocat
Hello, thanks for the long answer and clarification!
I was wondering if

Python: Select all

i=psi.sites[0].Id
ni = psi.sites[0].N
expi_ni=expm(1j*np.pi*(i-ni))
P=psi.expectation_value_multi_sites([expm(1j*np.pi*(i-ni))],i0=4)
Could be used to evaluate \(<e^{(i\pi(1-n_4)}...e^{(i\pi(1-n_{36}))}>\)

Re: Correlation function

Posted: 17 Apr 2025, 20:51
by mariocat
More: what should I write to evaluate\(<e^{i\pi(1-n_{4})}...e^{i\pi(1-n_{30})}>\) in a \(N=36\) Bose-Hubbard model. Basically I want to arbitrarly choose the first and last site of the product. Thanks!