-
Notifications
You must be signed in to change notification settings - Fork 127
Description
What is your issue?
Ground State Energy Calculation Issues with LocalHam1D
Problem Summary
I'm trying to calculate the exact ground state energy of a 1D Heisenberg model to compare with my MPS state, but I'm encountering multiple issues with different approaches in quimb.
Environment
- quimb version: 1.11.0
- Python version: 3.10
- Operating system: Linux
- Installation method: conda environment
Code and Errors
Original attempt - missing function
import quimb.tensor as qtn
N = 6
H = qtn.ham_1d_heis(N, j=1.0, cyclic=False)
psi0 = qtn.MPS_rand_state(N, bond_dim=4, dtype='complex128')
energy = psi0.compute_local_expectation(H, max_bond=16)
print("Energia iniziale:", energy.item())
# This fails:
from quimb import exact_gs_energy
E_exact = exact_gs_energy(H)Error: ImportError: cannot import name 'exact_gs_energy' from 'quimb'
Attempt with heisenberg_energy
from quimb import heisenberg_energy
E_exact = heisenberg_energy(N, j=1.0, cyclic=False)Error: TypeError: heisenberg_energy() got an unexpected keyword argument 'j'
Attempt with DMRG2
dmrg = qtn.DMRG2(H, bond_dims=[10, 20, 50, 100], cutoffs=1e-12)
dmrg.solve(tol=1e-12, verbosity=1)
E_exact = dmrg.energyError:
File "tensor_dmrg.py", line 557, in __init__
self.phys_dim = ham.phys_dim()
AttributeError: 'LocalHam1D' object has no attribute 'phys_dim'
Attempt with matrix conversion
H_dense = H.to_dense() # To use numpy.linalg.eigvalsError: AttributeError: 'LocalHam1D' object has no attribute 'to_dense'
Questions
-
What is the correct way to calculate the exact ground state energy for a
LocalHam1Dobject created withham_1d_heis()? -
Is
exact_gs_energyavailable in the current version? If not, what's the recommended alternative? -
What's the correct syntax for
heisenberg_energy()? The function exists but parameter names seem different from what I expected. -
Why doesn't DMRG2 work with LocalHam1D? Is there a compatibility issue or do I need to convert the Hamiltonian to a different format?
-
How can I convert a
LocalHam1Dto a dense matrix for exact diagonalization on small systems?
Expected Behavior
I expect to be able to:
- Calculate the exact ground state energy of a small (N=6) Heisenberg chain
- Compare this with the energy of my random MPS state
- Use either analytical formulas, exact diagonalization, or DMRG
Minimal Working Example Needed
Could you provide a minimal working example that shows how to:
import quimb.tensor as qtn
N = 6
H = qtn.ham_1d_heis(N, j=1.0, cyclic=False)
psi = qtn.MPS_rand_state(N, bond_dim=4, dtype='complex128')
energy_mps = psi.compute_local_expectation(H, max_bond=16)
# What should go here to get the exact ground state energy?
energy_exact = ???
print(f"MPS energy: {energy_mps}")
print(f"Exact energy: {energy_exact}")
print(f"Error: {abs(energy_mps - energy_exact)}")Additional Context
This is for benchmarking MPS optimization algorithms, so having a reliable way to compute exact energies for small systems is crucial. I'm willing to use any approach (analytical, exact diagonalization, or DMRG) as long as it works reliably.
Thank you for your help!