# Converting the eigenstates obtained from the exact diagonalization to a MPS

Hello dear ITensor team,

First of all, I would like to thank you for making the ITensor code available, and for the
time/efforts to keep it running and updated.
Well, I have a (naive) question on one of your examples of exact diagonalization (ITensors.jl/examples/exact_diagonalization/exact_diagonalization.jl at main · ITensor/ITensors.jl · GitHub).
Is it possible to use the eigenvectors obtained from it (after calling the eigsolve) and use it to calculate the correlation matrix (or any other observable) by means of “correlationMatrix”?
I’ve gone though the available tutorial (MPS and MPO Examples · ITensors.jl) on how to convert it to a MPS,
but so far I have not succeeded.

Thank you and kind regards,
Ginetom

1 Like

https://itensor.github.io/ITensors.jl/dev/examples/MPSandMPO.html#Creating-an-MPS-from-a-Tensor

Hi Miles!
Thank you so much for the quick reply. In fact, I have tried to follow the example given (and that you’ve suggested). As I have mentioned, I am extracting the GS wavefuntion from the exact diagonalization (exactly as calculated from the example: ITensors.jl/examples/exact_diagonalization/exact_diagonalization.jl at main · ITensor/ITensors.jl · GitHub), and then, I am trying
to convert the GS wavefunction to a MPS. I have used:

``````sites = siteinds("S=1/2", N; conserve_qns=true)
psiEDtoMPS = MPS(evecs[1],sites;cutoff=1e-8,maxdim=10)
``````

However, I am getting an error:

``````ERROR: LoadError: AssertionError: hasinds(A, s)
Stacktrace:
[1] MPS(A::ITensor, sites::Vector{Index{Vector{Pair{QN, Int64}}}}; leftinds::Nothing, orthocenter::Int64, kwargs::@Kwargs{cutoff::Float64, maxdim::Int64})
@ ITensors ~/.julia/packages/ITensors/UHeB1/src/mps/abstractmps.jl:1925
``````

I have no idea where is my mistake. So any help would be appreciated.

Thank you.

Does `evecs[1]` have the same indices as contained in `sites`?

I have only extracted the evecs[1] directly from the ED (calculated from the given ITensor example exact_diagonalization.jl), and then I have used:

``````sites = siteinds("S=1/2", N; conserve_qns=true)
psiEDtoMPS = MPS(evecs[1],sites;cutoff=1e-8,maxdim=10)
``````

So, how could I assume evecs[1] (which is the ground state associated to evals[1]) with the same indices as in sites?
Thank you.

If we are looking at the same example, there is already an array of site indices made on line 29 (just below the comment saying “Hilbert space”). The array is stored in the variable `s`. Then those indices are used to make the Hamiltonian and the eigenvectors. (You will need to set the `fuse` keyword to `fuse=false` in the call to `main` to keep the indices from being merged together, or else unfuse them after the ED is run.)

Then when making the MPS, your code is almost correct except:

• do not make a second array of site indices, but use the one already made, because a new array will contain new indices that will not match
• pass the existing array of site indices (named `s` in that code) to the `MPS` constructor

Hi Miles,
It worked after your suggestion (fuse=false). In fact, I have also assumed “fuse=false” before, but
at the same time I have also (wrongly) assumed “binary=false”, and this was my error.
Thank you so much for your help.

Glad to hear it is working now!