+1 vote
asked by (620 points)

I was wondering how to apply a local operator to an MPS and store as a new MPS? I simply want to have an MPS |psi> and want to apply Sz at site i to |psi>. When I use the op function, the output is of type ITensor, and it says there is no rule for * when applied to a type MPS.

2 Answers

+2 votes
answered by (450 points)

Hi Nick,

I think you may want to extract the itensor on the ith site form the MPS, multiply the itensor by the op function, and then plug it back. For example like this,

psi.position(i);
auto newpsi = noprime(psi(i) * op(sites,"Sz", i));
psi.set(i, newpsi);

Best,

Yixuan

commented by (620 points)
Awesome, thank you Yixuan.
0 votes
answered by (46.8k points)

Hi Nick,
Yixuan's answer is correct and his solution is good. I also just added a code formula here with an answer to your question:
http://itensor.org/docs.cgi?vers=cppv3&page=formulas/mps_onesite_op

The formula I added is a bit more general, e.g. assuming the operator could come from anywhere and not only the op(sites,"Sz",i) function, though that is a very good way to get the "Sz" operator for your case. Also the formula does not call psi.position(i) because strictly speaking it's not necessary to do so for a one-site operation (since no truncation afterward is involved) but it can still be a good idea for reasons I discuss at the end of the formula page.

Miles

commented by (620 points)
Great, thank you Miles!
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...