starting from Mehdi's code to experiment with batteries