Extracting Target Symmetry Sectors to Create Sparse Arrays in ITensor

A lot of the functionality you are using is considered internal functionality that most users should not be using. A telltale sign that functionality is internal is that it is undocumented, not exported, or that you are accessing fields of types, such as x.space or x.data. You are of course free to use internal functionality, but be aware that internal functionality may change even in patch releases of ITensor without warning, and in fact I’m certain some of the functionality you are using will be changed in future releases because we are in the process of rewriting the entire NDTensors library ([NDTensors] Roadmap to removing `TensorStorage` types · Issue #1250 · ITensor/ITensors.jl · GitHub), though we don’t know the exact time frame for when that will be finished.

I might be able to guide you on implementing what you are trying to accomplish with documented, external functionality, however I’m not sure if that is worth the hassle for you or me since at the end of the day ITensor is meant more as a tensor network library rather than an exact diagonalization library. I think with the rewrite planned in [NDTensors] Roadmap to removing `TensorStorage` types · Issue #1250 · ITensor/ITensors.jl · GitHub as well as our release of non-abelian symmetries we will have more solid tools that we can make available for end users to use for performing exact diagonalization and analyzing symmetry sectors, though again the timeframe for that is unknown (I would definitely hope both of those would be completed within a year).

As an alternative I would suggest looking for devoted exact diagonalization libraries. Two that come up in searches or I was told about (but haven’t tried myself) are:

Something that could be helpful if you want to use ITensor’s OpSum interface and/or make it easier to compare ITensor’s DMRG results to exact diagonalization results would be to write a conversion tool from ITensor’s OpSum object to the symbolic operator format of those packages. That is something I have discussed with Alex Wietek, the author of the first package.