Hi! I would like to create a product state with custom parameterized states defined on each site. In this example, the custom parameterized states are coherent states with an input parameter \alpha. The code below successfully passes \alpha into the construction of the coherent state ITensor, but I am not sure the best way to then pass it into the productMPS construction.
I was able to reference these posts about defining custom (coherent) states (Defining states with parameters as keyword arguments and Definition of a new bosonic state - #4 by kmp5) , but I would like to go one step further and make it a customized productMPS state.
I figure this could be done either by
- Inputing an array of ITensor states, which would then be input into the productMPS function
using ITensors, ITensorMPS
using LinearAlgebra
# annihilation operator
a_op(d) = diagm(1 => [sqrt(i) for i in 1:(d-1)])
# matrix elements of the displacement operator
D(α::ComplexF64, d::Int) = exp(α*a_op(d)'-α'*a_op(d))
# Coherent state on a single site
function ITensors.state(::StateName"coherent", ::SiteType"Boson", s::Index; α::Union{Float64, ComplexF64})
@show α
D(α, dim(s))*[if n==1 1 else 0 end for n=1:dim(s)]
end
# Number of sites
N = 3
# Hilbert Space truncation
d = 10
sites = siteinds("Boson", N; dim=d);
# Prepare the product state from an array of ITensor
# coherent states on each site
α = 10*im
states = [state("coherent", sites[i]; α=α) for i in 1:N ]
ψ_coherent = productMPS(ComplexF64, states)
which gives the following error:
ERROR: LoadError: MethodError: no method matching MPS(::Type{ComplexF64}, ::Vector{ITensor})
- Or, alternatively, pass the parameter directly into the
productMPS
like
# # Or be able to pass the parameter values directly into the productMPS (Prefered)
ψ_coherent = productMPS(ComplexF64, sites, "coherent"; α = α)
which gives the following error
ERROR: LoadError: MethodError: no method matching MPS(::Type{ComplexF64}, ::Vector{Index{Int64}}, ::String; α::ComplexF64)
I think I’m missing how to best input these states into the productMPS function and any guidance would be greatly appreciated!