Page 1 of 1

Expectation values using GroupedSite

Posted: 20 Jan 2019, 18:17
by nnn
Caveat: probably I'm misunderstanding exactly how GroupedSite is working.

I'd like to evaluate something like

Code: Select all

psi.expectation_value('Sx')
for a MPS 'psi' which has each \(k\) adjacent sites grouped using GroupedSite.

I think one way would be to add the desired kind of operator to the GroupedSite class? But surely an easier way is to replace 'Sx' with the expression needed (which should just be a Kronecker product of \(k\) Sx operators).

A hint in the right direction would be helpful!

Re: Expectation values using GroupedSite

Posted: 21 Jan 2019, 09:32
by Johannes
psi.expectation_value("Sx") tries to evaluate the expectation value \(\langle S^x_i\rangle\) on each site \(i\) of the MPS. If you called psi.group_sites(k) beforehand, the local sites i refer to GroupedSite, each containing k of the previous sites, and the "Sx" is no longer defined (on which of the k sites would it act on?).
However, the GroupedSite defines "Sx_0", "Sx_1", ... "Sx_{k-1}", if there was an operator "Sx" in the local sites before.
So one way to evaluate the expectation values is to call

Code: Select all

exp_vals = []
for i in range(k):
   exp_vals.append(psi.expectation_value("Sx_"+str(k))
exp_vals_sorted = np.stack(exp_vals).T.flatten()
Alternatively, you can just split the grouped sites before evaluating the expectation values. Don't forget to do the splitting only a copy, if you still need the original `psi` (e.g. because you're running a TEBD or DMRG simulation):

Code: Select all

psi_ungrouped = psi.copy()
psi_ungrouped.group_split()
exp_vals_sorted = psi_ungrouped.exp_vals("Sx") 
# ... and whatever other expectation values you want to evaluate ...

Re: Expectation values using GroupedSite

Posted: 21 Jan 2019, 13:23
by nnn
Ah yes, this makes lots of sense. Thanks so much for the response Johannes!