+1 vote
asked by (300 points)


Using the code below

using HDF5
 fo = h5open("output.h5", "w")
 write(fo, "MPS", psi)

I manage to write an MPS to a file, but only when QNs are not conserved.
Is there any way to do the same with QNs conserved?

Thanks a lot.
Best regards,
Gonçalo Catarina

commented by (70.1k points)
moved by

Hi Goncalo,
Unfortunately we haven’t implemented writing QN conserving ITensors to HDF5 yet in Julia. We plan to soon! This is the second request for it I’ve gotten in two days so I’ll move it up on my priority list.

Thanks for asking -


1 Answer

+1 vote
answered by (70.1k points)
selected by
Best answer

Hi Goncalo,
An update: I recently added this capability to the Julia version of ITensor, beginning in version 0.1.12 which is the latest tagged version. Please now try doing "update ITensors" in the Julia package manager then re-running your code above and it should work. If it doesn't, please comment below to let me know.


commented by (300 points)
Hi Miles,

I confirm that it now works.
I also checked that it also works for arrays of MPS.

Thanks a lot.
Gonçalo Catarina
commented by (70.1k points)
Thanks for that feedback! Glad it’s working well for you. Please let us know if the generated file sizes are ok for your purposes.
commented by (300 points)
Yes, it is ok!

I forgot to say that I also tested reading the MPS and using it afterwards. Everything works well.
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.