Are all your calculations properly converged?
Anyway, you miss the line
device_configuration.update()
right after
device_configuration.setCalculator(calculator(), initial_state=device_configuration)
I would also save the device configurations in case you want to perform further analysis later on.
Basically something like this:
...
device_configuration.setCalculator(calculator(),
initial_state=device_configuration)
device_configuration.update()
nlsave("filename.nc", device_cofiguration)
...