# Creating replicas of a ground state from DMRG.

**URL:** <https://itensor.discourse.group/t/creating-replicas-of-a-ground-state-from-dmrg/1725>\
**Category:** ITensor Julia Questions\
**Created:** [May 17, 2024, 3:16pm UTC](https://itensor.discourse.group/t/creating-replicas-of-a-ground-state-from-dmrg/1725 "2024-05-17T15:16:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RPaul-Smith](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/rpaul-smith/32/547_2.png) [@RPaul-Smith](https://itensor.discourse.group/u/RPaul-Smith)\
**Post date:** [May 17, 2024, 3:16pm UTC](https://itensor.discourse.group/t/creating-replicas-of-a-ground-state-from-dmrg/1725/1 "2024-05-17T15:16:54Z")

</div>

Hi all,

I’ve been using ITensor for a bit now and I am really enjoying using this package. I do have a couple of questions to ask and any help on them would be greatly appreciated.

1. I am using DMRG to calculate the ground state |\psi\rangle for a given Hamiltonian. Once I have this ground state at a bond dimension \chi is it possible to create multiple copies of the same ground state i.e. calculate |\psi\rangle^{\otimes 4} ?

2. If it is possible to create the replicas then would it also be possible to define an operator or MPO which can act across the same site in all 4 replicas which would allow me to take expectation values of this operator/MPO?

Thank you for any advice on my questions.

---

<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:** [May 17, 2024, 4:21pm UTC](https://itensor.discourse.group/t/creating-replicas-of-a-ground-state-from-dmrg/1725/2 "2024-05-17T16:21:41Z")

</div>

Interesting question. Yes, ITensor makes it straightforward to do this even though we don’t have a function to do it in one step.

Here’s a pattern you can use:

1. make a new array of site indices that is 4 times longer than your original one. So like `snew = siteinds("S=1/2",4*N)` (here I assumed S=1/2 sites but of course use the correct site type that you originally used for the length N system)

2. make an empty MPS of length 4N like this: `psi_new = MPS(snew)`

3. write a loop where you copy the original MPS, change its site indices to match the appropriate subarray of `snew`, and copy these tensors into `mnew`, like this:

```julia
for r=1:4
  range = 1+(r-1)*N:r*N
  psi_r = replace_siteinds(psi,snew[range])
  for (i,j) in enumerate(range)
       psi_new[j] = psi_r[i]
  end 
end

```

I haven’t tested the above code but I think it should work.

1. for good measure, I would lastly call `orthogonalize!(psi_new,1)` which will “gauge” the new MPS and also insert any missing virtual or link indices that might not be there from the above code

Then you can measure any operator you wish, using the new site index array `snew` to generate operators either as ITensors or using our OpSum to MPO conversion system.

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [May 17, 2024, 7:08pm UTC](https://itensor.discourse.group/t/creating-replicas-of-a-ground-state-from-dmrg/1725/3 "2024-05-17T19:08:00Z")

</div>

Note that you should use the latest version of ITensors (v0.6.10) if you want to use `replace_siteinds`, which fixes a bug in `replace_siteinds`: [[ITensorMPS] Make `replace_siteinds` non-mutating by mtfishman · Pull Request #1449 · ITensor/ITensors.jl · GitHub](https://github.com/ITensor/ITensors.jl/pull/1449).

Otherwise, on older versions of ITensors.jl use:

```julia
  psi_r = replace_siteinds!(deepcopy(psi),snew[range])

```
