Save evolution with hdf5
Posted: 20 Jun 2023, 13:47
I simulate time evolution of MPS by using \( ExpMPOEvolution\) method. Since I still do not know which observable I needed, instead of compute expectation value during and update to a next step, I would like to save the state at each steps in a file so I can open it later and compute the observables.
My code looks like this
For saving in HDF5 format,
However, compare to not calling the save function, write_hdf5 seriously slow down the computation.
Question: Do I implement it correctly? Or is there a better way to save with HDF5?
I'm not really familiar with HDF5.
Thanks.
My code looks like this
Code: Select all
self.engine = ExpMPOEvolution(self.state, self.model, self.options)
"""
Save state at step.
"""
if filename!=None:
self.write_hdf5(filename, step)
"""
Update state to a next timestep.
"""
self.engine.run()
self.state = self.engine.psi
Code: Select all
def write_hdf5(self, filename:str, step:int):
with h5py.File(filename, 'a') as f:
saver = hdf5_io.Hdf5Saver(f)
self.state.save_hdf5(saver, f, subpath=str(step)+'/')
Code: Select all
Unsaved
100%|██████████| 500/500 [00:02<00:00, 215.74it/s]
Saved
100%|██████████| 500/500 [00:14<00:00, 35.61it/s]
I'm not really familiar with HDF5.
Thanks.