Tools for a Quantum Many Body (QMB) State

State-vector utilities for expectation values, reduced density matrices, entanglement measures, and support-based diagnostics.

Typical workflow:

  • build a QMB_state from a state vector,

  • normalize or truncate it if needed,

  • evaluate observables and reduced density matrices,

  • use the entanglement and stabilizer helper modules for lower-level support extraction or reduced-density-matrix workflows when needed.

Utilities to analyze and manipulate quantum many-body states.

This module provides the QMB_state class and several helper functions for expectation values, reduced density matrices, entanglement measures, support extraction, and density-matrix post-processing.

class edlgt.modeling.qmb_state.QMB_state(psi, lvals=None, loc_dims=None, symmetry_sector=True, debug_mode=False)[source]

Container and analysis methods for a quantum many-body state vector.

Initialize a many-body state.

Parameters:
  • psi (numpy.ndarray) – State vector coefficients.

  • lvals (list, optional) – Lattice dimensions.

  • loc_dims (int or list or numpy.ndarray, optional) – Local Hilbert-space dimensions per site.

  • symmetry_sector (bool, optional) – If True, treat psi as living in a symmetry-reduced basis.

  • debug_mode (bool, optional) – If True, perform additional internal consistency checks.

Return type:

None

normalize(threshold=1e-14)[source]

Normalize the state vector to unit norm if needed.

Parameters:

threshold (float, optional) – Tolerance used to decide whether renormalization is required.

Returns:

Norm of the state before normalization.

Return type:

float

truncate(threshold=1e-14)[source]

Set state-vector entries below a threshold to zero.

Parameters:

threshold (float, optional) – Absolute-value threshold.

Returns:

Truncated state vector.

Return type:

numpy.ndarray

expectation_value(operator, component='real')[source]

Compute an expectation value on the current state.

Parameters:
  • operator (tuple or numpy.ndarray or scipy.sparse.spmatrix) –

    Operator to apply. Supported formats are:

    • (row_list, col_list, value_list) sparse triplets,

    • dense NumPy matrix,

    • SciPy sparse matrix.

  • component (str, optional) – Output component selector: "real" or "imag".

Returns:

Selected component of the expectation value.

Return type:

float

Raises:
  • TypeError – If operator has an unsupported format.

  • ValueError – If matrix dimensions are incompatible with the state.

reduced_density_matrix(keep_indices, partitions_dict)[source]

Compute the reduced density matrix for a subsystem.

Parameters:
  • keep_indices (list[int]) – Lattice sites retained in the subsystem.

  • partitions_dict (dict) – Partition metadata/cache used to build the subsystem-environment factorization.

Returns:

Reduced density matrix in dense format.

Return type:

numpy.ndarray

entanglement_entropy(keep_indices, partitions_dict)[source]

Compute the bipartite entanglement entropy of a subsystem.

Parameters:
  • keep_indices (list[int]) – Lattice sites retained in the subsystem.

  • partitions_dict (dict) – Partition metadata/cache used to build the subsystem-environment factorization.

Returns:

Von Neumann entanglement entropy (base-2 logarithm convention).

Return type:

float

get_state_configurations(threshold=0.01, sector_configs=None, return_configs=False)[source]

List or return basis configurations with large amplitudes.

Parameters:
  • threshold (float, optional) – Minimum probability threshold used to keep configurations.

  • sector_configs (numpy.ndarray, optional) – If provided, lookup table mapping basis indices to configurations.

  • return_configs (bool, optional) – If True, return the selected configurations and amplitudes.

Returns:

If return_configs=True, returns (cfgs, vals). Otherwise returns None and logs the selected configurations.

Return type:

tuple or None

participation_renyi_entropy(alpha=2)[source]

Compute the participation Renyi entropy of the state in the current basis.

Parameters:

alpha (int, optional) – Renyi order. Must satisfy alpha > 0 and alpha != 1. The default alpha=2 corresponds to the inverse-participation-ratio form.

Returns:

Participation Renyi entropy computed with the natural logarithm.

Return type:

float

Raises:

ValueError – If alpha <= 0 or alpha == 1.

Notes

The result depends on the basis used to represent self.psi and assumes the state is normalized.

stabilizer_renyi_entropy(sector_configs, prob_threshold=0.01)[source]

Compute the Renyi-2 stabilizer entropy on a truncated sector-basis support.

Parameters:
  • sector_configs (numpy.ndarray) – Sector-basis configurations of shape (n_configs, n_sites). Row i corresponds to basis index i of self.psi.

  • prob_threshold (float, optional) – Tail tolerance used in extract_support() to choose the truncated support.

Returns:

Renyi-2 stabilizer entropy estimate computed from the retained support.

Return type:

float

Notes

The dominant cost scales with the support size, so lowering prob_threshold increases runtime and memory use.

edlgt.modeling.qmb_state.truncation(array, threshold=1e-14)[source]

Set array entries below a threshold to zero.

Parameters:
  • array (numpy.ndarray) – Input array.

  • threshold (float, optional) – Absolute-value threshold.

Returns:

Thresholded array.

Return type:

numpy.ndarray

edlgt.modeling.qmb_state.get_norm(psi)[source]

Compute the Euclidean norm of a complex state vector.

Parameters:

psi (numpy.ndarray) – Complex vector.

Returns:

Euclidean norm of psi.

Return type:

float

edlgt.modeling.qmb_state.mixed_exp_val_data(psi1, psi2, row_list, col_list, value_list)[source]

Compute a mixed expectation value from sparse triplet data.

Parameters:
  • psi1 (numpy.ndarray) – Bra-state coefficients.

  • psi2 (numpy.ndarray) – Ket-state coefficients.

  • row_list (numpy.ndarray) – Sparse triplet representation of the operator.

  • col_list (numpy.ndarray) – Sparse triplet representation of the operator.

  • value_list (numpy.ndarray) – Sparse triplet representation of the operator.

Returns:

Mixed expectation value <psi1|O|psi2>.

Return type:

complex