# How set the maximal number states in the TEBD evolution? [julia]

edited

Hi, evergyone.

who knows how set the maximal number states in the TEBD evolution?

the codes as follow

using ITensors

let
N = 100
cutoff = 1E-8
tau = 0.1
ttotal = 5.0

# Compute the number of steps to do
Nsteps = Int(ttotal/tau)

# Make an array of 'site' indices
s = siteinds("S=1/2",N;conserve_qns=true)

# Make gates (1,2),(2,3),(3,4),...
gates = ITensor[]
for j=1:N-1
s1 = s[j]
s2 = s[j+1]
hj = op("Sz",s1) * op("Sz",s2) +
1/2 * op("S+",s1) * op("S-",s2) +
1/2 * op("S-",s1) * op("S+",s2)
Gj = exp(-1.0im * tau/2 * hj)
push!(gates,Gj)
end
# Include gates in reverse order too
# (N,N-1),(N-1,N-2),...
append!(gates,reverse(gates))

# Initialize psi to be a product state (alternating up and down)
psi = productMPS(s, n -> isodd(n) ? "Up" : "Dn")

c = div(N,2) # center site

# Compute and print initial value on site c
t = 0.0
Sz = expect(psi,"Sz";site_range=c:c)
println("$t$Sz")

# Do the time evolution by applying the gates
# for Nsteps steps and printing on site c
for step=1:Nsteps
psi = apply(gates, psi; cutoff=cutoff)
t += tau
Sz = expect(psi,"Sz";site_range=c:c)
println("$t$Sz")
end

return
end

You should be able to use the keyword maxdim.

commented by (550 points)
edited by
Thanks a lot.
more question :  the system has 'conserve_qns=true'. I want to overlap the psi with another state $\psi_f=(|00>+|11>)_{1,2}(|00>+|11>)_{3,4}......(|00>+|11>)_{99,100}$.
s1=removeqns(s)
.....

inner(psi,psif)

ERROR: LoadError: Indices must have the same spaces to be replaced.
commented by (14.1k points)
You could try:

psi_dense = removeqns(psi)
inner(psi_dense, psif)

So that you take the inner product of two states without qns.
commented by (550 points)
another error :   LoadError: MethodError: no method matching removeqns(::MPS)
commented by (14.1k points)
Sorry about that, try psi_dense = dense(psi) instead.

removeqns should be defined, that's a bug. I'll raise an issue about it.
commented by (550 points)
Thank you again. The code can be executed. Another method  we change
s = siteinds("S=1/2",N;conserve_qns=true)  to  s = siteinds("S=1/2",N;conserve_qns=false).
The evolution of system will need more time  and more memory.
Best wishes