# Difference between MPO() and OpSum()

**URL:** <https://itensor.discourse.group/t/difference-between-mpo-and-opsum/250>\
**Category:** ITensor Julia Questions\
**Created:** [July 12, 2022, 11:47pm UTC](https://itensor.discourse.group/t/difference-between-mpo-and-opsum/250 "2022-07-12T23:47:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meng-Zeng](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/meng-zeng/32/83_2.png) [@Meng-Zeng](https://itensor.discourse.group/u/Meng-Zeng)\
**Post date:** [July 12, 2022, 11:47pm UTC](https://itensor.discourse.group/t/difference-between-mpo-and-opsum/250/1 "2022-07-12T23:47:27Z")

</div>

Hello,

Lately I’ve been trying to understand the ITensorInfiniteMPS package. For example, the one given here on [Heisenberg model](https://github.com/ITensor/ITensorInfiniteMPS.jl/blob/main/examples/vumps/vumps_heisenberg.jl). I have the following questions:

1. What do \psi.AL and \psi.C mean in the code?

2. In the code for models, for example [Ising model](https://github.com/ITensor/ITensorInfiniteMPS.jl/blob/main/src/models/ising.jl), we have the following:

This MPO() here seems to be defined specifically for the Ising model, is it different from the one used in finite system DMRG? Also, it seems that OpSum() is very similar to MPO(). Is there any difference? Is there a reason that .+= is used for one and += is used for the other?

1. Where is the model “ising” defined? In the code ising.jl it seems that “ising” is used as an argument in defining the two functions MPO() and OpSum().

Thanks a lot for your time.  
-Meng

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [July 13, 2022, 1:07pm UTC](https://itensor.discourse.group/t/difference-between-mpo-and-opsum/250/2 "2022-07-13T13:07:03Z")

</div>

Hi Meng,

Good questions.

1. \psi.AL are the left gauged MPS tensors and \psi.C are the MPS bond matrices, respectively. \psi.AR are the right gauged MPS tensors. The `ITensorInfiniteMPS.jl` package uses the mixed canonical gauge, see [[1701.07035] Variational optimization algorithms for uniform matrix product states](https://arxiv.org/abs/1701.07035) for more details.
2. `MPO` is the definition of the finite MPO for the Ising model, and `Opsum` defines the terms of the unit cell of the infinite system Hamiltonian. This interface is admittedly quite confusing (it grew organically while I was originally writing the package), I am simplifying the interface here: [[WIP] Start simplifying the necessary OpSum definitions for Models by mtfishman · Pull Request #63 · ITensor/ITensorInfiniteMPS.jl · GitHub](https://github.com/ITensor/ITensorInfiniteMPS.jl/pull/63) so that there will only be a single function `ITensorInfiniteMPS.unit_cell_terms` where you define the terms in the unit cell for a model.  
There isn’t a big reason for using `.+=` instead of `+=`, `.+=` adds the terms in-place so the `OpSum` doesn’t need to get reallocated for each term added, but the performance difference won’t be noticeable in general.
3. The way to think about it is that each model is just a special instance of the general (parametric) type `Model`. So an instance of the Ising model is just `Model("ising")` and the type is `Model"ising"`. The main use of this type is so that you can define the Hamiltonian for the model, currently through the functions `MPO` and `OpSum` but in the future through the single function `ITensorInfiniteMPS.unit_cell_terms`.
