Skip to content
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

Add functionality of MPO with block diagonal form #154

Merged
merged 4 commits into from
Aug 8, 2023

Conversation

SUSYUSTC
Copy link
Contributor

@SUSYUSTC SUSYUSTC commented Aug 5, 2023

Currently if one add two MPOs by mpo = mpo1 + mpo2 it creates zeros at off-diagonal blocks. In case the final MPO is composed of many small MPOs the computational efficiency is slow. I'll probably add another PR later for diagonal potential MPO, in which case the final MPO is composed of a dense kinetic block and a diagonal potential MPO block.

This pull request adds a StackedMpo class to improve the efficiency by calculating the Hamiltonians corresponding to each MPO part separately and then adding the Hamiltonians. It works for both the direct and iterative approach.

Example:

// original way: mpo = mpo_k + mpo_p
mpo = StackedMpo([mpo_k, mpo_p])
result = optimize_mps(mps.copy(), mpo)  // expect the same result

@codecov
Copy link

codecov bot commented Aug 5, 2023

Codecov Report

Patch coverage: 98.14% and project coverage change: +0.05% 🎉

Comparison is base (9706a29) 84.76% compared to head (9a985d1) 84.81%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #154      +/-   ##
==========================================
+ Coverage   84.76%   84.81%   +0.05%     
==========================================
  Files         105      105              
  Lines       10140    10183      +43     
==========================================
+ Hits         8595     8637      +42     
- Misses       1545     1546       +1     
Files Changed Coverage Δ
renormalizer/mps/gs.py 95.93% <97.50%> (+0.12%) ⬆️
renormalizer/mps/__init__.py 100.00% <100.00%> (ø)
renormalizer/mps/mpo.py 91.15% <100.00%> (+0.09%) ⬆️
renormalizer/mps/tests/test_gs.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jjren
Copy link
Collaborator

jjren commented Aug 5, 2023

Excellent PR and many thanks to Jiace.
It is better to add a test in mps/tests/test_gs.py. For example, in test_optimization, you can simply add the two mpos together and check if the energy is doubled.

@SUSYUSTC
Copy link
Contributor Author

SUSYUSTC commented Aug 6, 2023

Test already added.

jjren
jjren previously approved these changes Aug 7, 2023
@atxy-blip
Copy link
Contributor

The new function looks good to me. Many thanks for your work!

Meanwhile, personally speaking I prefer well-documented code, so maybe you could add new comments and make changes to the original ones accordingly. For example, the following line should contain the new class:

mpo : renormalizer.mps.Mpo

@SUSYUSTC
Copy link
Contributor Author

SUSYUSTC commented Aug 7, 2023

Comments & types added

@jjren jjren merged commit 9583324 into shuaigroup:master Aug 8, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants