Measures

Analysis helpers for spectra and correlators, including adjacent-gap ratios, distance-averaged correlator summaries, and 2D structure-factor evaluation.

The API section below documents the functions exported in edlgt.tools.measures.__all__.

Post-processing helpers for spectral and correlation-based observables.

This module collects lightweight analysis utilities used in scripts and example workflows, including:

  • level-spacing statistics (r_values),

  • distance-resolved correlator summaries (analyze_correlator),

  • structure-factor evaluation on 2D lattices (structure_factor),

  • simple charge/density combinations from two occupancies.

Only a subset of functions is exported as public API via __all__.

edlgt.tools.measures.structure_factor(corr, lvals)[source]

Compute the 2D static structure factor on a rectangular lattice.

Parameters:
  • corr (numpy.ndarray) – Correlator array indexed as corr[x1, y1, x2, y2].

  • lvals (sequence[int]) – Lattice dimensions [Lx, Ly].

Returns:

Complex array of shape (Lx, Ly) containing the structure factor on the discrete Brillouin-zone grid.

Return type:

numpy.ndarray

Notes

This routine calls single_structure_factor() for each momentum point.

edlgt.tools.measures.get_charge(N_plus, N_minus)[source]

Return the charge-like combination used by the project conventions.

Parameters:
  • N_plus (float or numpy.ndarray) – Inputs combined element-wise if arrays are provided.

  • N_minus (float or numpy.ndarray) – Inputs combined element-wise if arrays are provided.

Returns:

N_plus + N_minus - 2.

Return type:

float or numpy.ndarray

edlgt.tools.measures.get_density(N_plus, N_minus)[source]

Return the density-like combination used by the project conventions.

Parameters:
  • N_plus (float or numpy.ndarray) – Inputs combined element-wise if arrays are provided.

  • N_minus (float or numpy.ndarray) – Inputs combined element-wise if arrays are provided.

Returns:

N_plus - N_minus + 2.

Return type:

float or numpy.ndarray

edlgt.tools.measures.analyze_correlator(corr)[source]

Average a 2D correlator by Euclidean distance.

Parameters:

corr (numpy.ndarray) – Correlator array indexed as corr[x1, y1, x2, y2].

Returns:

Array of shape (n_distances, 3) with columns:

  1. distance r,

  2. mean absolute correlator value at that distance,

  3. standard error of the mean (computed from the sample variance).

Return type:

numpy.ndarray

Notes

Distances are rounded to 3 decimal places before grouping to avoid small floating-point differences splitting equivalent distances.

edlgt.tools.measures.r_values(energy)[source]

Compute adjacent-gap ratios from a spectrum.

Parameters:

energy (array-like) – One-dimensional array of energy eigenvalues. The input is sorted internally before computing level spacings.

Returns:

(r_array, delta_E) where:

  • delta_E[i] = E[i+1] - E[i] for the sorted spectrum,

  • r_array[i] is the ratio between adjacent spacings.

Return type:

tuple

Notes

The first entry of r_array is set to 1 by convention because it has no left neighbor spacing.