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

Added example file with Infinite MPS to finite MPS function #72

Merged
merged 8 commits into from Mar 2, 2023

Conversation

nbaldelli
Copy link
Contributor

Related to #71.

I mainly added a function toMPS that

  1. takes a slice of an InfiniteCanonicalMPS
  2. puts it in a canonical form with the change of gauge on the last link
  3. adds two copy tensors at the beginning and end of the chain to add two "Dummy" sites to contract the dangling Link indices of the slice.
  4. It finally returns a finite MPS.

I added two functions computing the correlation matrix (by explicitly applying the operators) for both the infinite and infinite chain to check for consistency. I did not add the comparison with the correlation function from ITensorCorrelators as It would add a dependency.

@mtfishman
Copy link
Member

Thanks @nbaldelli, I like the idea of adding "dummy tensors" at the boundaries so it looks more like a finite MPS without dangling indices. Here is a simpler implementation:

function finite_mps::InfiniteCanonicalMPS, range::AbstractRange)
  @assert isone(step(range))
  ψ_finite = ψ.AL[range]
  ψ_finite[last(range)] *= ψ.C[last(range)]
  l0 = linkind.AL, first(range) - 1 => first(range))
  lN = linkind.AR, last(range) => last(range) + 1)
  ψ_finite = MPS([δ(l0, dag(l0)'); [ψ_finiteᵢ for ψ_finiteᵢ in ψ_finite]; δ(dag(lN), lN')])
  set_ortho_lims!(ψ_finite, (last(range) + 1):(last(range) + 1))
  return ψ_finite
end

This seems worth adding to the package. Could you make a PR for that, with a simple test? Then we don't need to implement this as a separate example, but just add the use of finite_mps to an existing example.

I noticed that when I do:

range = 1:6
correlation_matrix(finite_mps(ψ, range), "Sz", "Sz"; sites=(range .+ 1))

correlation_matrix throws an error about trying to make an "Sz" operator on site 1 (a site with the link index). It shouldn't have to do that in principle, it is a simple fix to make sure it skips that site (currently it just uses site 1 by default to analyze the Hermiticity of the operator, but we can just use first(sites)).

@mtfishman
Copy link
Member

mtfishman commented Mar 1, 2023

@nbaldelli I fixed the issue with correlation_matrix in ITensor/ITensors.jl#1081 so now the code

range = 1:6
correlation_matrix(finite_mps(ψ, range), "Sz", "Sz"; sites=(range .+ 1))

should work (once the new version of ITensors.jl is registered).

@nbaldelli
Copy link
Contributor Author

Hi Matt, just tested the code with your formulation of finite_mps and the new fix in ITensor/ITensors.jl#1081 and it works, I pushed the new changes and moved the test to the Ising model example file.

@mtfishman
Copy link
Member

Thanks @nbaldelli. Could you run the formatter to format the code? You can use:

julia> using JuliaFormatter, ITensorInfiniteMPS; format(pkgdir(ITensorInfiniteMPS))

@nbaldelli
Copy link
Contributor Author

Cleaning up the code, in the end I moved the example to vumps_hubbard_extended.jl where there is already a comparison with the finite DMRG results.

@nbaldelli
Copy link
Contributor Author

@mtfishman I think everything is fine now

@mtfishman
Copy link
Member

It looks like you still need to add finite_mps to the export list in src/ITensorInfiniteMPS.jl.

@mtfishman
Copy link
Member

Great, thanks @nbaldelli!

@mtfishman mtfishman merged commit 167abfb into ITensor:main Mar 2, 2023
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.

None yet

2 participants