Tracking max link dimension using observers in TDVP

Hello,
I was hoping you could provide me some guidance for keeping track of the max link dimension in a TDVP calculation. I am using the Observers package.
Essentially I want to automatically switch to 1-site TDVP once the max link dimension is reached.
My attempt used

linkdims(; maxlinkdim) = maxlinkdim

and then accessing this with an observer. However this doesn’t seem to work. Is there a way to do this?
Thanks!

To find the maximum link dimension of a state, you can use the ITensorMPS (/ITensors) function maxlinkdim.
Then you can create a function to capture this similar to what you’ve done

using ITensorMPS: maxlinkdim
getmaxlinkdims(; state) = maxlinkdim(state)
obs = observer(
# ...
"maxlinkdims" => getmaxlinkdims,
)

Note that the example 04 also has obs.states (from return_state(; state) = state), which you can then also call maxlinkdim on as an alternative.

2 Likes

Amazing, thank you so much! This perfectly solves my problem. Cheers!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.