# Convert a Hamiltonian matrix to an MPO for DMRG's input

**URL:** <https://itensor.discourse.group/t/convert-a-hamiltonian-matrix-to-an-mpo-for-dmrgs-input/1812>\
**Category:** DMRG and Numerical Methods\
**Tags:** mpo\
**Created:** [June 18, 2024, 12:10am UTC](https://itensor.discourse.group/t/convert-a-hamiltonian-matrix-to-an-mpo-for-dmrgs-input/1812 "2024-06-18T00:10:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfelmanl](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/dfelmanl/32/578_2.png) [@dfelmanl](https://itensor.discourse.group/u/dfelmanl)\
**Post date:** [June 18, 2024, 12:10am UTC](https://itensor.discourse.group/t/convert-a-hamiltonian-matrix-to-an-mpo-for-dmrgs-input/1812/1 "2024-06-18T00:10:28Z")

</div>

Hi,

I am trying to to find the optimal process to find the ground state of a Hamiltonian matrix when given as a 2D array.

In the examples I found in your [documentation](https://itensor.github.io/ITensors.jl/stable/examples/DMRG.html), the MPO hamiltonian is directly constructed from the hamiltonian operators.

My follow up question is:  
Is it recommended to optimize the given hamiltonian before giving it as an input into the `dmrg` algorithm?  
Maybe taking advantage of symmetries during its MPO construction? Or compressing it with SVD sweeps after the construction?

Thank you in advance,  
Daniel

---

<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:** [June 18, 2024, 1:23am UTC](https://itensor.discourse.group/t/convert-a-hamiltonian-matrix-to-an-mpo-for-dmrgs-input/1812/2 "2024-06-18T01:23:05Z")

</div>

In general the dense matrix representation of a Hamiltonian will be exponentially large in the number of sites of the system, so normally it wouldn’t make sense to start from that representation if you were running DMRG. That’s why we generally expect users to specify the Hamiltonian as a sum of local terms in some operator basis symbolically as an `OpSum`, since we can then construct the Hamiltonian as an MPO without going through the exponentially large matrix representation.

**EDIT:** To answer your follow-up questions, when you construct a Hamiltonian symbolically as an `OpSum` and then convert it to an `MPO`, internally ITensorMPS.jl already compresses the MPO to the optimal bond dimension using SVDs. Additionally, if you specify your site indices to have conserved QNs, it will also take advantage of those conserved quantities when it is being constructed. You could try writing down the MPO representations by hand for a few simple Hamiltonians and see how the optimal bond dimension compares to the bond dimensions of the MPOs constructed by ITensor, those should match.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/d3072b13e047cd06df7f3981547c0917d940dfa4.png) [@system](https://itensor.discourse.group/u/system)\
**Post date:** [June 28, 2024, 1:23am UTC](https://itensor.discourse.group/t/convert-a-hamiltonian-matrix-to-an-mpo-for-dmrgs-input/1812/3 "2024-06-28T01:23:38Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
