-
Notifications
You must be signed in to change notification settings - Fork 1
expectation value of a one-site operator for MPS using mixedcanonical form #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #384 +/- ##
=========================================
Coverage ? 43.81%
=========================================
Files ? 25
Lines ? 1383
Branches ? 0
=========================================
Hits ? 606
Misses ? 777
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can work well, but maybe is better if we specialize this function for MixedCanonical
form, and the default MPS
expect function calls the one of MixedCanonical
with canonize(MPS)
?
yes, definitely! I just wanted to get the discussion started, since we definitely need a function to compute exp values after it disappeared in the latest refactorings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for starting the work on this @starsfordummies
@jofrevalles yeah, the idea is to dispatch based on the CanonicalForm so that we can specialize behavior
the specialized implementations should do the following
- on
NonCanonical
, i would just do a sweep contracting the tensors - on
MixedCanonical
,canonize!
to the range of sites of the operator- directly connect boundary virtual bonds between ket and bra (skipping the tensors outside of the range of the operator)
- call
contract
- on
BondCanonical
,canonize!
to the range of sites of the operator (so move toMixedCanonical
) and callexpect
again but on theMixedCanonical
form - on
VidalGauge
, i would directly take the range of sites of the operator (so move toMixedCanonical
), absorb the lambdas and contract
if you know a more efficient way, we can do it that way
src/Components/MPS.jl
Outdated
""" Expectation value for a one-site operator `op` on site `op_site` of mps `psi`, brings `psi` to canonical form. """ | ||
function expect_1site!(psi::MPS, op::AbstractArray, op_site::Int) | ||
canonize!(psi, MixedCanonical(site"$(op_site)")) | ||
plug_ind = ind_at(psi, plug"$(op_site)") | ||
temp_ind = Index(:_temp_bra) | ||
ev = binary_einsum(psi[op_site], Tensor(op, [temp_ind, plug_ind])) | ||
ev = binary_einsum(ev, conj(replace(psi[op_site], plug_ind => temp_ind))) | ||
|
||
return ev | ||
end | ||
|
||
""" Expectation value for a one-site operator `op` on site `op_site` of mps `psi`. | ||
This makes a copy of the MPS """ | ||
function expect_1site(psi::MPS, op::AbstractArray, op_site::Int) | ||
psi = copy(psi) | ||
expect_1site!(psi, op, op_site) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind moving them to a Operations/expect.jl
file please?
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
i added a few methods for exp values of local ops and mpo - it could well be that bringing the MPS to canonical form is always the best way (even if it involves making a copy+canonizing it), need to benchmark it |
probably not too tenet-idiomatic but should work