ITensor / ITensors.jl

A Julia library for efficient tensor computations and tensor network calculations
https://itensor.org
Apache License 2.0
522 stars 122 forks source link

Change keyword argument set_limits to preserve_ortho #476

Open mtfishman opened 4 years ago

mtfishman commented 4 years ago

Right now, the keyword argument set_limits = false is used to turn off ITensor's internal process for setting the limits of an MPS/MPO if tensors outside of the orthogonality center are replaced. A better name for this would be preserve_ortho, as suggested by Miles.

mtfishman commented 3 years ago

Another idea is to provide a macro @preserve_ortho. This would provide a block of code that the user specifies will preserve the orthogonality limits of the MPS/MPO. The user may have to specify which MPS/MPO gets preserved in the block, for example:

psi = randomMPS(s)
@preserve_ortho psi begin
  psi .= prime.(psi)
  psi .= addtags.(psi, "x")
end

It could be implemented by first saving the orthogonality limits of the specified MPS/MPO, performing the operations in the block, and then setting the orthogonality limits back to the original ones at the end of the code block.

Perhaps it can also be implemented in a way that the MPS/MPO doesn't have to be specified, in which case all MPS/MPO orthogonality limits get preserved, but that may be more subtle (I wouldn't know how to search the code block for all the MPS/MPO but perhaps there are tools for that).