If C0 is the initial capacitance of the condenser before water rises in it then

(R is the mean radius and l is the length of the capacitor plates.)
Suppose the liquid rises to a height h in it. Then the capacitance of the condenser is

and energy of the capacitor and the liquid (including both gravitational and electrosatic contributions) is

If the capacitor were not connected to a battery this energy would have to be minimized. But the capacitor is connected to the battery and, in effect, the potential energy of the whole system has to be minimized. Suppose we increase h by δh. Then the energy of the capacitor and the liquid increases by

and that of the cell diminishes by the quantity Acell which is the product of charge flown and V
