# Construct outer product of mixed-type delta's as an MPS

**URL:** <https://itensor.discourse.group/t/construct-outer-product-of-mixed-type-deltas-as-an-mps/2164>\
**Category:** ITensor Julia Questions\
**Tags:** julia, mps\
**Created:** [December 10, 2024, 6:13pm UTC](https://itensor.discourse.group/t/construct-outer-product-of-mixed-type-deltas-as-an-mps/2164 "2024-12-10T18:13:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhen\_H](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/zhen_h/32/764_2.png) [@Zhen\_H](https://itensor.discourse.group/u/Zhen_H)\
**Post date:** [December 10, 2024, 6:13pm UTC](https://itensor.discourse.group/t/construct-outer-product-of-mixed-type-deltas-as-an-mps/2164/1 "2024-12-10T18:13:23Z")

</div>

Hi,

Given the following (mixed) sites (2 spin + 2N bosons):

```julia
using ITensors
sites = append!(siteinds("S=1/2",2), siteinds("Boson", N * 2 ; dim=d)

```

I’d like to construct the following MPS:

|\Psi\rangle = \left(|00\rangle + |11\rangle\right)\otimes \left(|00\rangle + |11\rangle +\cdots |d-1,d-1\rangle\right)\otimes\cdots\otimes \left(|00\rangle + |11\rangle +\cdots |d-1,d-1\rangle\right).

I am wondering what is the best way to do this in iTensor.

A little bit background: the vector |\Psi\rangle is the left vector used in third quantization, the inner product of which is equivalent to taking trace in the operator space.

---

<div class="post-metadata">

**Author:** ![Zhen\_H](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/zhen_h/32/764_2.png) [@Zhen\_H](https://itensor.discourse.group/u/Zhen_H)\
**Post date:** [December 16, 2024, 6:29am UTC](https://itensor.discourse.group/t/construct-outer-product-of-mixed-type-deltas-as-an-mps/2164/2 "2024-12-16T06:29:14Z")

</div>

I found a way to _ **manually** _ do this. Admittedly not very elegant, but it seems to be doing the trick. Please let me know what you think and if there is a more elegant / efficient way to do this…

```auto
N = 10
dim = 4
sites = append!(siteinds("S=1/2",2), siteinds("Boson", N * 2 ; dim=dim))

vac_left = MPS(sites,"0")

spin_id = productMPS(sites[1:2],["0","0"]) + productMPS(sites[1:2],["1","1"])

vac_left[1] = spin_id[1]
s2 = Array(spin_id[2], siteind(spin_id,2), linkind(spin_id,1))
s2 = reshape(s2, 1,2,2)
vac_left[2] = ITensor(s2, linkind(psi1,2), siteind(spin_id,2), linkind(spin_id,1))

for i in 1:N
    boson_id = productMPS(sites[2*i+1:2*i+2],["0","0"]) 
    for d in 2:dim
        boson_id = boson_id + productMPS(sites[2*i+1:2*i+2],[string(d-1),string(d-1)]) 
    end
    t1 = reshape(diagm(ones(dim)),1,dim,dim)
    vac_left[2*i+1] = ITensor(t1, linkind(psi1,2*i), siteind(boson_id,1), linkind(boson_id,1))
    if i<N
        vac_left[2*i+2] = ITensor(t1, linkind(psi1,2*i+2), siteind(boson_id,2), linkind(boson_id,1))
    else
        vac_left[2*i+2] = boson_id[2]
    end
end

```
