QMB Hamiltonian Class

Utilities to assemble, diagonalize, and evolve quantum many-body Hamiltonians from accumulated sparse contributions.

class edlgt.modeling.qmb_hamiltonian.QMB_hamiltonian(lvals, size)[source]

Container for a quantum many-body Hamiltonian and derived quantities.

Initialize an empty Hamiltonian accumulator.

Parameters:
  • lvals (list or tuple) – Lattice dimensions.

  • size (int) – Hilbert-space dimension of the Hamiltonian.

add_term(term)[source]

Add a Hamiltonian contribution to the internal sparse triplet lists.

Parameters:

term (tuple or numpy.ndarray or scipy.sparse.spmatrix) – Hamiltonian contribution provided as a sparse triplet (row_list, col_list, value_list), a dense matrix, or a SciPy sparse matrix.

Raises:

TypeError – If term has an unsupported format.

build(format)[source]

Build the Hamiltonian representation from accumulated triplets.

Parameters:

format (str) – Target representation: "dense", "sparse", or "linear".

convert_hamiltonian(format)[source]

Convert the Hamiltonian to another representation type.

Parameters:

format (str) – Target representation: "dense", "sparse", or "linear".

Raises:

ValueError – If format is not supported.

diagonalize(n_eigs, format, loc_dims, print_results=True)[source]

Diagonalize the Hamiltonian and store eigenvalues/eigenstates.

Parameters:
  • n_eigs (int or str) – Number of eigenpairs to compute, or "full" for full diagonalization.

  • format (str) – Hamiltonian representation to use for diagonalization.

  • loc_dims (list or numpy.ndarray) – Local Hilbert-space dimensions used to build QMB_state objects for eigenvectors.

  • print_results (bool, optional) – If True, log energies and energy densities.

Return type:

None

Raises:

ValueError – If n_eigs is invalid.

time_evolution(initial_state, time_line, loc_dims)[source]

Evolve an initial state along a time grid using the current Hamiltonian.

Parameters:
  • initial_state (numpy.ndarray) – Initial state vector.

  • time_line (numpy.ndarray) – Time samples at which the evolved state is returned.

  • loc_dims (numpy.ndarray) – Local Hilbert-space dimensions used to wrap evolved states into QMB_state objects.

Returns:

Evolved states are stored in self.psi_time.

Return type:

None

partition_function(beta)[source]

Compute the partition function for inverse temperature beta.

Parameters:

beta (float) – Inverse temperature.

Returns:

Partition function Z.

Return type:

float

Raises:

ValueError – If the computed partition function is non-positive.

free_energy(beta)[source]

Compute the free energy at inverse temperature beta.

Parameters:

beta (float) – Inverse temperature.

Returns:

Free energy.

Return type:

float

thermal_average(beta)[source]

Compute the thermal average energy at inverse temperature beta.

Parameters:

beta (float) – Inverse temperature.

Returns:

Thermal average energy.

Return type:

float

f_prime(beta)[source]

Compute the derivative used in the Newton solve for beta.

Parameters:

beta (float) – Inverse temperature.

Returns:

Derivative-like quantity used by get_beta().

Return type:

float

F_prime(beta)

Compute the derivative used in the Newton solve for beta.

Parameters:

beta (float) – Inverse temperature.

Returns:

Derivative-like quantity used by get_beta().

Return type:

float

get_beta(state, threshold=1e-10, max_iter=1000)[source]

Estimate an effective inverse temperature for a reference state.

Parameters:
  • state (numpy.ndarray) – Reference state vector.

  • threshold (float, optional) – Convergence tolerance for the Newton iteration.

  • max_iter (int, optional) – Maximum number of Newton iterations.

Returns:

Estimated inverse temperature beta.

Return type:

float

Notes

The method solves for the root of the difference between the thermal average energy and the energy of state.

get_r_value()[source]

Compute adjacent-gap ratio statistics from the stored spectrum.

Returns:

Array of local adjacent-gap ratios.

Return type:

numpy.ndarray

Raises:

ValueError – If the Hamiltonian has not been fully diagonalized.

print_energy(en_state)[source]

Log the energy density of a selected eigenstate index.

Parameters:

en_state (int) – Eigenstate index in self.Nenergies.

get_sparsity()[source]

Log the current sparsity estimated from accumulated triplets.

edlgt.modeling.qmb_hamiltonian.get_entropy_partition(lvals, option='half')[source]

Return lattice-site indices used for a standard bipartition.

Parameters:
  • lvals (list or tuple) – Lattice dimensions.

  • option (str, optional) – Partition preset. Currently only "half" is implemented.

Returns:

Site indices belonging to the selected subsystem.

Return type:

list[int]

Raises:

NotImplementedError – If option is not implemented.