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_statefrom 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 (
intorlistornumpy.ndarray, optional) – Local Hilbert-space dimensions per site.symmetry_sector (
bool, optional) – IfTrue, treatpsias living in a symmetry-reduced basis.debug_mode (
bool, optional) – IfTrue, perform additional internal consistency checks.
- Return type:
- 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:
- expectation_value(operator, component='real')[source]
Compute an expectation value on the current state.
- Parameters:
operator (
tupleornumpy.ndarrayorscipy.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:
- Raises:
TypeError – If
operatorhas 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:
- entanglement_entropy(keep_indices, partitions_dict)[source]
Compute the bipartite entanglement entropy of a subsystem.
- 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) – IfTrue, return the selected configurations and amplitudes.
- Returns:
If
return_configs=True, returns(cfgs, vals). Otherwise returnsNoneand logs the selected configurations.- Return type:
- 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 satisfyalpha > 0andalpha != 1. The defaultalpha=2corresponds to the inverse-participation-ratio form.- Returns:
Participation Renyi entropy computed with the natural logarithm.
- Return type:
- Raises:
ValueError – If
alpha <= 0oralpha == 1.
Notes
The result depends on the basis used to represent
self.psiand 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). Rowicorresponds to basis indexiofself.psi.prob_threshold (
float, optional) – Tail tolerance used inextract_support()to choose the truncated support.
- Returns:
Renyi-2 stabilizer entropy estimate computed from the retained support.
- Return type:
Notes
The dominant cost scales with the support size, so lowering
prob_thresholdincreases 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:
- 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:
- 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: