Hi Yotam,
I don’t think you need to pass alpha explicitly because its a variable in the function D
. I ran a quick test
using ITensors
let
N = 2 # number of bosons
d = 5 # local oscillator cutoff dimension
sites = siteinds("Boson", N; dim=d); # create the site indices for MPS representation
α = 0.01 # the coherent state's parameter
a_op(d) = diagm(1 => [sqrt(i) for i in 1:(d-1)]) # annihilation operator
D(α, d) = exp(α*a_op(d)'-α'*a_op(d)) # matrix elements of the displacement operator
function ITensors.state(::StateName"coherent", ::SiteType"Boson", s::Index)
@show α
D(α, dim(s))*[if n==1 1 else 0 end for n=1:dim(s)]
end
ψ₀ = MPS(sites, "coherent")
println("Finished with ψ₀")
α = 0.2
ϕ = MPS(sites, "coherent")
println("Finished with ϕ")
return
end
and see this as the output
α = 0.01
α = 0.01
Finished with ψ₀
α = 0.2
α = 0.2
Finished with ϕ