Expectation values using GroupedSite

How do I use this algorithm? What does that parameter do?
Post Reply
nnn
Posts: 2
Joined: 20 Jan 2019, 18:05

Expectation values using GroupedSite

Post 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!
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Expectation values using GroupedSite

Post 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 ...
nnn
Posts: 2
Joined: 20 Jan 2019, 18:05

Re: Expectation values using GroupedSite

Post by nnn »

Ah yes, this makes lots of sense. Thanks so much for the response Johannes!
Post Reply