# Non-hermitian hamiltonian with real eigenvalues

**URL:** <https://itensor.discourse.group/t/non-hermitian-hamiltonian-with-real-eigenvalues/891>\
**Category:** DMRG and Numerical Methods\
**Created:** [May 22, 2023, 9:28pm UTC](https://itensor.discourse.group/t/non-hermitian-hamiltonian-with-real-eigenvalues/891 "2023-05-22T21:28:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bernardo](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Bernardo](https://itensor.discourse.group/u/Bernardo)\
**Post date:** [May 22, 2023, 9:28pm UTC](https://itensor.discourse.group/t/non-hermitian-hamiltonian-with-real-eigenvalues/891/1 "2023-05-22T21:28:31Z")

</div>

Hello,

I have a Hamiltonian which is not hermitian, but I know that its eigenvalues are real. I can do DMRG with the option `ishermitian=false` . However, the algorithm treats the eigenvalues as complex. At times, it converges to a real value of the eigenvalues (i.e. with a very small imaginary part of the energy). At other times, it converges to a complex value of the energy.

Is there a way to tell the algorithm that I want a real result? For example, besides minimizing the energy, I would also want to minimize the absolute value of the imaginary part of the energy.

If needed, I can give a working example of what I’m referring to

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [May 23, 2023, 1:01am UTC](https://itensor.discourse.group/t/non-hermitian-hamiltonian-with-real-eigenvalues/891/2 "2023-05-23T01:01:52Z")

</div>

Hi @Bernardo,  
It’s a good question. Inside `dmrg`, we use the `KrylovKit.eigsolve` function to solve the reduced eigenproblem. That function takes a parameter called `which` that has the options given [on this page](https://jutho.github.io/KrylovKit.jl/stable/man/eig/#KrylovKit.eigsolve). The one we use in ITensor is `which=:SR` but would one of the other options solve your problem? If not, perhaps the custom `EigSorter` mentioned there could help.

To try this out, you can put ITensors.jl into “dev” mode by inputting the command:

```auto
julia> ]
pkg> dev ITensors

```

then navigate to the corresponding source code folder that Julia will tell you about. Then in the ITensors.jl/src/mps/ folder if you go to line 180 of dmrg.jl and edit that, you can try the other options. If one of them works well for you, we can make a small change to the library to allow that to be set from outside of the `dmrg` function. If you run into any issues editing the code just let us know and we can do things another way.
