google / TensorNetwork

A library for easy and efficient manipulation of tensor networks.
Apache License 2.0
1.82k stars 358 forks source link

quantum operators #393

Open mganahl opened 4 years ago

mganahl commented 4 years ago

This is related to #366, #379 and #390 For backend independent initialization of e.g. MPOs we need abstract quantum operators like e.g. spin (Sx, Sy, Sz) or fermionic/bosonic ladder operators.

The initialization for MPOs I have in mind is

import tensornetwork as tn
backend='numpy'
Sx = tn.quantum.Sx(backend=backend)
Sy = tn.quantum.Sy(backend=backend)
Sz = tn.quantum.Sz(backend=backend)
J = 1
N = 10
mpo = tn.FiniteMPO(backend=backend)
for n in range(N-1):
  mpo.add_two_body_term(Sx, Sx, n, n+1, J)
  mpo.add_two_body_term(Sy, Sy, n, n+1, J)
  mpo.add_two_body_term(Sz, Sz, n, n+1, J)
mpo.finalize()
chaserileyroberts commented 4 years ago

Looks nice!

Not sure what finalize should do though.

mganahl commented 4 years ago

MPOs are not unique, and there are simple but suboptimal ways of building them. One can compress them losslessly and pretty efficiently, but only once all the terms in the MPO are know. That's what finalize would be doing

chaserileyroberts commented 4 years ago

I think this would be nice to have just in general.

We should build a list of operators that we would likely want.

Examples:

X Y Z T H CNOT Toffile Sx Sy Sz.

Any others?

rdilip commented 4 years ago

I'm new to this library, but I think it would be helpful to have common bosonic operators as well? Namely B, Bd, N, NN?

I have a decent amount of this code written and would be happy to work on this if someone else is not already, but I have not contributed much to large projects before and would need some pointers on the preferred way to write tests, formatting, etc.?