+1 vote
asked by (270 points)

I have a dumb question... When constructing ampo, how to add a constant term? For example, in a 1D spin model, that 1/4 in terms like 0.5(Szi Szi+1 -1/4)?

I tried:
ampo = OpSum()
for i in 1:(N - 1)
ampo += 0.5, "Sz", i, "Sz", i + 1
ampo += -0.5/4
end

But doesn't work... I know the overall constant is trivial, but just want to know...
Thank you!

1 Answer

+1 vote
answered by (70.1k points)
selected by
 
Best answer

No that's a pretty good question actually!

The short answer is that if you want an overall constant shift, you can do this:

ampo += -0.5/4,"Id",1

and importantly do that outside the loop so it's only a single shift. If you put that inside the loop if would be equivalent to adding a shift

ampo += -(N-1)*0.5/4,"Id',1

unless that's actually the behavior you want.

On a more big picture level, recall that a constant shift to a Hamiltonian really means a term which is the tensor product of the identity operator on every site. The way OpSum works when converting to an MPO is that any sites not included in a term are assumed to have the identity operator acting on them. So a term like "Sz",3 is really Id1 Id2 Sz3 Id4 Id_5 ....

We should add as a feature, though, the ability to just add a constant by itself as you tried. It's a nice suggestion and could be convenient in many cases.

Thanks,
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

...