# Write MPS to file in Julia

+1 vote

Hi,

Using the code below

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


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 (44k 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.

Miles

+1 vote
selected

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.

Thanks,
Miles

commented by (260 points)
Hi Miles,

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

Thanks a lot.
Best,
Gonçalo Catarina
commented by (44k 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 (260 points)
Yes, it is ok!

I forgot to say that I also tested reading the MPS and using it afterwards. Everything works well.