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

[ITensors] Fix OpSum issue when a site operator has no blocks #1165

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

emstoudenmire
Copy link
Collaborator

Description

There was a bug in the QN version of OpSum where if one of the site operators making up a term had no blocks (was exactly zero), then the logic of figuring out which block of the column index which was based on finding the operator's flux, could break. (I.e. the intended operator might have a non-zero flux, but if it has no blocks, the flux function returns nothing. This can happen when the operator is something like "C*C" which goes outside the local Hilbert space.)

This fix checks for the nnzblocks(Op)==0 case and just skips such operators.

Fixes #1150

If practical and applicable, please include a minimal demonstration of the previous behavior and new behavior below.

Minimal demonstration of previous behavior

See #1150 for a minimal example code that throws an exception.

How Has This Been Tested?

Added a new "regression test" to the test_autompo.jl file.

Checklist:

  • My code follows the style guidelines of this project. Please run using JuliaFormatter; format(".") in the base directory of the repository (~/.julia/dev/ITensors) to format your code according to our style guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that verify the behavior of the changes I made.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.

@emstoudenmire
Copy link
Collaborator Author

[test ITensors mps]

@github-actions
Copy link
Contributor

Run ITensors mps tests from comment trigger: succeeded ✅
https://github.com/ITensor/ITensors.jl/actions/runs/5687844673

@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2023

Codecov Report

Merging #1165 (60e2356) into main (93447d0) will decrease coverage by 31.03%.
Report is 4 commits behind head on main.
The diff coverage is 0.00%.

❗ Current head 60e2356 differs from pull request most recent head e82d31a. Consider uploading reports for the commit e82d31a to get more accurate results

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##             main    #1165       +/-   ##
===========================================
- Coverage   85.28%   54.26%   -31.03%     
===========================================
  Files          87       86        -1     
  Lines        8368     8315       -53     
===========================================
- Hits         7137     4512     -2625     
- Misses       1231     3803     +2572     
Files Changed Coverage Δ
src/physics/autompo/opsum_to_mpo_qn.jl 0.00% <0.00%> (-97.62%) ⬇️

... and 36 files with indirect coverage changes

@github-actions
Copy link
Contributor

Run ITensors mps tests from comment trigger: succeeded ✅
https://github.com/ITensor/ITensors.jl/actions/runs/5687844673

@mtfishman mtfishman changed the title Fix OpSum Issue 1150 [ITensors] Fix OpSum issue when a site operator has no blocks Jul 31, 2023
@mtfishman mtfishman merged commit ab671e9 into main Jul 31, 2023
7 checks passed
@mtfishman mtfishman deleted the 1150_opsum_qn_array_size branch July 31, 2023 18:24
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.

[ITensors] [BUG] QN OpSum Wrong Array Size Issue
3 participants