iterative self-consistent algorithm