dynamite.subspaces¶
Classes that define the various subspaces on which operators can be defined.
The methods generally are just an interface to the backend, so that there is only one implementation of each of the functions.
- class dynamite.subspaces.Subspace[source]¶
Bases:
object
Base subspace class.
- identical(s)[source]¶
Returns whether two subspaces are exactly the same—both the same type and with the same values.
- property L¶
The spin chain length corresponding to this space.
- property product_state_basis¶
A boolean value indicating whether the given subspace’s basis states are product states.
- get_checksum()[source]¶
Get a checksum of the state mapping for this subspace. This allows subspaces to be compared quickly.
- idx_to_state(idx)[source]¶
Maps an index to an integer that in binary corresponds to the spin configuration. Vectorized implementation allows passing a numpy array of indices as idx.
- state_to_idx(state)[source]¶
The inverse mapping of
idx_to_state()
.
- class dynamite.subspaces.Parity(space, L=None)[source]¶
Bases:
_ProductStateSubspace
The subspaces of states in which the number of up spins is even or odd.
- Parameters:
space (int) – Either 0 or ‘even’ for the even subspace, or 1 or ‘odd’ for the other.
- property space¶
- class dynamite.subspaces.SpinConserve(L, k, spinflip=None)[source]¶
Bases:
_ProductStateSubspace
The subspaces of states which conserve total magnetization (total number of up/down spins).
- Parameters:
L (int) – Length of spin chain
k (int) – Number of down spins (1’s in integer representation of state)
spinflip (None) – (deprecated, use
XParity
subspace)
- property k¶
The number of down (“1” in binary representation) spins.
- class dynamite.subspaces.Explicit(state_list, L=None)[source]¶
Bases:
_ProductStateSubspace
A subspace generated by explicitly passing a list of product states.
- Parameters:
state_list (array-like) – An array of integers representing the states (in binary).
- class dynamite.subspaces.Auto(H, state, size_guess=None, sort=True)[source]¶
Bases:
Explicit
Automatically generate a mapping that takes advantage of any possible spin conservation law, by performing a breadth-first search of the graph of possible states using the operator as an adjacency matrix. The subspace is defined by providing a “start” state; the returned subspace will be whatever subspace contains that state.
Currently the actual computation of the ordering only can occur on process 0, limiting the scalability of this subspace.
- Parameters:
H (dynamite.operators.Operator) – The operator for which this custom subspace will be defined.
state (int or string) – An integer whose binary representation corresponds to the spin configuration of the “start” state mentioned above, or string representing the same. See
dynamite.states.State.str_to_state()
for more information.size_guess (int) – A guess for the dimension of the subspace. By default, memory is allocated for the full space, and then trimmed off if not used.
sort (bool) – Whether to reorder the mapping after computing it. In some cases this may cause a speedup.
- class dynamite.subspaces.XParity(parent=None, sector='+', L=None)[source]¶
Bases:
Subspace
This class implements the Parity subspace, but in the X basis instead of the Z basis. Unlike the other subspaces, it can be applied on top of another subspace by passing that subspace as the
parent
argument.In the Z basis, the basis states of this subspace are not product states, but rather states of the form \(\left|c\right> + \left|\bar c \right>\), where \(\left|c\right>\) is a product state and \(\left|\bar c\right>\) is its complement (all spins flipped). In dynamite’s interface, these basis states are represented by the bitstring \(c\) or \(\bar c\) that is lexicographically first (that is, the one having spin L-1 in the \(\left|0\right>\) state).
- property parent¶
The parent subspace upon which XParity has been applied.
- property sector¶
The sector of the xparity symmetry. Returns +1 or -1 as an integer.
- reduce_msc(msc, check_conserves=False)[source]¶
Return an equivalent (in the subspace) but simpler MSC representation for the operator, by taking advantage of the subspace’s symmetries.
- Parameters:
msc (dynamite.msc_tools.msc_dtype) – The input MSC representation
check_conserves (bool) – Whether to return whether the operator was conserved
- Returns:
dynamite.msc_tools.msc_dtype – The reduced version
bool – Whether the operator was conserved during the operation