# Hamiltonian Flex Terms

When I was about the implement the first-order term of the SSH model yesterday, I came to realize that with the current structure of our Hamiltonian this isn't all that easy.

This term is of the form where K is a function of the position. Rather than calculating the factor on-demand it shuld be pre-computed, as it is constant throughout the simulation. Either way we run into the problem that the Metropolis function will only pass the value of the current state vector x to the Hamiltonian term, rather than its index. Hence the correct pre-factor can not be assigned.

Since this is the second time we face the problem that our Hamiltonian structure is "insufficient" (the first one being the second-order SSH term), we should re-consider the design. Rather than (or in addition to) a "general multi-site term" we should have the notion of a "flex term", which takes a lot of arguments (lattice, statespace, neighbours, current site index) and directly provides a "diff" function for Metropolis algorithm. I have done exactly that for the quadratic SSH term, when I wrote a whole new class from scratch.

Note that for the problem described above another possibility would be to sort of interpret K as a bond strength and abuse the callbonds construction for that purpose. I'm not sure if like that though and whether it even works out. Also this approach would only cover the case of *constant* site-dependent pre-factors since the lattice does not have access to the statespace.