Ordering of exact diagonalization basis
Posted: 20 Jan 2025, 15:39
I am trying to match the results of TeNPy with a few other codes and am trying to figure out the TeNPy convention for the ordering of the basis in ExactDiag. For example, if we have SpinHalfFermionSites with 3 sites and (2, 2) electrons, then in total the Hilbert space has dimension 9 (N and Sz are conserved). Usually, I would expect that the Hilbert space is ordered in ascending binary numbers. For example, I would expect the statevector in this case, to be returned in the following order (using SpinHalfFermionSite notation):
[3, 3, 0]
[3, 1, 2]
[1, 3, 2]
[3, 2, 1]
[3, 0, 3]
[1, 2, 3]
[2, 3, 1]
[2, 1, 3]
[0, 3, 3]
However, it is actually returned in this order (which I can deduce by converting all the product states one-by-one):
[2, 3, 1]
[2, 1, 3]
[0, 3, 3]
[3, 2, 1]
[3, 0, 3]
[3, 3, 0]
[3, 1, 2]
[1, 2, 3]
[1, 3, 2]
Does anyone know what is the TeNPy convention for the ordering? Is it sorted in some binary representation?
Sample code to recover the basis ordering by brute force:
[3, 3, 0]
[3, 1, 2]
[1, 3, 2]
[3, 2, 1]
[3, 0, 3]
[1, 2, 3]
[2, 3, 1]
[2, 1, 3]
[0, 3, 3]
However, it is actually returned in this order (which I can deduce by converting all the product states one-by-one):
[2, 3, 1]
[2, 1, 3]
[0, 3, 3]
[3, 2, 1]
[3, 0, 3]
[3, 3, 0]
[3, 1, 2]
[1, 2, 3]
[1, 3, 2]
Does anyone know what is the TeNPy convention for the ordering? Is it sorted in some binary representation?
Sample code to recover the basis ordering by brute force:
Python: Select all
basis_ordering = []
for i, state in enumerate(product_states):
prod_mps = MPS.from_product_state(ED.model.lat.mps_sites(), state)
prod_statevector = list(ED.mps_to_full(prod_mps).to_ndarray())
idx = prod_statevector.index(1)
basis_ordering.append(idx)