Computing spatially-periodic electrical fields by charge iteration