The distances variable basically does two things. It creates a range around the nearest distance, where either the interaction will be constant (to catch any small numerical difference in distances) or a (d/d0)^2 fall-off which is common in these models. The final point is to truncate the interactions at some large distance, it is paired with a zero-term in the hopping elements.