Open gerardPlanella opened 11 months ago
Is this using SpinHam1D(S=S, cyclic=True)
? I guess currently it only handles translationally invariant hamiltonians, but could be modified quite easily.
It's might be a little more complicated than just removing that guard however, as PBC MPOs need special boundary conditions and can be a little hard to reason about.
Exactly, I tried removing the guard to check if it worked but it is not that simple.
What happened?
Hello,
How can you define a Hamiltonian for an MPS with PBC using the SpinHam1D class? If you try to do this you get the error:
`NotImplementedError Traceback (most recent call last) c:\Users\gerar\OneDrive\Documents\AI\QGNN\src\QGNN\baselines\beliefpropagation\tn_simple_update.ipynb Cell 9 line 6 62 # Add the interaction term and consider cyclic term 63 if J_ab != 0 and (abs(a - b) == 1 or (data[idx].pbc and (abs(a - b) == n[0] - 1))): ---> 64 ham_builder[a, b] += J_ab * 4, 'Z', 'Z' 65 ham_builder[b, a] += J_ab * 4, 'Z', 'Z' 70 ham_local_2 = ham_builder.build_mpo(n[0])
File ***\lib\site-packages\quimb\tensor\tensor_builder.py:3591, in SpinHam1D.getitem(self, sites) 3589 i, j = sorted(sites) 3590 if j - i != 1: -> 3591 raise NotImplementedError("Can only add nearest neighbour terms.") 3593 return _TermAdder(self.var_two_site_terms.get(sites, None), 2)
NotImplementedError: Can only add nearest neighbour terms.`
The problem comes from adding the interaction term from the first and last particle due to the PBC (in the library's code it checks for neighbors with the condition
a - b != 1
while it should beabs(a - b) != 1 and (PBC and (abs(a - b) != NumParticles - 1))))
. Is there a workaround? I need to instantiate my Hamiltonian with this class to create an MPO and thus use DRMG. The limitation with defining an MPO directly is the lack of fully customizable Hamiltonians.What did you expect to happen?
No response
Minimal Complete Verifiable Example
No response
Relevant log output
No response
Anything else we need to know?
No response
Environment
Yes