quantax.operator.Operator#

class quantax.operator.Operator#

Quantum operator

__init__(op_list: list)#
Parameters:

op_list

The operator represented as a list in the QuSpin format

[[opstr1, [strength1, index11, index12, ...]], [opstr2, [strength2, index21, index22, ...]], ...]

opstr:

a string representing the operator type. The convention is chosen the same as pauli=0 in QuSpin

strength:

interaction strength

index:

the site index that operators act on

__matmul__(other: State | Operator) DenseState#

Apply the operator on a ket state by H @ state to get \(H \left| \psi \right>\), or multiply two operators by H1 @ H2. The exact expectation value \(\left<\psi|H|\psi \right>\) can be computed by state @ H @ state.

__rmatmul__(state: State) DenseState#

Apply the operator on a bra state by state @ H to get \(\left< \psi \right| H\). The exact expectation value \(\left<\psi|H|\psi \right>\) can be computed by state @ H @ state.

__add__(other: Number | Operator) Operator#

Add two operators.

__iadd__(other: Operator) Operator#

In-place addition of two operators.

__sub__(other: Number | Operator) Operator#

Subtract two operators.

__isub__(other: Number | Operator) Operator#

In-place subtraction of two operators.

__mul__(other: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Operator#

Multiply an operator with a scalar.

__rmul__(other: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Operator#

Multiply an operator with a scalar.

__imul__(other: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Operator#

In-place multiplication of an operator with a scalar.

__neg__() Operator#

Negate an operator.

__truediv__(other: Number) Operator#

Divide an operator by a scalar.

__itruediv__(other: Number) Operator#

In-place division of an operator by a scalar.

property op_list: list#

Operator represented as a list in the QuSpin format

property jax_op_list: list#

Operator list with jax arrays, made easy for applying operator to basis states

property expression: str#

The operator as a human-readable expression

get_quspin_op(symm: Symmetry | None = None) 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 | str = 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 eigenvalue w[i].

property H: Operator#

Hermitian conjugate

Oloc(state: State, samples: Samples | ndarray | Array) Array#

Computes the local operator \(O_\mathrm{loc}(s) = \sum_{s'} \frac{\psi_{s'}}{\psi_s} \left< s|O|s' \right>\)

Parameters:
Returns:

A 1D jax array \(O_\mathrm{loc}(s)\)

expectation(state: State, samples: Samples | ndarray | Array | LogArray | ScaleArray, return_var: bool = False) float | Tuple[float, 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