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] Add option to ignore space error in replaceind #1455

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

corbett5
Copy link
Contributor

@corbett5 corbett5 commented May 21, 2024

Description

Added a keyword to ignore changes in the QN space when calling replaceind.

Fixes: Trying to change the space of a QNIndex

I use this to create a MPO with a certain set of QNs and then modify the QNs after construction. Specifically I use this to create the Fermi-Hubbard Hamiltonian on $N$ sites with full momentum conservation $\mod N$, then change this to be $\mod N/2$ after construction. Using full conservation during construction ensures maximum MPO sparsity, but the MPS seems to converge to the ground state faster when momentum is only conserved $\mod N/2$.

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.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.49%. Comparing base (12e45d0) to head (63e5388).
Report is 14 commits behind head on main.

Current head 63e5388 differs from pull request most recent head 47a97cd

Please upload reports for the commit 47a97cd to get more accurate results.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1455       +/-   ##
===========================================
- Coverage   79.19%   59.49%   -19.71%     
===========================================
  Files         147      140        -7     
  Lines        9673     9021      -652     
===========================================
- Hits         7661     5367     -2294     
- Misses       2012     3654     +1642     

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

@mtfishman mtfishman changed the title Add option to ignore space error in replaceind [ITensors] Add option to ignore space error in replaceind May 22, 2024
@mtfishman
Copy link
Member

Hi @corbett5, I'm surprised that actually works using replaceinds, it's a bit outside the scope of what the function was meant for. However, I guess because it is implemented using delta tensor contractions, those contractions are handling changing the QN structure of the tensor. We'll have to think about this a bit if this is the right place for this functionality and make sure it really works in a range of cases. I also think if we do this it should just be allowed and not be enabled with a keyword argument, but we'll need to check that the inputs actually make sense, i.e. that the QNs are compatible (say a subset of the original ones, if some are being removed).

Additionally, please take note of style guides like https://docs.julialang.org/en/v1/manual/style-guide and https://github.com/JuliaDiff/BlueStyle, essentially everything except for types and modules should be lower case, including keyword arguments. For that kind of keyword argument I would recommend snake casing, though like I said I think we probably shouldn't use a keyword argument here at all, if we decide to go through with this change. Those style guides would be relevant for https://github.com/ITensor/ITensorMPOConstruction.jl as well.

For the time being, instead of this can you manually do the same thing right now in your own code using contractions with delta tensors? It is not much less convenient than using replaceinds anyway.

@mtfishman mtfishman added the ITensors Issues or pull requests related to the `ITensors` package. label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ITensors Issues or pull requests related to the `ITensors` package.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants