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:
- add_term(term)[source]
Add a Hamiltonian contribution to the internal sparse triplet lists.
- Parameters:
term (
tupleornumpy.ndarrayorscipy.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
termhas 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
formatis not supported.
- diagonalize(n_eigs, format, loc_dims, print_results=True)[source]
Diagonalize the Hamiltonian and store eigenvalues/eigenstates.
- Parameters:
n_eigs (
intorstr) – Number of eigenpairs to compute, or"full"for full diagonalization.format (
str) – Hamiltonian representation to use for diagonalization.loc_dims (
listornumpy.ndarray) – Local Hilbert-space dimensions used to buildQMB_stateobjects for eigenvectors.print_results (
bool, optional) – IfTrue, log energies and energy densities.
- Return type:
- Raises:
ValueError – If
n_eigsis 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 intoQMB_stateobjects.
- Returns:
Evolved states are stored in
self.psi_time.- Return type:
- partition_function(beta)[source]
Compute the partition function for inverse temperature
beta.- Parameters:
beta (
float) – Inverse temperature.- Returns:
Partition function
Z.- Return type:
- Raises:
ValueError – If the computed partition function is non-positive.
- 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:
- 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:
- 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:
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:
- Raises:
ValueError – If the Hamiltonian has not been fully diagonalized.
- edlgt.modeling.qmb_hamiltonian.get_entropy_partition(lvals, option='half')[source]
Return lattice-site indices used for a standard bipartition.
- Parameters:
- Returns:
Site indices belonging to the selected subsystem.
- Return type:
list[int]- Raises:
NotImplementedError – If
optionis not implemented.