quantax.operator.Operator#
- class quantax.operator.Operator#
Quantum operator
- __init__(op_list: list[OpTerm])#
- Parameters:
op_list β
The operator represented as a list of
OpTerm. EachOpTermgroups all terms that share the same operator stringopstrtogether with their strengths and site indices:
- __matmul__(other: Operator) Operator#
- __matmul__(other: State) DenseState
Apply the operator on a ket state by
H @ stateto get \(H \left| \psi \right>\), or multiply two operators byH1 @ H2. The exact expectation value \(\left<\psi|H|\psi \right>\) can be computed bystate @ H @ state.
- __rmatmul__(state: State) DenseState#
Apply the operator on a bra state by
state @ Hto get \(\left< \psi \right| H\). The exact expectation value \(\left<\psi|H|\psi \right>\) can be computed bystate @ H @ state.
- __mul__(other: Array | ndarray | bool | number | bool | int | float | complex) Operator#
Multiply an operator with a scalar.
- __rmul__(other: Array | ndarray | bool | number | bool | int | float | complex) Operator#
Multiply an operator with a scalar.
- __imul__(other: Array | ndarray | bool | number | bool | int | float | complex) Operator#
In-place multiplication of an operator with a scalar.
- property op_list: list[OpTerm]#
Operator represented as a list in the QuSpin format
- property quspin_static_list: list#
The operator in the QuSpin static-list format
[[opstr, [[strength, *site_indices], ...]], ...].
- property jax_op_list: list[tuple[dict[str, Any], tuple[OpTermJAX, ...]]]#
Operator list with jax arrays, made easy for applying operator to basis states.
The format is
[(update_mode1, op_terms1), (update_mode2, op_terms2), ...], where eachupdate_modeis a dictionary produced by the update-mode filter and eachop_termsis a tuple ofOpTermJAXholding the jax-array strengths and indices of the terms in that update mode.
- property expression: str#
The operator as a human-readable expression
- apply_update_mode_filter(update_mode_filter: Callable[[str, Sequence[int]], dict[str, Any]]) None#
Apply a filter function to update the operatorβs jax_op_list with additional update_mode information for each operator term.
- Parameters:
update_mode_filter β A function that takes an operator string and its corresponding site indices, and returns a dictionary of update_mode.
- get_quspin_op(symm: Symmetry | None = None) quspin.operators.hamiltonian#
Obtain the corresponding QuSpin operator
- Parameters:
symm β The symmetry used for generate the operator basis, by default the basis without symmetry
- todense(symm: Symmetry | None = None) ndarray#
Obtain the dense matrix representing the operator
- Parameters:
symm β The symmetry used for generate the operator basis, by default the basis without symmetry
- diagonalize(symm: Symmetry | None = None, k: int | Literal['full'] = 1) tuple[NDArray, NDArray]#
Diagonalize the hamiltonian \(H = V D V^β \)
- Parameters:
symm β Symmetry for generating basis.
k β A number specifying how many lowest states to obtain, or βfullβ for all eigenstates.
- Returns:
- w:
Array of k eigenvalues.
- v:
An array of k eigenvectors.
v[:, i]is the eigenvector corresponding to the eigenvaluew[i].
- apply_diag(s: Array) Array#
Apply the diagonal part of the operator to a batch of configurations
s, returning the diagonal matrix elements \(\left< s|O|s \right>\).
- apply_off_diag(s: Array) list[tuple[dict[str, Any], Array, Array]]#
Apply the off-diagonal part of the operator to a batch of configurations
s.- Returns:
A list of
(update_mode, s_conn, strength)grouped by update mode, wheres_connare the connected configurations \(s'\) andstrengththe corresponding matrix elements \(\left< s'|O|s \right>\).
- Oloc(state: State, samples: Samples | NDArray[integer] | Array) Array#
Computes the local operator \(O_\mathrm{loc}(s) = \sum_{s'} \frac{\psi_{s'}}{\psi_s} \left< s|O|s' \right>\)
- Parameters:
state β A
quantax.state.Statefor computing \(\psi\)samples β A batch of samples \(s\)
- Returns:
A 1D jax array \(O_\mathrm{loc}(s)\)
- expectation(state: State, samples: Samples | Array, return_var: Literal[False] = False) complex#
- expectation(state: State, samples: Samples | Array, return_var: Literal[True]) tuple[complex, float]
The expectation value of the operator
- Parameters:
state β The state for computing \(\psi\) in \(O_\mathrm{loc}\)
samples β The samples for estimating \(\left< O_\mathrm{loc} \right>\)
return_var β Whether the variance should also be returned, default to False
- Returns:
- Omean:
Mean value of the operator \(\left< O_\mathrm{loc} \right>\)
- Ovar:
Variance of the operator \(\left< |O_\mathrm{loc}|^2 \right> - |\left< O_\mathrm{loc} \right>|^2\), only returned when
return_var = True