Hi everyone,
I’m trying to artificially increase the bond dimensions of a product-state MPS to a given bond dimension N (since I want to use this state in a TDVP evolution algorithm with fixed bond dimensions). I start from
sites = siteinds("Qubit", 10; conserve_parity=true)
initstate = MPS(sites, "0")
Normally, without QNs, I would use the method described here to “artificially” enlarge the bond dimension to the desired size.
Taking quantum numbers into account, I defined the following function:
function enlarge!(v::MPS, new_d)
N = length(v)
if hasqns(v[1])
lflux = sum(flux, v[1:end-1])
enlarged_links = Vector{ITensors.QNIndex}(undef, N - 1)
for bond in (N - 1):-1:1
enlarged_links[bond] = dag(Index(lflux => new_d; tags=tags(commonind(v[bond], v[bond + 1]))))
lflux -= flux(v[bond])
end
else
enlarged_links = [
Index(new_d; tags=tags(commonind(v[bond], v[bond + 1]))) for bond in 1:(N - 1)
]
end
@show first(linkinds(v), 5)
@show first(enlarged_links, 5)
for bond in 1:(N - 1)
bond_index = commonind(v[bond], v[bond + 1])
v[bond] = v[bond] * delta(dag(bond_index),enlarged_links[bond])
v[bond + 1] = v[bond + 1] * delta(bond_index, dag(enlarged_links[bond]))
end
return v
end
I took inspiration from the MPS constructor method
MPS(eltype::Type{<:Number}, sites::Vector{<:Index}, states_)
in ITensors/…/src/lib/ITensorMPS/src/mps.jl to define the new link indices, since this constructor is what gets called when I create the product state above; I figured I would get the same index structure.
Unfortunately this does not happen: the @show statements print
julia> enlarge!(initstate, 10)
first(linkinds(v), 5) = Index{Vector{Pair{QN, Int64}}}[(dim=1|id=315|"Link,l=1") <In>
1: QN("Parity",1,2) => 1, (dim=1|id=773|"Link,l=2") <In>
1: QN("Parity",0,2) => 1, (dim=1|id=639|"Link,l=3") <In>
1: QN("Parity",1,2) => 1, (dim=1|id=593|"Link,l=4") <In>
1: QN("Parity",0,2) => 1, (dim=1|id=474|"Link,l=5") <In>
1: QN("Parity",1,2) => 1]
first(enlarged_links, 5) = Index{Vector{Pair{QN, Int64}}}[(dim=10|id=583|"Link,l=1") <In>
1: QN("Parity",0,2) => 10, (dim=10|id=654|"Link,l=2") <In>
1: QN("Parity",0,2) => 10, (dim=10|id=118|"Link,l=3") <In>
1: QN("Parity",0,2) => 10, (dim=10|id=72|"Link,l=4") <In>
1: QN("Parity",0,2) => 10, (dim=10|id=973|"Link,l=5") <In>
1: QN("Parity",0,2) => 10]
and as you can see the alternating parity in the link indices is lost in the enlarged MPS.
So I ask you: what isn’t working in my method? Or is there another way I can enlarge the bond dimensions of an MPS?