Tool for evaluating the polar-decomposition WPD invariant for finite one-dimensional non-Hermitian chains. This tool is based on the principle introduced in arXiv:2607.05900.
The input is a square NumPy array containing the finite-chain Hamiltonian. The saved RF model predicts the crop length ell_star, and the WPD invariant is then evaluated directly from the supplied matrix.
This folder contains: -nhwpd.py -README.md
Download model.zip from the Zenodo archive linked below and extract the model.pkl file into the same folder as nhwpd.py.
Zenodo model file: https://zenodo.org/records/21338187
How to use: (Example)
import numpy as np
from nhwpd import evaluate_wpd
# Suppose you want to evaluate the invariant for the Hamiltonian matrix
# of an N-site Hatano-Nelson chain.
N = 128
H = np.zeros((N, N), dtype=complex)
for n in range(N - 1):
H[n + 1, n] = 1.0
H[n, n + 1] = 0.55
# Assuming the model.pkl file is in the same folder
result = evaluate_wpd(H, E_B=0.0)
For evaluating the invariant directly for a matrix, load the matrix and use the tool as:
H = np.load("matrix.npy")
result = evaluate_wpd(H, E_B=0.0)
If the matrix is disordered, the script first averages each hopping diagonal and feeds that effective finite-range clean model to the RF predictor. This predicts a crop-length ell_star which is used to evaluate the wpd invariant for the original disordered input matrix. The code also computes the winding number of the diagonal-averaged clean matrix. "distance_to_clean_winding" and "reliable" say whether the wpd value is close to this clean winding.
The default tolerance is 0.1. If the predicted ell_star does not give a wpd close to the clean winding, the code tries larger crop lengths in steps of 5 until the tolerance is reached or no larger crop is possible.
If no available crop reaches the tolerance, evaluate_wpd raises MatrixTooSmallError. This usually means that the matrix is too small for this base energy and tolerance.
The diagonal averaging is only a guide for selecting ell_star. If a matrix has isolated large entries, or otherwise is not well represented by averaged diagonals, the predicted crop length may be unreliable. In that case result["residual"] will usually be large.