# questions about metts

**URL:** <https://itensor.discourse.group/t/questions-about-metts/1143>\
**Category:** ITensor Julia Questions\
**Tags:** julia\
**Created:** [September 6, 2023, 2:20pm UTC](https://itensor.discourse.group/t/questions-about-metts/1143 "2023-09-06T14:20:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![luckyzy](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@luckyzy](https://itensor.discourse.group/u/luckyzy)\
**Post date:** [September 6, 2023, 2:20pm UTC](https://itensor.discourse.group/t/questions-about-metts/1143/1 "2023-09-06T14:20:30Z")

</div>

Hi there

My questions are very basic, they are related to the example of METTS.

1. There is a line in example, which is

```auto
      new_state = [samp[j] == 1 ? "X+" : "X-" for j in 1:N]

```

Is that mean new\_state is the maximally mixed state?

1. For boson, do we have to choose the basis under two axes in order to collapse METTS to product state ? If we need, how to define a Ry\_gates ? If we do not need to do that, I try to define a N\_gates which corresponds to Ry\_gates ,

```auto
      s = siteinds("Boson", L)
      N_gates = ops([("N", n) for n in 1:L], s)

```

Did I write correctly?

Best  
Yuanyu

---

<div class="post-metadata">

**Author:** ![luckyzy](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@luckyzy](https://itensor.discourse.group/u/luckyzy)\
**Post date:** [September 7, 2023, 11:23pm UTC](https://itensor.discourse.group/t/questions-about-metts/1143/2 "2023-09-07T23:23:00Z")

</div>

Maybe I should map the Boson Hubbard model to Heisenberg model. Then I could set the system which is S=1.

---

<div class="post-metadata">

**Author:** ![luckyzy](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@luckyzy](https://itensor.discourse.group/u/luckyzy)\
**Post date:** [September 8, 2023, 11:03am UTC](https://itensor.discourse.group/t/questions-about-metts/1143/3 "2023-09-08T11:03:23Z")

</div>

I have tried to print the 3D rotation gates , which is

```auto
ITensors.op(::OpName"RotateY",::SiteType"S=1") = [cos(pi/2) 0 sin(pi/2); 0 1 0; -sin(pi/2) 0 cos(pi/2)]

```

I am going to test if that is the right way.

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [September 9, 2023, 11:20pm UTC](https://itensor.discourse.group/t/questions-about-metts/1143/4 "2023-09-09T23:20:27Z")

</div>

Hi Yuanyu,  
The state `new_state` you defined above will make an array of strings that you can pass to the ITensor MPS constructor to make a product state. That product state MPS will then have spins in the +x direction on sites where `samp[j]==1` and in the -x direction on sites where `samp[j] != 1`. So it will be a product state of spins in the +x and -x direction based on what properties the previous sample has. (I would have to review the code to remember how samp is defined.) I’m not sure what you mean by maximally mixed state.

About rotations such as Ry, you can read about which operators are defined for the S=1/2 (same as Qubit) and the S=1 site types here:  
[https://itensor.github.io/ITensors.jl/dev/IncludedSiteTypes.html#"S1/2"-SiteType](https://itensor.github.io/ITensors.jl/dev/IncludedSiteTypes.html#%22S1/2%22-SiteType)

For examples of using these operators when they take arguments such as θ, you can look in the examples folder of the ITensors.jl source code or ask us if you can’t find such an example. There are other ways to make rotations to collapse METTS into different bases e.g. one way would be to define your own operators.

That’s good you are trying making your own operators which can be the easiest way sometimes. Try next making your operator into an ITensor and printing out its elements to confirm it worked correctly.

---

<div class="post-metadata">

**Author:** ![luckyzy](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@luckyzy](https://itensor.discourse.group/u/luckyzy)\
**Post date:** [September 10, 2023, 11:26pm UTC](https://itensor.discourse.group/t/questions-about-metts/1143/5 "2023-09-10T23:26:18Z")

</div>

Hey miles

Thanks for your reply. I still have some doubts about “gates” and function “sample!”. Here is my minimal runable code

```auto
function ITensors.op(::OpName"expτSS9", ::SiteType"Boson", n1::Index, n2::Index; τ)
  h =
   t * op("Adag", n1) * op("A", n2) + 
   t * op("Adag", n2) * op("A", n1) - 
   U2/2 * op("N * N", n1) * op("Id", n2) + 
   U2/2 * op("N", n1) * op("Id", n2) - 
   V2 * op("N", n1) * op("N", n2) - 
   miu2 * op("N", n1) * op("Id", n2)
  return exp(τ * h)
end

  so = siteinds("Boson", N, dim=3)

gates10 = ops([("expτSS9", (n, n + 1), (τ=-δτ / 2,)) for n in 1:(N - 1)], so)

append!(gates10, reverse(gates10));

psi = randomMPS(so)

τ_range = δτ:δτ:(beta / 2)

for τ in τ_range
  psi10 = apply(gates10, psi10; cutoff)
  normalize!(psi10)
  @show sample!(psi10)
end

```

There is not indicate an error, but the output of this part of code is

```auto
sample!(psi10) = [3, 3, 3, 3, 3, 3, 2, 3, 3, 2, 2, 2, 1, 3, 2, 3]
sample!(psi10) = [3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2]
sample!(psi10) = [3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 3, 2]
sample!(psi10) = [3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2, 3]
sample!(psi10) = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]
sample!(psi10) = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
sample!(psi10) = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
sample!(psi10) = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
sample!(psi10) = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
sample!(psi10) = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]

```

I do not know the number 3 refers to whether the number of particles per site is 0 or 2. Why is psi10 like this?

Yuanyu

---

<div class="post-metadata">

**Author:** ![luckyzy](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@luckyzy](https://itensor.discourse.group/u/luckyzy)\
**Post date:** [September 11, 2023, 2:24am UTC](https://itensor.discourse.group/t/questions-about-metts/1143/6 "2023-09-11T02:24:52Z")

</div>

Ooops, Did I missed the “ **im** ”?

> [@luckyzy](#):
>
> `gates10 = ops([("expτSS9", (n, n + 1), (τ=-δτ*im/ 2,)) for n in 1:(N - 1)], so)`
