added support for periodic boundary condition to functions iteraten() and stepn()