Repository navigation
Fuse charges into MPO and tensor product terms in a LocalOperator - #476
Yue-Zhengyuan wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
|
This seems great, I'll have a closer look later today. I did have one question right away. The MPOTerm _fuse_charge implementation now has a very big overlap with what MPSKit.add_physical_charge does within MPSKit itself. Do you think there's any opportunity to reuse shared functionality from there? We don't have to forcibly fit this into the MPSKit implementation if it doesn't make sense, but since they really do the same thing it might make sense to share core routines. This can also be done afterwards with some changes on both sides if it's not natural with the current state. |
| """ | ||
| Fuse an auxiliary charge into an MPO factor's physical legs while preserving its virtual bond spaces. | ||
| """ | ||
| function _fuse_mpo_charge(tensor::AbstractTensorMap, charge::Sector) |
There was a problem hiding this comment.
To reuse MPSKit, the result looks like this:
function _fuse_mpo_charge(tensor::AbstractTensorMap, charge::Sector)
nout, nin = numout(tensor), numin(tensor)
# MPSKit expects both virtual legs, including trivial legs at MPO endpoints.
nout == 1 && (tensor = insertleftunit(tensor, 1))
nin == 1 && (tensor = insertrightunit(tensor, numind(tensor)))
# MPSKit dualizes its charge argument; LocalOperator has already done so.
tensor = MPSKit.add_physical_charge(tensor, dual(charge))
nin == 1 && (tensor = removeunit(tensor, 4))
nout == 1 && (tensor = removeunit(tensor, 1))
return tensor
endThe extra handling does not cost much, but this does remind me if we want to support PBC-MPOTerms.
This PR extends
add_physical_chargeto work withMPOTermandTensorProductTermof aLocalOperatorintroduced in #425.