applying a local reset gate to an mps

Hi everyone,

I am pretty sure that you can help me with the following question.

Is there a gate or an operation that resets a qubit in a MPS. For instance, if I create a randomMPS,

N= 3
sites = siteinds(“S=1/2”,N)
ranmps = randomMPS(sites)

is it possible to reset one or some of the qubits to |Dn>?

Yes, there is a “ProjDn” operator defined for the “S=1/2” site type that you can use, which will project a spin into the down state.

You can get this operator on site number j by doing
P = op(“ProjDn”,sites[j]). Then you can apply it by using the apply function.

1 Like

Dear @miles,
Thanks a lot for your time. I was checking your suggestion and it seems that there is a problem with sample

sample: MPS m must have orthocenter(m)==1

Is there a way to solve it ?

my code is the following

N = 3
sites = siteinds("S=1/2", N)
states1 = ["Up","Up","Up"]
states2 = ["Dn","Dn","Dn"]
psi1 = MPS(sites,states1)
psi2 = MPS(sites,states2)
psi = normalize!(psi1+psi2)

P = op("ProjDn",sites[2])
psi2=apply(P,psi)
normalize!(psi2)

magz = expect(psi2,"Sz")
for (j,mz) in enumerate(magz)
    println("$j $mz")
end

sample(psi2)

The expectation value is the following

1 -0.5
2 -0.5
3 -0.5

I was hoping
1 0.0 (or close to 0.0)
2 -0.5
3 0.0 (or close to 0.0)
and sample gives the following error

sample: MPS m must have orthocenter(m)==1

Hi, yes we may improve that interface in the future. Please use sample! which modifies the orthogonality center for you internally, or else before calling sample, call orthogonalize(psi,1)

1 Like