energy reprogrammed with general nn-hamiltonian