How to contract 2 MPS objects

Hey all!
If I want to couple an outer spin to a spin chain.
my original thought was to try and build to MPS one of the dimensions of the chain, and the other with dim of 1 (for the spin), but I can’t contract the MPS’s.
Does someone knows what is the best way to do it ?
Screen Shot 2022-08-09 at 9.53.03

I’d like to help you but there are some issues with the code you posted that I am not sure about:

  • The image is cut off, so it doesn’t show the whole code or error messages. Can you please post the code as text, using 3 backticks (''' … code … ''') to surround the block of code?
  • What is ITensor(0,p) supposed to be doing?
  • What is the intent of the rest of the code (i.e. what is the meaning of P, Q, QU, etc.)?

Based on the first part of your question, when you say couple a spin to a spin chain, by “a spin chain” do you mean you already have the ground state of that spin chain? Or are you trying to make a specific wavefunction? Or are you just trying to build a model or Hilbert space you can use to initialize e.g. a DMRG calculation? Thanks –

@miles This is marked as solved, but I’m not able to find the solution.
I do have the same problem. I have generated an MPS of length N-1:

sites = siteinds(“Fermion”, 3)
states_psi = [“0” for i in 1:2]
psi = MPS(sites[1:2], states)

Now I want to append another Fermion, means I want to create a state on \mathcal{H}^N. In physics language I would like to take the Kronecker product of psi with another state phi.

states_phi = [“1”]
phi = MPS([sites[end]], states_phi)

# Kronecker product
chi = psi * phi

For MPOs there is the possibillity to construct and MPO on a larger Hilbert space via contract(), where the resulting MPO lives on all indices which are not shared between the former MPOs.
For MPS this contraction yields the following error.

ERROR: MethodError: no method matching contract(::MPS, ::MPS)
Closest candidates are:
contract(::NDTensors.DiagTensor, ::Any, ::NDTensors.Tensor{ElT, N, StoreT, IndsT} where {ElT, N, IndsT, StoreT<:NDTensors.Combiner}, ::Any) at .julia/packages/NDTensors/FHyfI/src/combiner/combiner.jl:125
contract(::NDTensors.DiagBlockSparseTensor, ::Any, ::NDTensors.BlockSparseTensor, ::Any) at .julia/packages/NDTensors/FHyfI/src/blocksparse/diagblocksparse.jl:565
contract(::NDTensors.DiagBlockSparseTensor, ::Any, ::NDTensors.BlockSparseTensor, ::Any, ::Any) at .julia/packages/NDTensors/FHyfI/src/blocksparse/diagblocksparse.jl:565

[1] *(A::MPS, B::MPS; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors .julia/packages/ITensors/fpBnt/src/mps/abstractmps.jl:1681
[2] *(A::MPS, B::MPS)
@ ITensors .julia/packages/ITensors/fpBnt/src/mps/abstractmps.jl:1681
[3] top-level scope
@ REPL[12]:1

Is there some concise solution for this Kronecker product of MPS or am I missing something obvious?

For Background: I try to create a specific MPS iteratively by appending new sites.