# Simple exact diagonalization in ITensor

+1 vote

I want to implement some simple exact diagonalization, for a challenging/new system, to benchmark DMRG for larger systems.

Is this simple to do? I need to keep the wavefunctions in MPS format after ED.

Thanks!

Jon

+1 vote

Hi Jon,
I created a code formula based on your question. Please let me know if it's useful for you, or if adding something else to it would help (including better comments of what the code is doing).

http://itensor.org/docs.cgi?page=formulas/simple_ed

commented by (860 points)
Thanks Miles! That might do the trick, although I think I am still going to write something up in Python since I want the full energy spectrum.

Jin and I were discussing the possibility of doing some kind of manual translation between MPS and simple ED code. For instance, make an MPO hamiltonian, then extract a full matrix version; apply that to simple vector versions of MPS with regular ED; and then translate the wave function back into MPS. This way we could solve the full eigenproblem using C++ but without losing the functionality of ITensor's analysis tools (SVD especially for getting the entanglement).

I am not sure if we're going to move forward with this approach or not but I think it would be useful.
commented by (30.7k points)
Hi Jon,
Sure thing. I think this example will help a lot of people and demonstrates some of the tensor level features of ITensor.

About getting all of the energies: if you use
ITensor U,d;
diagHermitian(H,U,d);
and then print "d" (Print(d);) then you should be able to get all of the energies that way.

Yes, it certainly should be possible to extract the storage of an ITensor and export the data into another code such as an ED code. There is a "code formula" about extracting the storage of a dense tensor that should help you. Eventually I want to fully document the storage types and the storage system, which is actually really flexible and interesting (if I may say so myself).

If you have some questions about accessing ITensor storage data or creating ITensors from some data directly, post a specific question on here and I can help you out.
commented by (860 points)
Ok will do! Thanks! This might actually be a lot easier than Python, because I am studying the extended hubbard model.

Would it be easy to pull the elements out of the Hamiltonian MPO and put them into a regular matrix, for purposes of getting the largest possible system size with ED? I figure there is some loss of accessible system size with the method you suggested above, is this so?
commented by (30.7k points)
Hi Jon, you should think carefully about the cost of each step if you are doing things in the full Hilbert space. While you could do the steps you mentioned above, just creating the Hamiltonian in the first place in ITensor would scale doubly exponentially with system size and you'd also not be taking advantage of the extreme sparsity of the Hamiltonian matrix. State-of-the-art ED approaches either store the Hamiltonian matrix elements in a sparse format or create the matrix elements on the fly while doing the Lanczos algorithm, say.
commented by (860 points)
So maybe it's not worth my time to get involved with ED?
commented by (30.7k points)
Hm, so it just depends on what you want. If you want to do ED separately, I was assuming it's because you want to write a more specialized code than is appropriate for ITensor because you want to reach larger system sizes and access the full spectrum. Doing so becomes hard very quickly, so there's little point in developing a specialized code unless one is going to use the key tricks, such as exploiting the sparsity of H and using algorithms like Lanczos or Davidson. Otherwise the "toy" ED one writes in ITensor (like in the code formula page I made) is good enough just for simple testing and things. Hope that helps to clarify - you can see why I don't think providing all of those ED-specific tricks would really make sense within the set of goals for ITensor itself