Add features to map graph nodes to Hilbert space sites
Created by: femtobit
As brought up in #922 (closed), in composite systems like
hi = Fock(N=1) * Spin(1/2, N=10)
it'd be nice to be able to define graph operators acting on subsets of Hilbert sites. This requires a mapping from the graph nodes to Hilbert sites.
With this PR, this can be provided when creating GraphOperator
(and Heisenberg
, which is a subclass):
g = Chain(10)
h = Heisenberg(hi, g, acting_on_subspace=list(range(1, 11)))
# equivalently as a shorthand:
h = Heisenberg(hi, g, acting_on_subspace=1)
(Closes #922 (closed).)
EDIT: Updated examples with alternative design which uses graph.node_labels
.
EDIT 2: Updated examples with current naming.
EDIT 3: Updated example back to initial version.