SIZING OF ENERGY STORAGE SYSTEMS FROM FIRST PRINCIPLES